1 // Generated file, do not edit by hand, see `crate/ra_tools/src/codegen`
4 ast::{self, AstChildren, AstNode},
8 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
10 pub(crate) syntax: SyntaxNode,
12 impl AstNode for Alias {
13 fn can_cast(kind: SyntaxKind) -> bool {
19 fn cast(syntax: SyntaxNode) -> Option<Self> {
20 if Self::can_cast(syntax.kind()) {
26 fn syntax(&self) -> &SyntaxNode {
30 impl ast::NameOwner for Alias {}
32 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
34 pub(crate) syntax: SyntaxNode,
36 impl AstNode for ArgList {
37 fn can_cast(kind: SyntaxKind) -> bool {
43 fn cast(syntax: SyntaxNode) -> Option<Self> {
44 if Self::can_cast(syntax.kind()) {
50 fn syntax(&self) -> &SyntaxNode {
55 pub fn args(&self) -> AstChildren<Expr> {
56 AstChildren::new(&self.syntax)
59 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
60 pub struct ArrayExpr {
61 pub(crate) syntax: SyntaxNode,
63 impl AstNode for ArrayExpr {
64 fn can_cast(kind: SyntaxKind) -> bool {
70 fn cast(syntax: SyntaxNode) -> Option<Self> {
71 if Self::can_cast(syntax.kind()) {
77 fn syntax(&self) -> &SyntaxNode {
82 pub fn exprs(&self) -> AstChildren<Expr> {
83 AstChildren::new(&self.syntax)
86 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
87 pub struct ArrayType {
88 pub(crate) syntax: SyntaxNode,
90 impl AstNode for ArrayType {
91 fn can_cast(kind: SyntaxKind) -> bool {
97 fn cast(syntax: SyntaxNode) -> Option<Self> {
98 if Self::can_cast(syntax.kind()) {
104 fn syntax(&self) -> &SyntaxNode {
109 pub fn type_ref(&self) -> Option<TypeRef> {
110 AstChildren::new(&self.syntax).next()
112 pub fn expr(&self) -> Option<Expr> {
113 AstChildren::new(&self.syntax).next()
116 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
117 pub struct AssocTypeArg {
118 pub(crate) syntax: SyntaxNode,
120 impl AstNode for AssocTypeArg {
121 fn can_cast(kind: SyntaxKind) -> bool {
123 ASSOC_TYPE_ARG => true,
127 fn cast(syntax: SyntaxNode) -> Option<Self> {
128 if Self::can_cast(syntax.kind()) {
129 Some(Self { syntax })
134 fn syntax(&self) -> &SyntaxNode {
139 pub fn name_ref(&self) -> Option<NameRef> {
140 AstChildren::new(&self.syntax).next()
142 pub fn type_ref(&self) -> Option<TypeRef> {
143 AstChildren::new(&self.syntax).next()
146 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
148 pub(crate) syntax: SyntaxNode,
150 impl AstNode for Attr {
151 fn can_cast(kind: SyntaxKind) -> bool {
157 fn cast(syntax: SyntaxNode) -> Option<Self> {
158 if Self::can_cast(syntax.kind()) {
159 Some(Self { syntax })
164 fn syntax(&self) -> &SyntaxNode {
169 pub fn value(&self) -> Option<TokenTree> {
170 AstChildren::new(&self.syntax).next()
173 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
174 pub struct AwaitExpr {
175 pub(crate) syntax: SyntaxNode,
177 impl AstNode for AwaitExpr {
178 fn can_cast(kind: SyntaxKind) -> bool {
184 fn cast(syntax: SyntaxNode) -> Option<Self> {
185 if Self::can_cast(syntax.kind()) {
186 Some(Self { syntax })
191 fn syntax(&self) -> &SyntaxNode {
196 pub fn expr(&self) -> Option<Expr> {
197 AstChildren::new(&self.syntax).next()
200 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
202 pub(crate) syntax: SyntaxNode,
204 impl AstNode for BinExpr {
205 fn can_cast(kind: SyntaxKind) -> bool {
211 fn cast(syntax: SyntaxNode) -> Option<Self> {
212 if Self::can_cast(syntax.kind()) {
213 Some(Self { syntax })
218 fn syntax(&self) -> &SyntaxNode {
223 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
225 pub(crate) syntax: SyntaxNode,
227 impl AstNode for BindPat {
228 fn can_cast(kind: SyntaxKind) -> bool {
234 fn cast(syntax: SyntaxNode) -> Option<Self> {
235 if Self::can_cast(syntax.kind()) {
236 Some(Self { syntax })
241 fn syntax(&self) -> &SyntaxNode {
245 impl ast::NameOwner for BindPat {}
247 pub fn pat(&self) -> Option<Pat> {
248 AstChildren::new(&self.syntax).next()
251 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
253 pub(crate) syntax: SyntaxNode,
255 impl AstNode for Block {
256 fn can_cast(kind: SyntaxKind) -> bool {
262 fn cast(syntax: SyntaxNode) -> Option<Self> {
263 if Self::can_cast(syntax.kind()) {
264 Some(Self { syntax })
269 fn syntax(&self) -> &SyntaxNode {
273 impl ast::AttrsOwner for Block {}
275 pub fn statements(&self) -> AstChildren<Stmt> {
276 AstChildren::new(&self.syntax)
278 pub fn expr(&self) -> Option<Expr> {
279 AstChildren::new(&self.syntax).next()
282 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
283 pub struct BlockExpr {
284 pub(crate) syntax: SyntaxNode,
286 impl AstNode for BlockExpr {
287 fn can_cast(kind: SyntaxKind) -> bool {
293 fn cast(syntax: SyntaxNode) -> Option<Self> {
294 if Self::can_cast(syntax.kind()) {
295 Some(Self { syntax })
300 fn syntax(&self) -> &SyntaxNode {
305 pub fn block(&self) -> Option<Block> {
306 AstChildren::new(&self.syntax).next()
309 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
311 pub(crate) syntax: SyntaxNode,
313 impl AstNode for BoxPat {
314 fn can_cast(kind: SyntaxKind) -> bool {
320 fn cast(syntax: SyntaxNode) -> Option<Self> {
321 if Self::can_cast(syntax.kind()) {
322 Some(Self { syntax })
327 fn syntax(&self) -> &SyntaxNode {
332 pub fn pat(&self) -> Option<Pat> {
333 AstChildren::new(&self.syntax).next()
336 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
337 pub struct BreakExpr {
338 pub(crate) syntax: SyntaxNode,
340 impl AstNode for BreakExpr {
341 fn can_cast(kind: SyntaxKind) -> bool {
347 fn cast(syntax: SyntaxNode) -> Option<Self> {
348 if Self::can_cast(syntax.kind()) {
349 Some(Self { syntax })
354 fn syntax(&self) -> &SyntaxNode {
359 pub fn expr(&self) -> Option<Expr> {
360 AstChildren::new(&self.syntax).next()
363 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
364 pub struct CallExpr {
365 pub(crate) syntax: SyntaxNode,
367 impl AstNode for CallExpr {
368 fn can_cast(kind: SyntaxKind) -> bool {
374 fn cast(syntax: SyntaxNode) -> Option<Self> {
375 if Self::can_cast(syntax.kind()) {
376 Some(Self { syntax })
381 fn syntax(&self) -> &SyntaxNode {
385 impl ast::ArgListOwner for CallExpr {}
387 pub fn expr(&self) -> Option<Expr> {
388 AstChildren::new(&self.syntax).next()
391 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
392 pub struct CastExpr {
393 pub(crate) syntax: SyntaxNode,
395 impl AstNode for CastExpr {
396 fn can_cast(kind: SyntaxKind) -> bool {
402 fn cast(syntax: SyntaxNode) -> Option<Self> {
403 if Self::can_cast(syntax.kind()) {
404 Some(Self { syntax })
409 fn syntax(&self) -> &SyntaxNode {
414 pub fn expr(&self) -> Option<Expr> {
415 AstChildren::new(&self.syntax).next()
417 pub fn type_ref(&self) -> Option<TypeRef> {
418 AstChildren::new(&self.syntax).next()
421 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
422 pub struct Condition {
423 pub(crate) syntax: SyntaxNode,
425 impl AstNode for Condition {
426 fn can_cast(kind: SyntaxKind) -> bool {
432 fn cast(syntax: SyntaxNode) -> Option<Self> {
433 if Self::can_cast(syntax.kind()) {
434 Some(Self { syntax })
439 fn syntax(&self) -> &SyntaxNode {
444 pub fn pat(&self) -> Option<Pat> {
445 AstChildren::new(&self.syntax).next()
447 pub fn expr(&self) -> Option<Expr> {
448 AstChildren::new(&self.syntax).next()
451 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
452 pub struct ConstDef {
453 pub(crate) syntax: SyntaxNode,
455 impl AstNode for ConstDef {
456 fn can_cast(kind: SyntaxKind) -> bool {
462 fn cast(syntax: SyntaxNode) -> Option<Self> {
463 if Self::can_cast(syntax.kind()) {
464 Some(Self { syntax })
469 fn syntax(&self) -> &SyntaxNode {
473 impl ast::VisibilityOwner for ConstDef {}
474 impl ast::NameOwner for ConstDef {}
475 impl ast::TypeParamsOwner for ConstDef {}
476 impl ast::AttrsOwner for ConstDef {}
477 impl ast::DocCommentsOwner for ConstDef {}
478 impl ast::TypeAscriptionOwner for ConstDef {}
480 pub fn body(&self) -> Option<Expr> {
481 AstChildren::new(&self.syntax).next()
484 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
485 pub struct ContinueExpr {
486 pub(crate) syntax: SyntaxNode,
488 impl AstNode for ContinueExpr {
489 fn can_cast(kind: SyntaxKind) -> bool {
491 CONTINUE_EXPR => true,
495 fn cast(syntax: SyntaxNode) -> Option<Self> {
496 if Self::can_cast(syntax.kind()) {
497 Some(Self { syntax })
502 fn syntax(&self) -> &SyntaxNode {
507 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
508 pub struct DynTraitType {
509 pub(crate) syntax: SyntaxNode,
511 impl AstNode for DynTraitType {
512 fn can_cast(kind: SyntaxKind) -> bool {
514 DYN_TRAIT_TYPE => true,
518 fn cast(syntax: SyntaxNode) -> Option<Self> {
519 if Self::can_cast(syntax.kind()) {
520 Some(Self { syntax })
525 fn syntax(&self) -> &SyntaxNode {
529 impl ast::TypeBoundsOwner for DynTraitType {}
531 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
533 pub(crate) syntax: SyntaxNode,
535 impl AstNode for EnumDef {
536 fn can_cast(kind: SyntaxKind) -> bool {
542 fn cast(syntax: SyntaxNode) -> Option<Self> {
543 if Self::can_cast(syntax.kind()) {
544 Some(Self { syntax })
549 fn syntax(&self) -> &SyntaxNode {
553 impl ast::VisibilityOwner for EnumDef {}
554 impl ast::NameOwner for EnumDef {}
555 impl ast::TypeParamsOwner for EnumDef {}
556 impl ast::AttrsOwner for EnumDef {}
557 impl ast::DocCommentsOwner for EnumDef {}
559 pub fn variant_list(&self) -> Option<EnumVariantList> {
560 AstChildren::new(&self.syntax).next()
563 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
564 pub struct EnumVariant {
565 pub(crate) syntax: SyntaxNode,
567 impl AstNode for EnumVariant {
568 fn can_cast(kind: SyntaxKind) -> bool {
570 ENUM_VARIANT => true,
574 fn cast(syntax: SyntaxNode) -> Option<Self> {
575 if Self::can_cast(syntax.kind()) {
576 Some(Self { syntax })
581 fn syntax(&self) -> &SyntaxNode {
585 impl ast::NameOwner for EnumVariant {}
586 impl ast::DocCommentsOwner for EnumVariant {}
587 impl ast::AttrsOwner for EnumVariant {}
589 pub fn expr(&self) -> Option<Expr> {
590 AstChildren::new(&self.syntax).next()
593 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
594 pub struct EnumVariantList {
595 pub(crate) syntax: SyntaxNode,
597 impl AstNode for EnumVariantList {
598 fn can_cast(kind: SyntaxKind) -> bool {
600 ENUM_VARIANT_LIST => true,
604 fn cast(syntax: SyntaxNode) -> Option<Self> {
605 if Self::can_cast(syntax.kind()) {
606 Some(Self { syntax })
611 fn syntax(&self) -> &SyntaxNode {
615 impl EnumVariantList {
616 pub fn variants(&self) -> AstChildren<EnumVariant> {
617 AstChildren::new(&self.syntax)
620 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
622 TupleExpr(TupleExpr),
623 ArrayExpr(ArrayExpr),
624 ParenExpr(ParenExpr),
626 LambdaExpr(LambdaExpr),
630 WhileExpr(WhileExpr),
631 ContinueExpr(ContinueExpr),
632 BreakExpr(BreakExpr),
634 BlockExpr(BlockExpr),
635 ReturnExpr(ReturnExpr),
636 MatchExpr(MatchExpr),
637 RecordLit(RecordLit),
639 IndexExpr(IndexExpr),
640 MethodCallExpr(MethodCallExpr),
641 FieldExpr(FieldExpr),
642 AwaitExpr(AwaitExpr),
644 TryBlockExpr(TryBlockExpr),
647 PrefixExpr(PrefixExpr),
648 RangeExpr(RangeExpr),
651 MacroCall(MacroCall),
653 impl From<TupleExpr> for Expr {
654 fn from(node: TupleExpr) -> Expr {
655 Expr::TupleExpr(node)
658 impl From<ArrayExpr> for Expr {
659 fn from(node: ArrayExpr) -> Expr {
660 Expr::ArrayExpr(node)
663 impl From<ParenExpr> for Expr {
664 fn from(node: ParenExpr) -> Expr {
665 Expr::ParenExpr(node)
668 impl From<PathExpr> for Expr {
669 fn from(node: PathExpr) -> Expr {
673 impl From<LambdaExpr> for Expr {
674 fn from(node: LambdaExpr) -> Expr {
675 Expr::LambdaExpr(node)
678 impl From<IfExpr> for Expr {
679 fn from(node: IfExpr) -> Expr {
683 impl From<LoopExpr> for Expr {
684 fn from(node: LoopExpr) -> Expr {
688 impl From<ForExpr> for Expr {
689 fn from(node: ForExpr) -> Expr {
693 impl From<WhileExpr> for Expr {
694 fn from(node: WhileExpr) -> Expr {
695 Expr::WhileExpr(node)
698 impl From<ContinueExpr> for Expr {
699 fn from(node: ContinueExpr) -> Expr {
700 Expr::ContinueExpr(node)
703 impl From<BreakExpr> for Expr {
704 fn from(node: BreakExpr) -> Expr {
705 Expr::BreakExpr(node)
708 impl From<Label> for Expr {
709 fn from(node: Label) -> Expr {
713 impl From<BlockExpr> for Expr {
714 fn from(node: BlockExpr) -> Expr {
715 Expr::BlockExpr(node)
718 impl From<ReturnExpr> for Expr {
719 fn from(node: ReturnExpr) -> Expr {
720 Expr::ReturnExpr(node)
723 impl From<MatchExpr> for Expr {
724 fn from(node: MatchExpr) -> Expr {
725 Expr::MatchExpr(node)
728 impl From<RecordLit> for Expr {
729 fn from(node: RecordLit) -> Expr {
730 Expr::RecordLit(node)
733 impl From<CallExpr> for Expr {
734 fn from(node: CallExpr) -> Expr {
738 impl From<IndexExpr> for Expr {
739 fn from(node: IndexExpr) -> Expr {
740 Expr::IndexExpr(node)
743 impl From<MethodCallExpr> for Expr {
744 fn from(node: MethodCallExpr) -> Expr {
745 Expr::MethodCallExpr(node)
748 impl From<FieldExpr> for Expr {
749 fn from(node: FieldExpr) -> Expr {
750 Expr::FieldExpr(node)
753 impl From<AwaitExpr> for Expr {
754 fn from(node: AwaitExpr) -> Expr {
755 Expr::AwaitExpr(node)
758 impl From<TryExpr> for Expr {
759 fn from(node: TryExpr) -> Expr {
763 impl From<TryBlockExpr> for Expr {
764 fn from(node: TryBlockExpr) -> Expr {
765 Expr::TryBlockExpr(node)
768 impl From<CastExpr> for Expr {
769 fn from(node: CastExpr) -> Expr {
773 impl From<RefExpr> for Expr {
774 fn from(node: RefExpr) -> Expr {
778 impl From<PrefixExpr> for Expr {
779 fn from(node: PrefixExpr) -> Expr {
780 Expr::PrefixExpr(node)
783 impl From<RangeExpr> for Expr {
784 fn from(node: RangeExpr) -> Expr {
785 Expr::RangeExpr(node)
788 impl From<BinExpr> for Expr {
789 fn from(node: BinExpr) -> Expr {
793 impl From<Literal> for Expr {
794 fn from(node: Literal) -> Expr {
798 impl From<MacroCall> for Expr {
799 fn from(node: MacroCall) -> Expr {
800 Expr::MacroCall(node)
803 impl AstNode for Expr {
804 fn can_cast(kind: SyntaxKind) -> bool {
806 TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR
807 | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL
808 | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR
809 | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR
810 | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL => {
816 fn cast(syntax: SyntaxNode) -> Option<Self> {
817 let res = match syntax.kind() {
818 TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }),
819 ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }),
820 PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }),
821 PATH_EXPR => Expr::PathExpr(PathExpr { syntax }),
822 LAMBDA_EXPR => Expr::LambdaExpr(LambdaExpr { syntax }),
823 IF_EXPR => Expr::IfExpr(IfExpr { syntax }),
824 LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }),
825 FOR_EXPR => Expr::ForExpr(ForExpr { syntax }),
826 WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }),
827 CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }),
828 BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }),
829 LABEL => Expr::Label(Label { syntax }),
830 BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
831 RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }),
832 MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
833 RECORD_LIT => Expr::RecordLit(RecordLit { syntax }),
834 CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
835 INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
836 METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
837 FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }),
838 AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }),
839 TRY_EXPR => Expr::TryExpr(TryExpr { syntax }),
840 TRY_BLOCK_EXPR => Expr::TryBlockExpr(TryBlockExpr { syntax }),
841 CAST_EXPR => Expr::CastExpr(CastExpr { syntax }),
842 REF_EXPR => Expr::RefExpr(RefExpr { syntax }),
843 PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }),
844 RANGE_EXPR => Expr::RangeExpr(RangeExpr { syntax }),
845 BIN_EXPR => Expr::BinExpr(BinExpr { syntax }),
846 LITERAL => Expr::Literal(Literal { syntax }),
847 MACRO_CALL => Expr::MacroCall(MacroCall { syntax }),
852 fn syntax(&self) -> &SyntaxNode {
854 Expr::TupleExpr(it) => &it.syntax,
855 Expr::ArrayExpr(it) => &it.syntax,
856 Expr::ParenExpr(it) => &it.syntax,
857 Expr::PathExpr(it) => &it.syntax,
858 Expr::LambdaExpr(it) => &it.syntax,
859 Expr::IfExpr(it) => &it.syntax,
860 Expr::LoopExpr(it) => &it.syntax,
861 Expr::ForExpr(it) => &it.syntax,
862 Expr::WhileExpr(it) => &it.syntax,
863 Expr::ContinueExpr(it) => &it.syntax,
864 Expr::BreakExpr(it) => &it.syntax,
865 Expr::Label(it) => &it.syntax,
866 Expr::BlockExpr(it) => &it.syntax,
867 Expr::ReturnExpr(it) => &it.syntax,
868 Expr::MatchExpr(it) => &it.syntax,
869 Expr::RecordLit(it) => &it.syntax,
870 Expr::CallExpr(it) => &it.syntax,
871 Expr::IndexExpr(it) => &it.syntax,
872 Expr::MethodCallExpr(it) => &it.syntax,
873 Expr::FieldExpr(it) => &it.syntax,
874 Expr::AwaitExpr(it) => &it.syntax,
875 Expr::TryExpr(it) => &it.syntax,
876 Expr::TryBlockExpr(it) => &it.syntax,
877 Expr::CastExpr(it) => &it.syntax,
878 Expr::RefExpr(it) => &it.syntax,
879 Expr::PrefixExpr(it) => &it.syntax,
880 Expr::RangeExpr(it) => &it.syntax,
881 Expr::BinExpr(it) => &it.syntax,
882 Expr::Literal(it) => &it.syntax,
883 Expr::MacroCall(it) => &it.syntax,
888 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
889 pub struct ExprStmt {
890 pub(crate) syntax: SyntaxNode,
892 impl AstNode for ExprStmt {
893 fn can_cast(kind: SyntaxKind) -> bool {
899 fn cast(syntax: SyntaxNode) -> Option<Self> {
900 if Self::can_cast(syntax.kind()) {
901 Some(Self { syntax })
906 fn syntax(&self) -> &SyntaxNode {
911 pub fn expr(&self) -> Option<Expr> {
912 AstChildren::new(&self.syntax).next()
915 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
916 pub struct ExternCrateItem {
917 pub(crate) syntax: SyntaxNode,
919 impl AstNode for ExternCrateItem {
920 fn can_cast(kind: SyntaxKind) -> bool {
922 EXTERN_CRATE_ITEM => true,
926 fn cast(syntax: SyntaxNode) -> Option<Self> {
927 if Self::can_cast(syntax.kind()) {
928 Some(Self { syntax })
933 fn syntax(&self) -> &SyntaxNode {
937 impl ast::AttrsOwner for ExternCrateItem {}
938 impl ExternCrateItem {
939 pub fn name_ref(&self) -> Option<NameRef> {
940 AstChildren::new(&self.syntax).next()
942 pub fn alias(&self) -> Option<Alias> {
943 AstChildren::new(&self.syntax).next()
946 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
947 pub struct FieldExpr {
948 pub(crate) syntax: SyntaxNode,
950 impl AstNode for FieldExpr {
951 fn can_cast(kind: SyntaxKind) -> bool {
957 fn cast(syntax: SyntaxNode) -> Option<Self> {
958 if Self::can_cast(syntax.kind()) {
959 Some(Self { syntax })
964 fn syntax(&self) -> &SyntaxNode {
969 pub fn expr(&self) -> Option<Expr> {
970 AstChildren::new(&self.syntax).next()
972 pub fn name_ref(&self) -> Option<NameRef> {
973 AstChildren::new(&self.syntax).next()
976 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
978 pub(crate) syntax: SyntaxNode,
980 impl AstNode for FnDef {
981 fn can_cast(kind: SyntaxKind) -> bool {
987 fn cast(syntax: SyntaxNode) -> Option<Self> {
988 if Self::can_cast(syntax.kind()) {
989 Some(Self { syntax })
994 fn syntax(&self) -> &SyntaxNode {
998 impl ast::VisibilityOwner for FnDef {}
999 impl ast::NameOwner for FnDef {}
1000 impl ast::TypeParamsOwner for FnDef {}
1001 impl ast::AttrsOwner for FnDef {}
1002 impl ast::DocCommentsOwner for FnDef {}
1004 pub fn param_list(&self) -> Option<ParamList> {
1005 AstChildren::new(&self.syntax).next()
1007 pub fn body(&self) -> Option<Block> {
1008 AstChildren::new(&self.syntax).next()
1010 pub fn ret_type(&self) -> Option<RetType> {
1011 AstChildren::new(&self.syntax).next()
1014 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1015 pub struct FnPointerType {
1016 pub(crate) syntax: SyntaxNode,
1018 impl AstNode for FnPointerType {
1019 fn can_cast(kind: SyntaxKind) -> bool {
1021 FN_POINTER_TYPE => true,
1025 fn cast(syntax: SyntaxNode) -> Option<Self> {
1026 if Self::can_cast(syntax.kind()) {
1027 Some(Self { syntax })
1032 fn syntax(&self) -> &SyntaxNode {
1036 impl FnPointerType {
1037 pub fn param_list(&self) -> Option<ParamList> {
1038 AstChildren::new(&self.syntax).next()
1040 pub fn ret_type(&self) -> Option<RetType> {
1041 AstChildren::new(&self.syntax).next()
1044 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1045 pub struct ForExpr {
1046 pub(crate) syntax: SyntaxNode,
1048 impl AstNode for ForExpr {
1049 fn can_cast(kind: SyntaxKind) -> bool {
1055 fn cast(syntax: SyntaxNode) -> Option<Self> {
1056 if Self::can_cast(syntax.kind()) {
1057 Some(Self { syntax })
1062 fn syntax(&self) -> &SyntaxNode {
1066 impl ast::LoopBodyOwner for ForExpr {}
1068 pub fn pat(&self) -> Option<Pat> {
1069 AstChildren::new(&self.syntax).next()
1071 pub fn iterable(&self) -> Option<Expr> {
1072 AstChildren::new(&self.syntax).next()
1075 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1076 pub struct ForType {
1077 pub(crate) syntax: SyntaxNode,
1079 impl AstNode for ForType {
1080 fn can_cast(kind: SyntaxKind) -> bool {
1086 fn cast(syntax: SyntaxNode) -> Option<Self> {
1087 if Self::can_cast(syntax.kind()) {
1088 Some(Self { syntax })
1093 fn syntax(&self) -> &SyntaxNode {
1098 pub fn type_ref(&self) -> Option<TypeRef> {
1099 AstChildren::new(&self.syntax).next()
1102 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1104 pub(crate) syntax: SyntaxNode,
1106 impl AstNode for IfExpr {
1107 fn can_cast(kind: SyntaxKind) -> bool {
1113 fn cast(syntax: SyntaxNode) -> Option<Self> {
1114 if Self::can_cast(syntax.kind()) {
1115 Some(Self { syntax })
1120 fn syntax(&self) -> &SyntaxNode {
1125 pub fn condition(&self) -> Option<Condition> {
1126 AstChildren::new(&self.syntax).next()
1129 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1130 pub struct ImplBlock {
1131 pub(crate) syntax: SyntaxNode,
1133 impl AstNode for ImplBlock {
1134 fn can_cast(kind: SyntaxKind) -> bool {
1140 fn cast(syntax: SyntaxNode) -> Option<Self> {
1141 if Self::can_cast(syntax.kind()) {
1142 Some(Self { syntax })
1147 fn syntax(&self) -> &SyntaxNode {
1151 impl ast::TypeParamsOwner for ImplBlock {}
1152 impl ast::AttrsOwner for ImplBlock {}
1154 pub fn item_list(&self) -> Option<ItemList> {
1155 AstChildren::new(&self.syntax).next()
1158 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1161 TypeAliasDef(TypeAliasDef),
1164 impl From<FnDef> for ImplItem {
1165 fn from(node: FnDef) -> ImplItem {
1166 ImplItem::FnDef(node)
1169 impl From<TypeAliasDef> for ImplItem {
1170 fn from(node: TypeAliasDef) -> ImplItem {
1171 ImplItem::TypeAliasDef(node)
1174 impl From<ConstDef> for ImplItem {
1175 fn from(node: ConstDef) -> ImplItem {
1176 ImplItem::ConstDef(node)
1179 impl AstNode for ImplItem {
1180 fn can_cast(kind: SyntaxKind) -> bool {
1182 FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true,
1186 fn cast(syntax: SyntaxNode) -> Option<Self> {
1187 let res = match syntax.kind() {
1188 FN_DEF => ImplItem::FnDef(FnDef { syntax }),
1189 TYPE_ALIAS_DEF => ImplItem::TypeAliasDef(TypeAliasDef { syntax }),
1190 CONST_DEF => ImplItem::ConstDef(ConstDef { syntax }),
1195 fn syntax(&self) -> &SyntaxNode {
1197 ImplItem::FnDef(it) => &it.syntax,
1198 ImplItem::TypeAliasDef(it) => &it.syntax,
1199 ImplItem::ConstDef(it) => &it.syntax,
1204 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1205 pub struct ImplTraitType {
1206 pub(crate) syntax: SyntaxNode,
1208 impl AstNode for ImplTraitType {
1209 fn can_cast(kind: SyntaxKind) -> bool {
1211 IMPL_TRAIT_TYPE => true,
1215 fn cast(syntax: SyntaxNode) -> Option<Self> {
1216 if Self::can_cast(syntax.kind()) {
1217 Some(Self { syntax })
1222 fn syntax(&self) -> &SyntaxNode {
1226 impl ast::TypeBoundsOwner for ImplTraitType {}
1227 impl ImplTraitType {}
1228 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1229 pub struct IndexExpr {
1230 pub(crate) syntax: SyntaxNode,
1232 impl AstNode for IndexExpr {
1233 fn can_cast(kind: SyntaxKind) -> bool {
1239 fn cast(syntax: SyntaxNode) -> Option<Self> {
1240 if Self::can_cast(syntax.kind()) {
1241 Some(Self { syntax })
1246 fn syntax(&self) -> &SyntaxNode {
1251 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1252 pub struct ItemList {
1253 pub(crate) syntax: SyntaxNode,
1255 impl AstNode for ItemList {
1256 fn can_cast(kind: SyntaxKind) -> bool {
1262 fn cast(syntax: SyntaxNode) -> Option<Self> {
1263 if Self::can_cast(syntax.kind()) {
1264 Some(Self { syntax })
1269 fn syntax(&self) -> &SyntaxNode {
1273 impl ast::FnDefOwner for ItemList {}
1274 impl ast::ModuleItemOwner for ItemList {}
1276 pub fn impl_items(&self) -> AstChildren<ImplItem> {
1277 AstChildren::new(&self.syntax)
1280 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1282 pub(crate) syntax: SyntaxNode,
1284 impl AstNode for Label {
1285 fn can_cast(kind: SyntaxKind) -> bool {
1291 fn cast(syntax: SyntaxNode) -> Option<Self> {
1292 if Self::can_cast(syntax.kind()) {
1293 Some(Self { syntax })
1298 fn syntax(&self) -> &SyntaxNode {
1303 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1304 pub struct LambdaExpr {
1305 pub(crate) syntax: SyntaxNode,
1307 impl AstNode for LambdaExpr {
1308 fn can_cast(kind: SyntaxKind) -> bool {
1310 LAMBDA_EXPR => true,
1314 fn cast(syntax: SyntaxNode) -> Option<Self> {
1315 if Self::can_cast(syntax.kind()) {
1316 Some(Self { syntax })
1321 fn syntax(&self) -> &SyntaxNode {
1326 pub fn param_list(&self) -> Option<ParamList> {
1327 AstChildren::new(&self.syntax).next()
1329 pub fn body(&self) -> Option<Expr> {
1330 AstChildren::new(&self.syntax).next()
1333 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1334 pub struct LetStmt {
1335 pub(crate) syntax: SyntaxNode,
1337 impl AstNode for LetStmt {
1338 fn can_cast(kind: SyntaxKind) -> bool {
1344 fn cast(syntax: SyntaxNode) -> Option<Self> {
1345 if Self::can_cast(syntax.kind()) {
1346 Some(Self { syntax })
1351 fn syntax(&self) -> &SyntaxNode {
1355 impl ast::TypeAscriptionOwner for LetStmt {}
1357 pub fn pat(&self) -> Option<Pat> {
1358 AstChildren::new(&self.syntax).next()
1360 pub fn initializer(&self) -> Option<Expr> {
1361 AstChildren::new(&self.syntax).next()
1364 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1365 pub struct LifetimeArg {
1366 pub(crate) syntax: SyntaxNode,
1368 impl AstNode for LifetimeArg {
1369 fn can_cast(kind: SyntaxKind) -> bool {
1371 LIFETIME_ARG => true,
1375 fn cast(syntax: SyntaxNode) -> Option<Self> {
1376 if Self::can_cast(syntax.kind()) {
1377 Some(Self { syntax })
1382 fn syntax(&self) -> &SyntaxNode {
1387 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1388 pub struct LifetimeParam {
1389 pub(crate) syntax: SyntaxNode,
1391 impl AstNode for LifetimeParam {
1392 fn can_cast(kind: SyntaxKind) -> bool {
1394 LIFETIME_PARAM => true,
1398 fn cast(syntax: SyntaxNode) -> Option<Self> {
1399 if Self::can_cast(syntax.kind()) {
1400 Some(Self { syntax })
1405 fn syntax(&self) -> &SyntaxNode {
1409 impl ast::AttrsOwner for LifetimeParam {}
1410 impl LifetimeParam {}
1411 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1412 pub struct Literal {
1413 pub(crate) syntax: SyntaxNode,
1415 impl AstNode for Literal {
1416 fn can_cast(kind: SyntaxKind) -> bool {
1422 fn cast(syntax: SyntaxNode) -> Option<Self> {
1423 if Self::can_cast(syntax.kind()) {
1424 Some(Self { syntax })
1429 fn syntax(&self) -> &SyntaxNode {
1434 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1435 pub struct LiteralPat {
1436 pub(crate) syntax: SyntaxNode,
1438 impl AstNode for LiteralPat {
1439 fn can_cast(kind: SyntaxKind) -> bool {
1441 LITERAL_PAT => true,
1445 fn cast(syntax: SyntaxNode) -> Option<Self> {
1446 if Self::can_cast(syntax.kind()) {
1447 Some(Self { syntax })
1452 fn syntax(&self) -> &SyntaxNode {
1457 pub fn literal(&self) -> Option<Literal> {
1458 AstChildren::new(&self.syntax).next()
1461 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1462 pub struct LoopExpr {
1463 pub(crate) syntax: SyntaxNode,
1465 impl AstNode for LoopExpr {
1466 fn can_cast(kind: SyntaxKind) -> bool {
1472 fn cast(syntax: SyntaxNode) -> Option<Self> {
1473 if Self::can_cast(syntax.kind()) {
1474 Some(Self { syntax })
1479 fn syntax(&self) -> &SyntaxNode {
1483 impl ast::LoopBodyOwner for LoopExpr {}
1485 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1486 pub struct MacroCall {
1487 pub(crate) syntax: SyntaxNode,
1489 impl AstNode for MacroCall {
1490 fn can_cast(kind: SyntaxKind) -> bool {
1496 fn cast(syntax: SyntaxNode) -> Option<Self> {
1497 if Self::can_cast(syntax.kind()) {
1498 Some(Self { syntax })
1503 fn syntax(&self) -> &SyntaxNode {
1507 impl ast::NameOwner for MacroCall {}
1508 impl ast::AttrsOwner for MacroCall {}
1509 impl ast::DocCommentsOwner for MacroCall {}
1511 pub fn token_tree(&self) -> Option<TokenTree> {
1512 AstChildren::new(&self.syntax).next()
1514 pub fn path(&self) -> Option<Path> {
1515 AstChildren::new(&self.syntax).next()
1518 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1519 pub struct MacroItems {
1520 pub(crate) syntax: SyntaxNode,
1522 impl AstNode for MacroItems {
1523 fn can_cast(kind: SyntaxKind) -> bool {
1525 MACRO_ITEMS => true,
1529 fn cast(syntax: SyntaxNode) -> Option<Self> {
1530 if Self::can_cast(syntax.kind()) {
1531 Some(Self { syntax })
1536 fn syntax(&self) -> &SyntaxNode {
1540 impl ast::ModuleItemOwner for MacroItems {}
1541 impl ast::FnDefOwner for MacroItems {}
1543 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1544 pub struct MacroStmts {
1545 pub(crate) syntax: SyntaxNode,
1547 impl AstNode for MacroStmts {
1548 fn can_cast(kind: SyntaxKind) -> bool {
1550 MACRO_STMTS => true,
1554 fn cast(syntax: SyntaxNode) -> Option<Self> {
1555 if Self::can_cast(syntax.kind()) {
1556 Some(Self { syntax })
1561 fn syntax(&self) -> &SyntaxNode {
1566 pub fn statements(&self) -> AstChildren<Stmt> {
1567 AstChildren::new(&self.syntax)
1569 pub fn expr(&self) -> Option<Expr> {
1570 AstChildren::new(&self.syntax).next()
1573 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1574 pub struct MatchArm {
1575 pub(crate) syntax: SyntaxNode,
1577 impl AstNode for MatchArm {
1578 fn can_cast(kind: SyntaxKind) -> bool {
1584 fn cast(syntax: SyntaxNode) -> Option<Self> {
1585 if Self::can_cast(syntax.kind()) {
1586 Some(Self { syntax })
1591 fn syntax(&self) -> &SyntaxNode {
1595 impl ast::AttrsOwner for MatchArm {}
1597 pub fn pats(&self) -> AstChildren<Pat> {
1598 AstChildren::new(&self.syntax)
1600 pub fn guard(&self) -> Option<MatchGuard> {
1601 AstChildren::new(&self.syntax).next()
1603 pub fn expr(&self) -> Option<Expr> {
1604 AstChildren::new(&self.syntax).next()
1607 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1608 pub struct MatchArmList {
1609 pub(crate) syntax: SyntaxNode,
1611 impl AstNode for MatchArmList {
1612 fn can_cast(kind: SyntaxKind) -> bool {
1614 MATCH_ARM_LIST => true,
1618 fn cast(syntax: SyntaxNode) -> Option<Self> {
1619 if Self::can_cast(syntax.kind()) {
1620 Some(Self { syntax })
1625 fn syntax(&self) -> &SyntaxNode {
1629 impl ast::AttrsOwner for MatchArmList {}
1631 pub fn arms(&self) -> AstChildren<MatchArm> {
1632 AstChildren::new(&self.syntax)
1635 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1636 pub struct MatchExpr {
1637 pub(crate) syntax: SyntaxNode,
1639 impl AstNode for MatchExpr {
1640 fn can_cast(kind: SyntaxKind) -> bool {
1646 fn cast(syntax: SyntaxNode) -> Option<Self> {
1647 if Self::can_cast(syntax.kind()) {
1648 Some(Self { syntax })
1653 fn syntax(&self) -> &SyntaxNode {
1658 pub fn expr(&self) -> Option<Expr> {
1659 AstChildren::new(&self.syntax).next()
1661 pub fn match_arm_list(&self) -> Option<MatchArmList> {
1662 AstChildren::new(&self.syntax).next()
1665 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1666 pub struct MatchGuard {
1667 pub(crate) syntax: SyntaxNode,
1669 impl AstNode for MatchGuard {
1670 fn can_cast(kind: SyntaxKind) -> bool {
1672 MATCH_GUARD => true,
1676 fn cast(syntax: SyntaxNode) -> Option<Self> {
1677 if Self::can_cast(syntax.kind()) {
1678 Some(Self { syntax })
1683 fn syntax(&self) -> &SyntaxNode {
1688 pub fn expr(&self) -> Option<Expr> {
1689 AstChildren::new(&self.syntax).next()
1692 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1693 pub struct MethodCallExpr {
1694 pub(crate) syntax: SyntaxNode,
1696 impl AstNode for MethodCallExpr {
1697 fn can_cast(kind: SyntaxKind) -> bool {
1699 METHOD_CALL_EXPR => true,
1703 fn cast(syntax: SyntaxNode) -> Option<Self> {
1704 if Self::can_cast(syntax.kind()) {
1705 Some(Self { syntax })
1710 fn syntax(&self) -> &SyntaxNode {
1714 impl ast::ArgListOwner for MethodCallExpr {}
1715 impl MethodCallExpr {
1716 pub fn expr(&self) -> Option<Expr> {
1717 AstChildren::new(&self.syntax).next()
1719 pub fn name_ref(&self) -> Option<NameRef> {
1720 AstChildren::new(&self.syntax).next()
1722 pub fn type_arg_list(&self) -> Option<TypeArgList> {
1723 AstChildren::new(&self.syntax).next()
1726 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1728 pub(crate) syntax: SyntaxNode,
1730 impl AstNode for Module {
1731 fn can_cast(kind: SyntaxKind) -> bool {
1737 fn cast(syntax: SyntaxNode) -> Option<Self> {
1738 if Self::can_cast(syntax.kind()) {
1739 Some(Self { syntax })
1744 fn syntax(&self) -> &SyntaxNode {
1748 impl ast::VisibilityOwner for Module {}
1749 impl ast::NameOwner for Module {}
1750 impl ast::AttrsOwner for Module {}
1751 impl ast::DocCommentsOwner for Module {}
1753 pub fn item_list(&self) -> Option<ItemList> {
1754 AstChildren::new(&self.syntax).next()
1757 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1758 pub enum ModuleItem {
1759 StructDef(StructDef),
1763 TypeAliasDef(TypeAliasDef),
1764 ImplBlock(ImplBlock),
1766 ExternCrateItem(ExternCrateItem),
1768 StaticDef(StaticDef),
1771 impl From<StructDef> for ModuleItem {
1772 fn from(node: StructDef) -> ModuleItem {
1773 ModuleItem::StructDef(node)
1776 impl From<EnumDef> for ModuleItem {
1777 fn from(node: EnumDef) -> ModuleItem {
1778 ModuleItem::EnumDef(node)
1781 impl From<FnDef> for ModuleItem {
1782 fn from(node: FnDef) -> ModuleItem {
1783 ModuleItem::FnDef(node)
1786 impl From<TraitDef> for ModuleItem {
1787 fn from(node: TraitDef) -> ModuleItem {
1788 ModuleItem::TraitDef(node)
1791 impl From<TypeAliasDef> for ModuleItem {
1792 fn from(node: TypeAliasDef) -> ModuleItem {
1793 ModuleItem::TypeAliasDef(node)
1796 impl From<ImplBlock> for ModuleItem {
1797 fn from(node: ImplBlock) -> ModuleItem {
1798 ModuleItem::ImplBlock(node)
1801 impl From<UseItem> for ModuleItem {
1802 fn from(node: UseItem) -> ModuleItem {
1803 ModuleItem::UseItem(node)
1806 impl From<ExternCrateItem> for ModuleItem {
1807 fn from(node: ExternCrateItem) -> ModuleItem {
1808 ModuleItem::ExternCrateItem(node)
1811 impl From<ConstDef> for ModuleItem {
1812 fn from(node: ConstDef) -> ModuleItem {
1813 ModuleItem::ConstDef(node)
1816 impl From<StaticDef> for ModuleItem {
1817 fn from(node: StaticDef) -> ModuleItem {
1818 ModuleItem::StaticDef(node)
1821 impl From<Module> for ModuleItem {
1822 fn from(node: Module) -> ModuleItem {
1823 ModuleItem::Module(node)
1826 impl AstNode for ModuleItem {
1827 fn can_cast(kind: SyntaxKind) -> bool {
1829 STRUCT_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_BLOCK | USE_ITEM
1830 | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true,
1834 fn cast(syntax: SyntaxNode) -> Option<Self> {
1835 let res = match syntax.kind() {
1836 STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }),
1837 ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }),
1838 FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
1839 TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
1840 TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
1841 IMPL_BLOCK => ModuleItem::ImplBlock(ImplBlock { syntax }),
1842 USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
1843 EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
1844 CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
1845 STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }),
1846 MODULE => ModuleItem::Module(Module { syntax }),
1851 fn syntax(&self) -> &SyntaxNode {
1853 ModuleItem::StructDef(it) => &it.syntax,
1854 ModuleItem::EnumDef(it) => &it.syntax,
1855 ModuleItem::FnDef(it) => &it.syntax,
1856 ModuleItem::TraitDef(it) => &it.syntax,
1857 ModuleItem::TypeAliasDef(it) => &it.syntax,
1858 ModuleItem::ImplBlock(it) => &it.syntax,
1859 ModuleItem::UseItem(it) => &it.syntax,
1860 ModuleItem::ExternCrateItem(it) => &it.syntax,
1861 ModuleItem::ConstDef(it) => &it.syntax,
1862 ModuleItem::StaticDef(it) => &it.syntax,
1863 ModuleItem::Module(it) => &it.syntax,
1868 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1870 pub(crate) syntax: SyntaxNode,
1872 impl AstNode for Name {
1873 fn can_cast(kind: SyntaxKind) -> bool {
1879 fn cast(syntax: SyntaxNode) -> Option<Self> {
1880 if Self::can_cast(syntax.kind()) {
1881 Some(Self { syntax })
1886 fn syntax(&self) -> &SyntaxNode {
1891 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1892 pub struct NameRef {
1893 pub(crate) syntax: SyntaxNode,
1895 impl AstNode for NameRef {
1896 fn can_cast(kind: SyntaxKind) -> bool {
1902 fn cast(syntax: SyntaxNode) -> Option<Self> {
1903 if Self::can_cast(syntax.kind()) {
1904 Some(Self { syntax })
1909 fn syntax(&self) -> &SyntaxNode {
1914 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1915 pub struct NeverType {
1916 pub(crate) syntax: SyntaxNode,
1918 impl AstNode for NeverType {
1919 fn can_cast(kind: SyntaxKind) -> bool {
1925 fn cast(syntax: SyntaxNode) -> Option<Self> {
1926 if Self::can_cast(syntax.kind()) {
1927 Some(Self { syntax })
1932 fn syntax(&self) -> &SyntaxNode {
1937 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1938 pub enum NominalDef {
1939 StructDef(StructDef),
1942 impl From<StructDef> for NominalDef {
1943 fn from(node: StructDef) -> NominalDef {
1944 NominalDef::StructDef(node)
1947 impl From<EnumDef> for NominalDef {
1948 fn from(node: EnumDef) -> NominalDef {
1949 NominalDef::EnumDef(node)
1952 impl AstNode for NominalDef {
1953 fn can_cast(kind: SyntaxKind) -> bool {
1955 STRUCT_DEF | ENUM_DEF => true,
1959 fn cast(syntax: SyntaxNode) -> Option<Self> {
1960 let res = match syntax.kind() {
1961 STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }),
1962 ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }),
1967 fn syntax(&self) -> &SyntaxNode {
1969 NominalDef::StructDef(it) => &it.syntax,
1970 NominalDef::EnumDef(it) => &it.syntax,
1974 impl ast::NameOwner for NominalDef {}
1975 impl ast::TypeParamsOwner for NominalDef {}
1976 impl ast::AttrsOwner for NominalDef {}
1978 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1980 pub(crate) syntax: SyntaxNode,
1982 impl AstNode for Param {
1983 fn can_cast(kind: SyntaxKind) -> bool {
1989 fn cast(syntax: SyntaxNode) -> Option<Self> {
1990 if Self::can_cast(syntax.kind()) {
1991 Some(Self { syntax })
1996 fn syntax(&self) -> &SyntaxNode {
2000 impl ast::TypeAscriptionOwner for Param {}
2001 impl ast::AttrsOwner for Param {}
2003 pub fn pat(&self) -> Option<Pat> {
2004 AstChildren::new(&self.syntax).next()
2007 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2008 pub struct ParamList {
2009 pub(crate) syntax: SyntaxNode,
2011 impl AstNode for ParamList {
2012 fn can_cast(kind: SyntaxKind) -> bool {
2018 fn cast(syntax: SyntaxNode) -> Option<Self> {
2019 if Self::can_cast(syntax.kind()) {
2020 Some(Self { syntax })
2025 fn syntax(&self) -> &SyntaxNode {
2030 pub fn params(&self) -> AstChildren<Param> {
2031 AstChildren::new(&self.syntax)
2033 pub fn self_param(&self) -> Option<SelfParam> {
2034 AstChildren::new(&self.syntax).next()
2037 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2038 pub struct ParenExpr {
2039 pub(crate) syntax: SyntaxNode,
2041 impl AstNode for ParenExpr {
2042 fn can_cast(kind: SyntaxKind) -> bool {
2048 fn cast(syntax: SyntaxNode) -> Option<Self> {
2049 if Self::can_cast(syntax.kind()) {
2050 Some(Self { syntax })
2055 fn syntax(&self) -> &SyntaxNode {
2060 pub fn expr(&self) -> Option<Expr> {
2061 AstChildren::new(&self.syntax).next()
2064 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2065 pub struct ParenType {
2066 pub(crate) syntax: SyntaxNode,
2068 impl AstNode for ParenType {
2069 fn can_cast(kind: SyntaxKind) -> bool {
2075 fn cast(syntax: SyntaxNode) -> Option<Self> {
2076 if Self::can_cast(syntax.kind()) {
2077 Some(Self { syntax })
2082 fn syntax(&self) -> &SyntaxNode {
2087 pub fn type_ref(&self) -> Option<TypeRef> {
2088 AstChildren::new(&self.syntax).next()
2091 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2096 PlaceholderPat(PlaceholderPat),
2098 RecordPat(RecordPat),
2099 TupleStructPat(TupleStructPat),
2103 LiteralPat(LiteralPat),
2105 impl From<RefPat> for Pat {
2106 fn from(node: RefPat) -> Pat {
2110 impl From<BoxPat> for Pat {
2111 fn from(node: BoxPat) -> Pat {
2115 impl From<BindPat> for Pat {
2116 fn from(node: BindPat) -> Pat {
2120 impl From<PlaceholderPat> for Pat {
2121 fn from(node: PlaceholderPat) -> Pat {
2122 Pat::PlaceholderPat(node)
2125 impl From<PathPat> for Pat {
2126 fn from(node: PathPat) -> Pat {
2130 impl From<RecordPat> for Pat {
2131 fn from(node: RecordPat) -> Pat {
2132 Pat::RecordPat(node)
2135 impl From<TupleStructPat> for Pat {
2136 fn from(node: TupleStructPat) -> Pat {
2137 Pat::TupleStructPat(node)
2140 impl From<TuplePat> for Pat {
2141 fn from(node: TuplePat) -> Pat {
2145 impl From<SlicePat> for Pat {
2146 fn from(node: SlicePat) -> Pat {
2150 impl From<RangePat> for Pat {
2151 fn from(node: RangePat) -> Pat {
2155 impl From<LiteralPat> for Pat {
2156 fn from(node: LiteralPat) -> Pat {
2157 Pat::LiteralPat(node)
2160 impl AstNode for Pat {
2161 fn can_cast(kind: SyntaxKind) -> bool {
2163 REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | RECORD_PAT
2164 | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true,
2168 fn cast(syntax: SyntaxNode) -> Option<Self> {
2169 let res = match syntax.kind() {
2170 REF_PAT => Pat::RefPat(RefPat { syntax }),
2171 BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
2172 BIND_PAT => Pat::BindPat(BindPat { syntax }),
2173 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
2174 PATH_PAT => Pat::PathPat(PathPat { syntax }),
2175 RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
2176 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
2177 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
2178 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
2179 RANGE_PAT => Pat::RangePat(RangePat { syntax }),
2180 LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
2185 fn syntax(&self) -> &SyntaxNode {
2187 Pat::RefPat(it) => &it.syntax,
2188 Pat::BoxPat(it) => &it.syntax,
2189 Pat::BindPat(it) => &it.syntax,
2190 Pat::PlaceholderPat(it) => &it.syntax,
2191 Pat::PathPat(it) => &it.syntax,
2192 Pat::RecordPat(it) => &it.syntax,
2193 Pat::TupleStructPat(it) => &it.syntax,
2194 Pat::TuplePat(it) => &it.syntax,
2195 Pat::SlicePat(it) => &it.syntax,
2196 Pat::RangePat(it) => &it.syntax,
2197 Pat::LiteralPat(it) => &it.syntax,
2202 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2204 pub(crate) syntax: SyntaxNode,
2206 impl AstNode for Path {
2207 fn can_cast(kind: SyntaxKind) -> bool {
2213 fn cast(syntax: SyntaxNode) -> Option<Self> {
2214 if Self::can_cast(syntax.kind()) {
2215 Some(Self { syntax })
2220 fn syntax(&self) -> &SyntaxNode {
2225 pub fn segment(&self) -> Option<PathSegment> {
2226 AstChildren::new(&self.syntax).next()
2228 pub fn qualifier(&self) -> Option<Path> {
2229 AstChildren::new(&self.syntax).next()
2232 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2233 pub struct PathExpr {
2234 pub(crate) syntax: SyntaxNode,
2236 impl AstNode for PathExpr {
2237 fn can_cast(kind: SyntaxKind) -> bool {
2243 fn cast(syntax: SyntaxNode) -> Option<Self> {
2244 if Self::can_cast(syntax.kind()) {
2245 Some(Self { syntax })
2250 fn syntax(&self) -> &SyntaxNode {
2255 pub fn path(&self) -> Option<Path> {
2256 AstChildren::new(&self.syntax).next()
2259 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2260 pub struct PathPat {
2261 pub(crate) syntax: SyntaxNode,
2263 impl AstNode for PathPat {
2264 fn can_cast(kind: SyntaxKind) -> bool {
2270 fn cast(syntax: SyntaxNode) -> Option<Self> {
2271 if Self::can_cast(syntax.kind()) {
2272 Some(Self { syntax })
2277 fn syntax(&self) -> &SyntaxNode {
2282 pub fn path(&self) -> Option<Path> {
2283 AstChildren::new(&self.syntax).next()
2286 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2287 pub struct PathSegment {
2288 pub(crate) syntax: SyntaxNode,
2290 impl AstNode for PathSegment {
2291 fn can_cast(kind: SyntaxKind) -> bool {
2293 PATH_SEGMENT => true,
2297 fn cast(syntax: SyntaxNode) -> Option<Self> {
2298 if Self::can_cast(syntax.kind()) {
2299 Some(Self { syntax })
2304 fn syntax(&self) -> &SyntaxNode {
2309 pub fn name_ref(&self) -> Option<NameRef> {
2310 AstChildren::new(&self.syntax).next()
2312 pub fn type_arg_list(&self) -> Option<TypeArgList> {
2313 AstChildren::new(&self.syntax).next()
2316 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2317 pub struct PathType {
2318 pub(crate) syntax: SyntaxNode,
2320 impl AstNode for PathType {
2321 fn can_cast(kind: SyntaxKind) -> bool {
2327 fn cast(syntax: SyntaxNode) -> Option<Self> {
2328 if Self::can_cast(syntax.kind()) {
2329 Some(Self { syntax })
2334 fn syntax(&self) -> &SyntaxNode {
2339 pub fn path(&self) -> Option<Path> {
2340 AstChildren::new(&self.syntax).next()
2343 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2344 pub struct PlaceholderPat {
2345 pub(crate) syntax: SyntaxNode,
2347 impl AstNode for PlaceholderPat {
2348 fn can_cast(kind: SyntaxKind) -> bool {
2350 PLACEHOLDER_PAT => true,
2354 fn cast(syntax: SyntaxNode) -> Option<Self> {
2355 if Self::can_cast(syntax.kind()) {
2356 Some(Self { syntax })
2361 fn syntax(&self) -> &SyntaxNode {
2365 impl PlaceholderPat {}
2366 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2367 pub struct PlaceholderType {
2368 pub(crate) syntax: SyntaxNode,
2370 impl AstNode for PlaceholderType {
2371 fn can_cast(kind: SyntaxKind) -> bool {
2373 PLACEHOLDER_TYPE => true,
2377 fn cast(syntax: SyntaxNode) -> Option<Self> {
2378 if Self::can_cast(syntax.kind()) {
2379 Some(Self { syntax })
2384 fn syntax(&self) -> &SyntaxNode {
2388 impl PlaceholderType {}
2389 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2390 pub struct PointerType {
2391 pub(crate) syntax: SyntaxNode,
2393 impl AstNode for PointerType {
2394 fn can_cast(kind: SyntaxKind) -> bool {
2396 POINTER_TYPE => true,
2400 fn cast(syntax: SyntaxNode) -> Option<Self> {
2401 if Self::can_cast(syntax.kind()) {
2402 Some(Self { syntax })
2407 fn syntax(&self) -> &SyntaxNode {
2412 pub fn type_ref(&self) -> Option<TypeRef> {
2413 AstChildren::new(&self.syntax).next()
2416 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2417 pub struct PrefixExpr {
2418 pub(crate) syntax: SyntaxNode,
2420 impl AstNode for PrefixExpr {
2421 fn can_cast(kind: SyntaxKind) -> bool {
2423 PREFIX_EXPR => true,
2427 fn cast(syntax: SyntaxNode) -> Option<Self> {
2428 if Self::can_cast(syntax.kind()) {
2429 Some(Self { syntax })
2434 fn syntax(&self) -> &SyntaxNode {
2439 pub fn expr(&self) -> Option<Expr> {
2440 AstChildren::new(&self.syntax).next()
2443 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2444 pub struct RangeExpr {
2445 pub(crate) syntax: SyntaxNode,
2447 impl AstNode for RangeExpr {
2448 fn can_cast(kind: SyntaxKind) -> bool {
2454 fn cast(syntax: SyntaxNode) -> Option<Self> {
2455 if Self::can_cast(syntax.kind()) {
2456 Some(Self { syntax })
2461 fn syntax(&self) -> &SyntaxNode {
2466 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2467 pub struct RangePat {
2468 pub(crate) syntax: SyntaxNode,
2470 impl AstNode for RangePat {
2471 fn can_cast(kind: SyntaxKind) -> bool {
2477 fn cast(syntax: SyntaxNode) -> Option<Self> {
2478 if Self::can_cast(syntax.kind()) {
2479 Some(Self { syntax })
2484 fn syntax(&self) -> &SyntaxNode {
2489 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2490 pub struct RecordField {
2491 pub(crate) syntax: SyntaxNode,
2493 impl AstNode for RecordField {
2494 fn can_cast(kind: SyntaxKind) -> bool {
2496 RECORD_FIELD => true,
2500 fn cast(syntax: SyntaxNode) -> Option<Self> {
2501 if Self::can_cast(syntax.kind()) {
2502 Some(Self { syntax })
2507 fn syntax(&self) -> &SyntaxNode {
2512 pub fn name_ref(&self) -> Option<NameRef> {
2513 AstChildren::new(&self.syntax).next()
2515 pub fn expr(&self) -> Option<Expr> {
2516 AstChildren::new(&self.syntax).next()
2519 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2520 pub struct RecordFieldDef {
2521 pub(crate) syntax: SyntaxNode,
2523 impl AstNode for RecordFieldDef {
2524 fn can_cast(kind: SyntaxKind) -> bool {
2526 RECORD_FIELD_DEF => true,
2530 fn cast(syntax: SyntaxNode) -> Option<Self> {
2531 if Self::can_cast(syntax.kind()) {
2532 Some(Self { syntax })
2537 fn syntax(&self) -> &SyntaxNode {
2541 impl ast::VisibilityOwner for RecordFieldDef {}
2542 impl ast::NameOwner for RecordFieldDef {}
2543 impl ast::AttrsOwner for RecordFieldDef {}
2544 impl ast::DocCommentsOwner for RecordFieldDef {}
2545 impl ast::TypeAscriptionOwner for RecordFieldDef {}
2546 impl RecordFieldDef {}
2547 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2548 pub struct RecordFieldDefList {
2549 pub(crate) syntax: SyntaxNode,
2551 impl AstNode for RecordFieldDefList {
2552 fn can_cast(kind: SyntaxKind) -> bool {
2554 RECORD_FIELD_DEF_LIST => true,
2558 fn cast(syntax: SyntaxNode) -> Option<Self> {
2559 if Self::can_cast(syntax.kind()) {
2560 Some(Self { syntax })
2565 fn syntax(&self) -> &SyntaxNode {
2569 impl RecordFieldDefList {
2570 pub fn fields(&self) -> AstChildren<RecordFieldDef> {
2571 AstChildren::new(&self.syntax)
2574 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2575 pub struct RecordFieldList {
2576 pub(crate) syntax: SyntaxNode,
2578 impl AstNode for RecordFieldList {
2579 fn can_cast(kind: SyntaxKind) -> bool {
2581 RECORD_FIELD_LIST => true,
2585 fn cast(syntax: SyntaxNode) -> Option<Self> {
2586 if Self::can_cast(syntax.kind()) {
2587 Some(Self { syntax })
2592 fn syntax(&self) -> &SyntaxNode {
2596 impl RecordFieldList {
2597 pub fn fields(&self) -> AstChildren<RecordField> {
2598 AstChildren::new(&self.syntax)
2600 pub fn spread(&self) -> Option<Expr> {
2601 AstChildren::new(&self.syntax).next()
2604 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2605 pub struct RecordFieldPat {
2606 pub(crate) syntax: SyntaxNode,
2608 impl AstNode for RecordFieldPat {
2609 fn can_cast(kind: SyntaxKind) -> bool {
2611 RECORD_FIELD_PAT => true,
2615 fn cast(syntax: SyntaxNode) -> Option<Self> {
2616 if Self::can_cast(syntax.kind()) {
2617 Some(Self { syntax })
2622 fn syntax(&self) -> &SyntaxNode {
2626 impl ast::NameOwner for RecordFieldPat {}
2627 impl RecordFieldPat {
2628 pub fn pat(&self) -> Option<Pat> {
2629 AstChildren::new(&self.syntax).next()
2632 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2633 pub struct RecordFieldPatList {
2634 pub(crate) syntax: SyntaxNode,
2636 impl AstNode for RecordFieldPatList {
2637 fn can_cast(kind: SyntaxKind) -> bool {
2639 RECORD_FIELD_PAT_LIST => true,
2643 fn cast(syntax: SyntaxNode) -> Option<Self> {
2644 if Self::can_cast(syntax.kind()) {
2645 Some(Self { syntax })
2650 fn syntax(&self) -> &SyntaxNode {
2654 impl RecordFieldPatList {
2655 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
2656 AstChildren::new(&self.syntax)
2658 pub fn bind_pats(&self) -> AstChildren<BindPat> {
2659 AstChildren::new(&self.syntax)
2662 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2663 pub struct RecordLit {
2664 pub(crate) syntax: SyntaxNode,
2666 impl AstNode for RecordLit {
2667 fn can_cast(kind: SyntaxKind) -> bool {
2673 fn cast(syntax: SyntaxNode) -> Option<Self> {
2674 if Self::can_cast(syntax.kind()) {
2675 Some(Self { syntax })
2680 fn syntax(&self) -> &SyntaxNode {
2685 pub fn path(&self) -> Option<Path> {
2686 AstChildren::new(&self.syntax).next()
2688 pub fn record_field_list(&self) -> Option<RecordFieldList> {
2689 AstChildren::new(&self.syntax).next()
2692 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2693 pub struct RecordPat {
2694 pub(crate) syntax: SyntaxNode,
2696 impl AstNode for RecordPat {
2697 fn can_cast(kind: SyntaxKind) -> bool {
2703 fn cast(syntax: SyntaxNode) -> Option<Self> {
2704 if Self::can_cast(syntax.kind()) {
2705 Some(Self { syntax })
2710 fn syntax(&self) -> &SyntaxNode {
2715 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
2716 AstChildren::new(&self.syntax).next()
2718 pub fn path(&self) -> Option<Path> {
2719 AstChildren::new(&self.syntax).next()
2722 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2723 pub struct RefExpr {
2724 pub(crate) syntax: SyntaxNode,
2726 impl AstNode for RefExpr {
2727 fn can_cast(kind: SyntaxKind) -> bool {
2733 fn cast(syntax: SyntaxNode) -> Option<Self> {
2734 if Self::can_cast(syntax.kind()) {
2735 Some(Self { syntax })
2740 fn syntax(&self) -> &SyntaxNode {
2745 pub fn expr(&self) -> Option<Expr> {
2746 AstChildren::new(&self.syntax).next()
2749 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2751 pub(crate) syntax: SyntaxNode,
2753 impl AstNode for RefPat {
2754 fn can_cast(kind: SyntaxKind) -> bool {
2760 fn cast(syntax: SyntaxNode) -> Option<Self> {
2761 if Self::can_cast(syntax.kind()) {
2762 Some(Self { syntax })
2767 fn syntax(&self) -> &SyntaxNode {
2772 pub fn pat(&self) -> Option<Pat> {
2773 AstChildren::new(&self.syntax).next()
2776 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2777 pub struct ReferenceType {
2778 pub(crate) syntax: SyntaxNode,
2780 impl AstNode for ReferenceType {
2781 fn can_cast(kind: SyntaxKind) -> bool {
2783 REFERENCE_TYPE => true,
2787 fn cast(syntax: SyntaxNode) -> Option<Self> {
2788 if Self::can_cast(syntax.kind()) {
2789 Some(Self { syntax })
2794 fn syntax(&self) -> &SyntaxNode {
2798 impl ReferenceType {
2799 pub fn type_ref(&self) -> Option<TypeRef> {
2800 AstChildren::new(&self.syntax).next()
2803 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2804 pub struct RetType {
2805 pub(crate) syntax: SyntaxNode,
2807 impl AstNode for RetType {
2808 fn can_cast(kind: SyntaxKind) -> bool {
2814 fn cast(syntax: SyntaxNode) -> Option<Self> {
2815 if Self::can_cast(syntax.kind()) {
2816 Some(Self { syntax })
2821 fn syntax(&self) -> &SyntaxNode {
2826 pub fn type_ref(&self) -> Option<TypeRef> {
2827 AstChildren::new(&self.syntax).next()
2830 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2831 pub struct ReturnExpr {
2832 pub(crate) syntax: SyntaxNode,
2834 impl AstNode for ReturnExpr {
2835 fn can_cast(kind: SyntaxKind) -> bool {
2837 RETURN_EXPR => true,
2841 fn cast(syntax: SyntaxNode) -> Option<Self> {
2842 if Self::can_cast(syntax.kind()) {
2843 Some(Self { syntax })
2848 fn syntax(&self) -> &SyntaxNode {
2853 pub fn expr(&self) -> Option<Expr> {
2854 AstChildren::new(&self.syntax).next()
2857 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2858 pub struct SelfParam {
2859 pub(crate) syntax: SyntaxNode,
2861 impl AstNode for SelfParam {
2862 fn can_cast(kind: SyntaxKind) -> bool {
2868 fn cast(syntax: SyntaxNode) -> Option<Self> {
2869 if Self::can_cast(syntax.kind()) {
2870 Some(Self { syntax })
2875 fn syntax(&self) -> &SyntaxNode {
2879 impl ast::TypeAscriptionOwner for SelfParam {}
2880 impl ast::AttrsOwner for SelfParam {}
2882 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2883 pub struct SlicePat {
2884 pub(crate) syntax: SyntaxNode,
2886 impl AstNode for SlicePat {
2887 fn can_cast(kind: SyntaxKind) -> bool {
2893 fn cast(syntax: SyntaxNode) -> Option<Self> {
2894 if Self::can_cast(syntax.kind()) {
2895 Some(Self { syntax })
2900 fn syntax(&self) -> &SyntaxNode {
2905 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2906 pub struct SliceType {
2907 pub(crate) syntax: SyntaxNode,
2909 impl AstNode for SliceType {
2910 fn can_cast(kind: SyntaxKind) -> bool {
2916 fn cast(syntax: SyntaxNode) -> Option<Self> {
2917 if Self::can_cast(syntax.kind()) {
2918 Some(Self { syntax })
2923 fn syntax(&self) -> &SyntaxNode {
2928 pub fn type_ref(&self) -> Option<TypeRef> {
2929 AstChildren::new(&self.syntax).next()
2932 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2933 pub struct SourceFile {
2934 pub(crate) syntax: SyntaxNode,
2936 impl AstNode for SourceFile {
2937 fn can_cast(kind: SyntaxKind) -> bool {
2939 SOURCE_FILE => true,
2943 fn cast(syntax: SyntaxNode) -> Option<Self> {
2944 if Self::can_cast(syntax.kind()) {
2945 Some(Self { syntax })
2950 fn syntax(&self) -> &SyntaxNode {
2954 impl ast::ModuleItemOwner for SourceFile {}
2955 impl ast::FnDefOwner for SourceFile {}
2957 pub fn modules(&self) -> AstChildren<Module> {
2958 AstChildren::new(&self.syntax)
2961 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2962 pub struct StaticDef {
2963 pub(crate) syntax: SyntaxNode,
2965 impl AstNode for StaticDef {
2966 fn can_cast(kind: SyntaxKind) -> bool {
2972 fn cast(syntax: SyntaxNode) -> Option<Self> {
2973 if Self::can_cast(syntax.kind()) {
2974 Some(Self { syntax })
2979 fn syntax(&self) -> &SyntaxNode {
2983 impl ast::VisibilityOwner for StaticDef {}
2984 impl ast::NameOwner for StaticDef {}
2985 impl ast::TypeParamsOwner for StaticDef {}
2986 impl ast::AttrsOwner for StaticDef {}
2987 impl ast::DocCommentsOwner for StaticDef {}
2988 impl ast::TypeAscriptionOwner for StaticDef {}
2990 pub fn body(&self) -> Option<Expr> {
2991 AstChildren::new(&self.syntax).next()
2994 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2999 impl From<ExprStmt> for Stmt {
3000 fn from(node: ExprStmt) -> Stmt {
3001 Stmt::ExprStmt(node)
3004 impl From<LetStmt> for Stmt {
3005 fn from(node: LetStmt) -> Stmt {
3009 impl AstNode for Stmt {
3010 fn can_cast(kind: SyntaxKind) -> bool {
3012 EXPR_STMT | LET_STMT => true,
3016 fn cast(syntax: SyntaxNode) -> Option<Self> {
3017 let res = match syntax.kind() {
3018 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
3019 LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
3024 fn syntax(&self) -> &SyntaxNode {
3026 Stmt::ExprStmt(it) => &it.syntax,
3027 Stmt::LetStmt(it) => &it.syntax,
3032 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3033 pub struct StructDef {
3034 pub(crate) syntax: SyntaxNode,
3036 impl AstNode for StructDef {
3037 fn can_cast(kind: SyntaxKind) -> bool {
3043 fn cast(syntax: SyntaxNode) -> Option<Self> {
3044 if Self::can_cast(syntax.kind()) {
3045 Some(Self { syntax })
3050 fn syntax(&self) -> &SyntaxNode {
3054 impl ast::VisibilityOwner for StructDef {}
3055 impl ast::NameOwner for StructDef {}
3056 impl ast::TypeParamsOwner for StructDef {}
3057 impl ast::AttrsOwner for StructDef {}
3058 impl ast::DocCommentsOwner for StructDef {}
3060 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3061 pub struct TokenTree {
3062 pub(crate) syntax: SyntaxNode,
3064 impl AstNode for TokenTree {
3065 fn can_cast(kind: SyntaxKind) -> bool {
3071 fn cast(syntax: SyntaxNode) -> Option<Self> {
3072 if Self::can_cast(syntax.kind()) {
3073 Some(Self { syntax })
3078 fn syntax(&self) -> &SyntaxNode {
3083 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3084 pub struct TraitDef {
3085 pub(crate) syntax: SyntaxNode,
3087 impl AstNode for TraitDef {
3088 fn can_cast(kind: SyntaxKind) -> bool {
3094 fn cast(syntax: SyntaxNode) -> Option<Self> {
3095 if Self::can_cast(syntax.kind()) {
3096 Some(Self { syntax })
3101 fn syntax(&self) -> &SyntaxNode {
3105 impl ast::VisibilityOwner for TraitDef {}
3106 impl ast::NameOwner for TraitDef {}
3107 impl ast::AttrsOwner for TraitDef {}
3108 impl ast::DocCommentsOwner for TraitDef {}
3109 impl ast::TypeParamsOwner for TraitDef {}
3110 impl ast::TypeBoundsOwner for TraitDef {}
3112 pub fn item_list(&self) -> Option<ItemList> {
3113 AstChildren::new(&self.syntax).next()
3116 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3117 pub struct TryBlockExpr {
3118 pub(crate) syntax: SyntaxNode,
3120 impl AstNode for TryBlockExpr {
3121 fn can_cast(kind: SyntaxKind) -> bool {
3123 TRY_BLOCK_EXPR => true,
3127 fn cast(syntax: SyntaxNode) -> Option<Self> {
3128 if Self::can_cast(syntax.kind()) {
3129 Some(Self { syntax })
3134 fn syntax(&self) -> &SyntaxNode {
3138 impl ast::TryBlockBodyOwner for TryBlockExpr {}
3139 impl TryBlockExpr {}
3140 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3141 pub struct TryExpr {
3142 pub(crate) syntax: SyntaxNode,
3144 impl AstNode for TryExpr {
3145 fn can_cast(kind: SyntaxKind) -> bool {
3151 fn cast(syntax: SyntaxNode) -> Option<Self> {
3152 if Self::can_cast(syntax.kind()) {
3153 Some(Self { syntax })
3158 fn syntax(&self) -> &SyntaxNode {
3163 pub fn expr(&self) -> Option<Expr> {
3164 AstChildren::new(&self.syntax).next()
3167 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3168 pub struct TupleExpr {
3169 pub(crate) syntax: SyntaxNode,
3171 impl AstNode for TupleExpr {
3172 fn can_cast(kind: SyntaxKind) -> bool {
3178 fn cast(syntax: SyntaxNode) -> Option<Self> {
3179 if Self::can_cast(syntax.kind()) {
3180 Some(Self { syntax })
3185 fn syntax(&self) -> &SyntaxNode {
3190 pub fn exprs(&self) -> AstChildren<Expr> {
3191 AstChildren::new(&self.syntax)
3194 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3195 pub struct TupleFieldDef {
3196 pub(crate) syntax: SyntaxNode,
3198 impl AstNode for TupleFieldDef {
3199 fn can_cast(kind: SyntaxKind) -> bool {
3201 TUPLE_FIELD_DEF => true,
3205 fn cast(syntax: SyntaxNode) -> Option<Self> {
3206 if Self::can_cast(syntax.kind()) {
3207 Some(Self { syntax })
3212 fn syntax(&self) -> &SyntaxNode {
3216 impl ast::VisibilityOwner for TupleFieldDef {}
3217 impl ast::AttrsOwner for TupleFieldDef {}
3218 impl TupleFieldDef {
3219 pub fn type_ref(&self) -> Option<TypeRef> {
3220 AstChildren::new(&self.syntax).next()
3223 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3224 pub struct TupleFieldDefList {
3225 pub(crate) syntax: SyntaxNode,
3227 impl AstNode for TupleFieldDefList {
3228 fn can_cast(kind: SyntaxKind) -> bool {
3230 TUPLE_FIELD_DEF_LIST => true,
3234 fn cast(syntax: SyntaxNode) -> Option<Self> {
3235 if Self::can_cast(syntax.kind()) {
3236 Some(Self { syntax })
3241 fn syntax(&self) -> &SyntaxNode {
3245 impl TupleFieldDefList {
3246 pub fn fields(&self) -> AstChildren<TupleFieldDef> {
3247 AstChildren::new(&self.syntax)
3250 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3251 pub struct TuplePat {
3252 pub(crate) syntax: SyntaxNode,
3254 impl AstNode for TuplePat {
3255 fn can_cast(kind: SyntaxKind) -> bool {
3261 fn cast(syntax: SyntaxNode) -> Option<Self> {
3262 if Self::can_cast(syntax.kind()) {
3263 Some(Self { syntax })
3268 fn syntax(&self) -> &SyntaxNode {
3273 pub fn args(&self) -> AstChildren<Pat> {
3274 AstChildren::new(&self.syntax)
3277 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3278 pub struct TupleStructPat {
3279 pub(crate) syntax: SyntaxNode,
3281 impl AstNode for TupleStructPat {
3282 fn can_cast(kind: SyntaxKind) -> bool {
3284 TUPLE_STRUCT_PAT => true,
3288 fn cast(syntax: SyntaxNode) -> Option<Self> {
3289 if Self::can_cast(syntax.kind()) {
3290 Some(Self { syntax })
3295 fn syntax(&self) -> &SyntaxNode {
3299 impl TupleStructPat {
3300 pub fn args(&self) -> AstChildren<Pat> {
3301 AstChildren::new(&self.syntax)
3303 pub fn path(&self) -> Option<Path> {
3304 AstChildren::new(&self.syntax).next()
3307 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3308 pub struct TupleType {
3309 pub(crate) syntax: SyntaxNode,
3311 impl AstNode for TupleType {
3312 fn can_cast(kind: SyntaxKind) -> bool {
3318 fn cast(syntax: SyntaxNode) -> Option<Self> {
3319 if Self::can_cast(syntax.kind()) {
3320 Some(Self { syntax })
3325 fn syntax(&self) -> &SyntaxNode {
3330 pub fn fields(&self) -> AstChildren<TypeRef> {
3331 AstChildren::new(&self.syntax)
3334 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3335 pub struct TypeAliasDef {
3336 pub(crate) syntax: SyntaxNode,
3338 impl AstNode for TypeAliasDef {
3339 fn can_cast(kind: SyntaxKind) -> bool {
3341 TYPE_ALIAS_DEF => true,
3345 fn cast(syntax: SyntaxNode) -> Option<Self> {
3346 if Self::can_cast(syntax.kind()) {
3347 Some(Self { syntax })
3352 fn syntax(&self) -> &SyntaxNode {
3356 impl ast::VisibilityOwner for TypeAliasDef {}
3357 impl ast::NameOwner for TypeAliasDef {}
3358 impl ast::TypeParamsOwner for TypeAliasDef {}
3359 impl ast::AttrsOwner for TypeAliasDef {}
3360 impl ast::DocCommentsOwner for TypeAliasDef {}
3361 impl ast::TypeBoundsOwner for TypeAliasDef {}
3363 pub fn type_ref(&self) -> Option<TypeRef> {
3364 AstChildren::new(&self.syntax).next()
3367 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3368 pub struct TypeArg {
3369 pub(crate) syntax: SyntaxNode,
3371 impl AstNode for TypeArg {
3372 fn can_cast(kind: SyntaxKind) -> bool {
3378 fn cast(syntax: SyntaxNode) -> Option<Self> {
3379 if Self::can_cast(syntax.kind()) {
3380 Some(Self { syntax })
3385 fn syntax(&self) -> &SyntaxNode {
3390 pub fn type_ref(&self) -> Option<TypeRef> {
3391 AstChildren::new(&self.syntax).next()
3394 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3395 pub struct TypeArgList {
3396 pub(crate) syntax: SyntaxNode,
3398 impl AstNode for TypeArgList {
3399 fn can_cast(kind: SyntaxKind) -> bool {
3401 TYPE_ARG_LIST => true,
3405 fn cast(syntax: SyntaxNode) -> Option<Self> {
3406 if Self::can_cast(syntax.kind()) {
3407 Some(Self { syntax })
3412 fn syntax(&self) -> &SyntaxNode {
3417 pub fn type_args(&self) -> AstChildren<TypeArg> {
3418 AstChildren::new(&self.syntax)
3420 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> {
3421 AstChildren::new(&self.syntax)
3423 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> {
3424 AstChildren::new(&self.syntax)
3427 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3428 pub struct TypeBound {
3429 pub(crate) syntax: SyntaxNode,
3431 impl AstNode for TypeBound {
3432 fn can_cast(kind: SyntaxKind) -> bool {
3438 fn cast(syntax: SyntaxNode) -> Option<Self> {
3439 if Self::can_cast(syntax.kind()) {
3440 Some(Self { syntax })
3445 fn syntax(&self) -> &SyntaxNode {
3450 pub fn type_ref(&self) -> Option<TypeRef> {
3451 AstChildren::new(&self.syntax).next()
3454 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3455 pub struct TypeBoundList {
3456 pub(crate) syntax: SyntaxNode,
3458 impl AstNode for TypeBoundList {
3459 fn can_cast(kind: SyntaxKind) -> bool {
3461 TYPE_BOUND_LIST => true,
3465 fn cast(syntax: SyntaxNode) -> Option<Self> {
3466 if Self::can_cast(syntax.kind()) {
3467 Some(Self { syntax })
3472 fn syntax(&self) -> &SyntaxNode {
3476 impl TypeBoundList {
3477 pub fn bounds(&self) -> AstChildren<TypeBound> {
3478 AstChildren::new(&self.syntax)
3481 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3482 pub struct TypeParam {
3483 pub(crate) syntax: SyntaxNode,
3485 impl AstNode for TypeParam {
3486 fn can_cast(kind: SyntaxKind) -> bool {
3492 fn cast(syntax: SyntaxNode) -> Option<Self> {
3493 if Self::can_cast(syntax.kind()) {
3494 Some(Self { syntax })
3499 fn syntax(&self) -> &SyntaxNode {
3503 impl ast::NameOwner for TypeParam {}
3504 impl ast::AttrsOwner for TypeParam {}
3505 impl ast::TypeBoundsOwner for TypeParam {}
3506 impl ast::DefaultTypeParamOwner for TypeParam {}
3508 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3509 pub struct TypeParamList {
3510 pub(crate) syntax: SyntaxNode,
3512 impl AstNode for TypeParamList {
3513 fn can_cast(kind: SyntaxKind) -> bool {
3515 TYPE_PARAM_LIST => true,
3519 fn cast(syntax: SyntaxNode) -> Option<Self> {
3520 if Self::can_cast(syntax.kind()) {
3521 Some(Self { syntax })
3526 fn syntax(&self) -> &SyntaxNode {
3530 impl TypeParamList {
3531 pub fn type_params(&self) -> AstChildren<TypeParam> {
3532 AstChildren::new(&self.syntax)
3534 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> {
3535 AstChildren::new(&self.syntax)
3538 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3540 ParenType(ParenType),
3541 TupleType(TupleType),
3542 NeverType(NeverType),
3544 PointerType(PointerType),
3545 ArrayType(ArrayType),
3546 SliceType(SliceType),
3547 ReferenceType(ReferenceType),
3548 PlaceholderType(PlaceholderType),
3549 FnPointerType(FnPointerType),
3551 ImplTraitType(ImplTraitType),
3552 DynTraitType(DynTraitType),
3554 impl From<ParenType> for TypeRef {
3555 fn from(node: ParenType) -> TypeRef {
3556 TypeRef::ParenType(node)
3559 impl From<TupleType> for TypeRef {
3560 fn from(node: TupleType) -> TypeRef {
3561 TypeRef::TupleType(node)
3564 impl From<NeverType> for TypeRef {
3565 fn from(node: NeverType) -> TypeRef {
3566 TypeRef::NeverType(node)
3569 impl From<PathType> for TypeRef {
3570 fn from(node: PathType) -> TypeRef {
3571 TypeRef::PathType(node)
3574 impl From<PointerType> for TypeRef {
3575 fn from(node: PointerType) -> TypeRef {
3576 TypeRef::PointerType(node)
3579 impl From<ArrayType> for TypeRef {
3580 fn from(node: ArrayType) -> TypeRef {
3581 TypeRef::ArrayType(node)
3584 impl From<SliceType> for TypeRef {
3585 fn from(node: SliceType) -> TypeRef {
3586 TypeRef::SliceType(node)
3589 impl From<ReferenceType> for TypeRef {
3590 fn from(node: ReferenceType) -> TypeRef {
3591 TypeRef::ReferenceType(node)
3594 impl From<PlaceholderType> for TypeRef {
3595 fn from(node: PlaceholderType) -> TypeRef {
3596 TypeRef::PlaceholderType(node)
3599 impl From<FnPointerType> for TypeRef {
3600 fn from(node: FnPointerType) -> TypeRef {
3601 TypeRef::FnPointerType(node)
3604 impl From<ForType> for TypeRef {
3605 fn from(node: ForType) -> TypeRef {
3606 TypeRef::ForType(node)
3609 impl From<ImplTraitType> for TypeRef {
3610 fn from(node: ImplTraitType) -> TypeRef {
3611 TypeRef::ImplTraitType(node)
3614 impl From<DynTraitType> for TypeRef {
3615 fn from(node: DynTraitType) -> TypeRef {
3616 TypeRef::DynTraitType(node)
3619 impl AstNode for TypeRef {
3620 fn can_cast(kind: SyntaxKind) -> bool {
3622 PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
3623 | SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE
3624 | IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
3628 fn cast(syntax: SyntaxNode) -> Option<Self> {
3629 let res = match syntax.kind() {
3630 PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }),
3631 TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }),
3632 NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }),
3633 PATH_TYPE => TypeRef::PathType(PathType { syntax }),
3634 POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }),
3635 ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }),
3636 SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }),
3637 REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }),
3638 PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }),
3639 FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }),
3640 FOR_TYPE => TypeRef::ForType(ForType { syntax }),
3641 IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }),
3642 DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }),
3647 fn syntax(&self) -> &SyntaxNode {
3649 TypeRef::ParenType(it) => &it.syntax,
3650 TypeRef::TupleType(it) => &it.syntax,
3651 TypeRef::NeverType(it) => &it.syntax,
3652 TypeRef::PathType(it) => &it.syntax,
3653 TypeRef::PointerType(it) => &it.syntax,
3654 TypeRef::ArrayType(it) => &it.syntax,
3655 TypeRef::SliceType(it) => &it.syntax,
3656 TypeRef::ReferenceType(it) => &it.syntax,
3657 TypeRef::PlaceholderType(it) => &it.syntax,
3658 TypeRef::FnPointerType(it) => &it.syntax,
3659 TypeRef::ForType(it) => &it.syntax,
3660 TypeRef::ImplTraitType(it) => &it.syntax,
3661 TypeRef::DynTraitType(it) => &it.syntax,
3666 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3667 pub struct UseItem {
3668 pub(crate) syntax: SyntaxNode,
3670 impl AstNode for UseItem {
3671 fn can_cast(kind: SyntaxKind) -> bool {
3677 fn cast(syntax: SyntaxNode) -> Option<Self> {
3678 if Self::can_cast(syntax.kind()) {
3679 Some(Self { syntax })
3684 fn syntax(&self) -> &SyntaxNode {
3688 impl ast::AttrsOwner for UseItem {}
3690 pub fn use_tree(&self) -> Option<UseTree> {
3691 AstChildren::new(&self.syntax).next()
3694 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3695 pub struct UseTree {
3696 pub(crate) syntax: SyntaxNode,
3698 impl AstNode for UseTree {
3699 fn can_cast(kind: SyntaxKind) -> bool {
3705 fn cast(syntax: SyntaxNode) -> Option<Self> {
3706 if Self::can_cast(syntax.kind()) {
3707 Some(Self { syntax })
3712 fn syntax(&self) -> &SyntaxNode {
3717 pub fn path(&self) -> Option<Path> {
3718 AstChildren::new(&self.syntax).next()
3720 pub fn use_tree_list(&self) -> Option<UseTreeList> {
3721 AstChildren::new(&self.syntax).next()
3723 pub fn alias(&self) -> Option<Alias> {
3724 AstChildren::new(&self.syntax).next()
3727 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3728 pub struct UseTreeList {
3729 pub(crate) syntax: SyntaxNode,
3731 impl AstNode for UseTreeList {
3732 fn can_cast(kind: SyntaxKind) -> bool {
3734 USE_TREE_LIST => true,
3738 fn cast(syntax: SyntaxNode) -> Option<Self> {
3739 if Self::can_cast(syntax.kind()) {
3740 Some(Self { syntax })
3745 fn syntax(&self) -> &SyntaxNode {
3750 pub fn use_trees(&self) -> AstChildren<UseTree> {
3751 AstChildren::new(&self.syntax)
3754 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3755 pub struct Visibility {
3756 pub(crate) syntax: SyntaxNode,
3758 impl AstNode for Visibility {
3759 fn can_cast(kind: SyntaxKind) -> bool {
3765 fn cast(syntax: SyntaxNode) -> Option<Self> {
3766 if Self::can_cast(syntax.kind()) {
3767 Some(Self { syntax })
3772 fn syntax(&self) -> &SyntaxNode {
3777 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3778 pub struct WhereClause {
3779 pub(crate) syntax: SyntaxNode,
3781 impl AstNode for WhereClause {
3782 fn can_cast(kind: SyntaxKind) -> bool {
3784 WHERE_CLAUSE => true,
3788 fn cast(syntax: SyntaxNode) -> Option<Self> {
3789 if Self::can_cast(syntax.kind()) {
3790 Some(Self { syntax })
3795 fn syntax(&self) -> &SyntaxNode {
3800 pub fn predicates(&self) -> AstChildren<WherePred> {
3801 AstChildren::new(&self.syntax)
3804 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3805 pub struct WherePred {
3806 pub(crate) syntax: SyntaxNode,
3808 impl AstNode for WherePred {
3809 fn can_cast(kind: SyntaxKind) -> bool {
3815 fn cast(syntax: SyntaxNode) -> Option<Self> {
3816 if Self::can_cast(syntax.kind()) {
3817 Some(Self { syntax })
3822 fn syntax(&self) -> &SyntaxNode {
3826 impl ast::TypeBoundsOwner for WherePred {}
3828 pub fn type_ref(&self) -> Option<TypeRef> {
3829 AstChildren::new(&self.syntax).next()
3832 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3833 pub struct WhileExpr {
3834 pub(crate) syntax: SyntaxNode,
3836 impl AstNode for WhileExpr {
3837 fn can_cast(kind: SyntaxKind) -> bool {
3843 fn cast(syntax: SyntaxNode) -> Option<Self> {
3844 if Self::can_cast(syntax.kind()) {
3845 Some(Self { syntax })
3850 fn syntax(&self) -> &SyntaxNode {
3854 impl ast::LoopBodyOwner for WhileExpr {}
3856 pub fn condition(&self) -> Option<Condition> {
3857 AstChildren::new(&self.syntax).next()