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<BlockExpr> {
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()
2315 pub fn param_list(&self) -> Option<ParamList> {
2316 AstChildren::new(&self.syntax).next()
2318 pub fn ret_type(&self) -> Option<RetType> {
2319 AstChildren::new(&self.syntax).next()
2322 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2323 pub struct PathType {
2324 pub(crate) syntax: SyntaxNode,
2326 impl AstNode for PathType {
2327 fn can_cast(kind: SyntaxKind) -> bool {
2333 fn cast(syntax: SyntaxNode) -> Option<Self> {
2334 if Self::can_cast(syntax.kind()) {
2335 Some(Self { syntax })
2340 fn syntax(&self) -> &SyntaxNode {
2345 pub fn path(&self) -> Option<Path> {
2346 AstChildren::new(&self.syntax).next()
2349 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2350 pub struct PlaceholderPat {
2351 pub(crate) syntax: SyntaxNode,
2353 impl AstNode for PlaceholderPat {
2354 fn can_cast(kind: SyntaxKind) -> bool {
2356 PLACEHOLDER_PAT => true,
2360 fn cast(syntax: SyntaxNode) -> Option<Self> {
2361 if Self::can_cast(syntax.kind()) {
2362 Some(Self { syntax })
2367 fn syntax(&self) -> &SyntaxNode {
2371 impl PlaceholderPat {}
2372 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2373 pub struct PlaceholderType {
2374 pub(crate) syntax: SyntaxNode,
2376 impl AstNode for PlaceholderType {
2377 fn can_cast(kind: SyntaxKind) -> bool {
2379 PLACEHOLDER_TYPE => true,
2383 fn cast(syntax: SyntaxNode) -> Option<Self> {
2384 if Self::can_cast(syntax.kind()) {
2385 Some(Self { syntax })
2390 fn syntax(&self) -> &SyntaxNode {
2394 impl PlaceholderType {}
2395 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2396 pub struct PointerType {
2397 pub(crate) syntax: SyntaxNode,
2399 impl AstNode for PointerType {
2400 fn can_cast(kind: SyntaxKind) -> bool {
2402 POINTER_TYPE => true,
2406 fn cast(syntax: SyntaxNode) -> Option<Self> {
2407 if Self::can_cast(syntax.kind()) {
2408 Some(Self { syntax })
2413 fn syntax(&self) -> &SyntaxNode {
2418 pub fn type_ref(&self) -> Option<TypeRef> {
2419 AstChildren::new(&self.syntax).next()
2422 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2423 pub struct PrefixExpr {
2424 pub(crate) syntax: SyntaxNode,
2426 impl AstNode for PrefixExpr {
2427 fn can_cast(kind: SyntaxKind) -> bool {
2429 PREFIX_EXPR => true,
2433 fn cast(syntax: SyntaxNode) -> Option<Self> {
2434 if Self::can_cast(syntax.kind()) {
2435 Some(Self { syntax })
2440 fn syntax(&self) -> &SyntaxNode {
2445 pub fn expr(&self) -> Option<Expr> {
2446 AstChildren::new(&self.syntax).next()
2449 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2450 pub struct RangeExpr {
2451 pub(crate) syntax: SyntaxNode,
2453 impl AstNode for RangeExpr {
2454 fn can_cast(kind: SyntaxKind) -> bool {
2460 fn cast(syntax: SyntaxNode) -> Option<Self> {
2461 if Self::can_cast(syntax.kind()) {
2462 Some(Self { syntax })
2467 fn syntax(&self) -> &SyntaxNode {
2472 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2473 pub struct RangePat {
2474 pub(crate) syntax: SyntaxNode,
2476 impl AstNode for RangePat {
2477 fn can_cast(kind: SyntaxKind) -> bool {
2483 fn cast(syntax: SyntaxNode) -> Option<Self> {
2484 if Self::can_cast(syntax.kind()) {
2485 Some(Self { syntax })
2490 fn syntax(&self) -> &SyntaxNode {
2495 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2496 pub struct RecordField {
2497 pub(crate) syntax: SyntaxNode,
2499 impl AstNode for RecordField {
2500 fn can_cast(kind: SyntaxKind) -> bool {
2502 RECORD_FIELD => true,
2506 fn cast(syntax: SyntaxNode) -> Option<Self> {
2507 if Self::can_cast(syntax.kind()) {
2508 Some(Self { syntax })
2513 fn syntax(&self) -> &SyntaxNode {
2518 pub fn name_ref(&self) -> Option<NameRef> {
2519 AstChildren::new(&self.syntax).next()
2521 pub fn expr(&self) -> Option<Expr> {
2522 AstChildren::new(&self.syntax).next()
2525 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2526 pub struct RecordFieldDef {
2527 pub(crate) syntax: SyntaxNode,
2529 impl AstNode for RecordFieldDef {
2530 fn can_cast(kind: SyntaxKind) -> bool {
2532 RECORD_FIELD_DEF => true,
2536 fn cast(syntax: SyntaxNode) -> Option<Self> {
2537 if Self::can_cast(syntax.kind()) {
2538 Some(Self { syntax })
2543 fn syntax(&self) -> &SyntaxNode {
2547 impl ast::VisibilityOwner for RecordFieldDef {}
2548 impl ast::NameOwner for RecordFieldDef {}
2549 impl ast::AttrsOwner for RecordFieldDef {}
2550 impl ast::DocCommentsOwner for RecordFieldDef {}
2551 impl ast::TypeAscriptionOwner for RecordFieldDef {}
2552 impl RecordFieldDef {}
2553 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2554 pub struct RecordFieldDefList {
2555 pub(crate) syntax: SyntaxNode,
2557 impl AstNode for RecordFieldDefList {
2558 fn can_cast(kind: SyntaxKind) -> bool {
2560 RECORD_FIELD_DEF_LIST => true,
2564 fn cast(syntax: SyntaxNode) -> Option<Self> {
2565 if Self::can_cast(syntax.kind()) {
2566 Some(Self { syntax })
2571 fn syntax(&self) -> &SyntaxNode {
2575 impl RecordFieldDefList {
2576 pub fn fields(&self) -> AstChildren<RecordFieldDef> {
2577 AstChildren::new(&self.syntax)
2580 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2581 pub struct RecordFieldList {
2582 pub(crate) syntax: SyntaxNode,
2584 impl AstNode for RecordFieldList {
2585 fn can_cast(kind: SyntaxKind) -> bool {
2587 RECORD_FIELD_LIST => true,
2591 fn cast(syntax: SyntaxNode) -> Option<Self> {
2592 if Self::can_cast(syntax.kind()) {
2593 Some(Self { syntax })
2598 fn syntax(&self) -> &SyntaxNode {
2602 impl RecordFieldList {
2603 pub fn fields(&self) -> AstChildren<RecordField> {
2604 AstChildren::new(&self.syntax)
2606 pub fn spread(&self) -> Option<Expr> {
2607 AstChildren::new(&self.syntax).next()
2610 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2611 pub struct RecordFieldPat {
2612 pub(crate) syntax: SyntaxNode,
2614 impl AstNode for RecordFieldPat {
2615 fn can_cast(kind: SyntaxKind) -> bool {
2617 RECORD_FIELD_PAT => true,
2621 fn cast(syntax: SyntaxNode) -> Option<Self> {
2622 if Self::can_cast(syntax.kind()) {
2623 Some(Self { syntax })
2628 fn syntax(&self) -> &SyntaxNode {
2632 impl ast::NameOwner for RecordFieldPat {}
2633 impl RecordFieldPat {
2634 pub fn pat(&self) -> Option<Pat> {
2635 AstChildren::new(&self.syntax).next()
2638 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2639 pub struct RecordFieldPatList {
2640 pub(crate) syntax: SyntaxNode,
2642 impl AstNode for RecordFieldPatList {
2643 fn can_cast(kind: SyntaxKind) -> bool {
2645 RECORD_FIELD_PAT_LIST => true,
2649 fn cast(syntax: SyntaxNode) -> Option<Self> {
2650 if Self::can_cast(syntax.kind()) {
2651 Some(Self { syntax })
2656 fn syntax(&self) -> &SyntaxNode {
2660 impl RecordFieldPatList {
2661 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
2662 AstChildren::new(&self.syntax)
2664 pub fn bind_pats(&self) -> AstChildren<BindPat> {
2665 AstChildren::new(&self.syntax)
2668 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2669 pub struct RecordLit {
2670 pub(crate) syntax: SyntaxNode,
2672 impl AstNode for RecordLit {
2673 fn can_cast(kind: SyntaxKind) -> bool {
2679 fn cast(syntax: SyntaxNode) -> Option<Self> {
2680 if Self::can_cast(syntax.kind()) {
2681 Some(Self { syntax })
2686 fn syntax(&self) -> &SyntaxNode {
2691 pub fn path(&self) -> Option<Path> {
2692 AstChildren::new(&self.syntax).next()
2694 pub fn record_field_list(&self) -> Option<RecordFieldList> {
2695 AstChildren::new(&self.syntax).next()
2698 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2699 pub struct RecordPat {
2700 pub(crate) syntax: SyntaxNode,
2702 impl AstNode for RecordPat {
2703 fn can_cast(kind: SyntaxKind) -> bool {
2709 fn cast(syntax: SyntaxNode) -> Option<Self> {
2710 if Self::can_cast(syntax.kind()) {
2711 Some(Self { syntax })
2716 fn syntax(&self) -> &SyntaxNode {
2721 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
2722 AstChildren::new(&self.syntax).next()
2724 pub fn path(&self) -> Option<Path> {
2725 AstChildren::new(&self.syntax).next()
2728 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2729 pub struct RefExpr {
2730 pub(crate) syntax: SyntaxNode,
2732 impl AstNode for RefExpr {
2733 fn can_cast(kind: SyntaxKind) -> bool {
2739 fn cast(syntax: SyntaxNode) -> Option<Self> {
2740 if Self::can_cast(syntax.kind()) {
2741 Some(Self { syntax })
2746 fn syntax(&self) -> &SyntaxNode {
2751 pub fn expr(&self) -> Option<Expr> {
2752 AstChildren::new(&self.syntax).next()
2755 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2757 pub(crate) syntax: SyntaxNode,
2759 impl AstNode for RefPat {
2760 fn can_cast(kind: SyntaxKind) -> bool {
2766 fn cast(syntax: SyntaxNode) -> Option<Self> {
2767 if Self::can_cast(syntax.kind()) {
2768 Some(Self { syntax })
2773 fn syntax(&self) -> &SyntaxNode {
2778 pub fn pat(&self) -> Option<Pat> {
2779 AstChildren::new(&self.syntax).next()
2782 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2783 pub struct ReferenceType {
2784 pub(crate) syntax: SyntaxNode,
2786 impl AstNode for ReferenceType {
2787 fn can_cast(kind: SyntaxKind) -> bool {
2789 REFERENCE_TYPE => true,
2793 fn cast(syntax: SyntaxNode) -> Option<Self> {
2794 if Self::can_cast(syntax.kind()) {
2795 Some(Self { syntax })
2800 fn syntax(&self) -> &SyntaxNode {
2804 impl ReferenceType {
2805 pub fn type_ref(&self) -> Option<TypeRef> {
2806 AstChildren::new(&self.syntax).next()
2809 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2810 pub struct RetType {
2811 pub(crate) syntax: SyntaxNode,
2813 impl AstNode for RetType {
2814 fn can_cast(kind: SyntaxKind) -> bool {
2820 fn cast(syntax: SyntaxNode) -> Option<Self> {
2821 if Self::can_cast(syntax.kind()) {
2822 Some(Self { syntax })
2827 fn syntax(&self) -> &SyntaxNode {
2832 pub fn type_ref(&self) -> Option<TypeRef> {
2833 AstChildren::new(&self.syntax).next()
2836 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2837 pub struct ReturnExpr {
2838 pub(crate) syntax: SyntaxNode,
2840 impl AstNode for ReturnExpr {
2841 fn can_cast(kind: SyntaxKind) -> bool {
2843 RETURN_EXPR => true,
2847 fn cast(syntax: SyntaxNode) -> Option<Self> {
2848 if Self::can_cast(syntax.kind()) {
2849 Some(Self { syntax })
2854 fn syntax(&self) -> &SyntaxNode {
2859 pub fn expr(&self) -> Option<Expr> {
2860 AstChildren::new(&self.syntax).next()
2863 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2864 pub struct SelfParam {
2865 pub(crate) syntax: SyntaxNode,
2867 impl AstNode for SelfParam {
2868 fn can_cast(kind: SyntaxKind) -> bool {
2874 fn cast(syntax: SyntaxNode) -> Option<Self> {
2875 if Self::can_cast(syntax.kind()) {
2876 Some(Self { syntax })
2881 fn syntax(&self) -> &SyntaxNode {
2885 impl ast::TypeAscriptionOwner for SelfParam {}
2886 impl ast::AttrsOwner for SelfParam {}
2888 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2889 pub struct SlicePat {
2890 pub(crate) syntax: SyntaxNode,
2892 impl AstNode for SlicePat {
2893 fn can_cast(kind: SyntaxKind) -> bool {
2899 fn cast(syntax: SyntaxNode) -> Option<Self> {
2900 if Self::can_cast(syntax.kind()) {
2901 Some(Self { syntax })
2906 fn syntax(&self) -> &SyntaxNode {
2911 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2912 pub struct SliceType {
2913 pub(crate) syntax: SyntaxNode,
2915 impl AstNode for SliceType {
2916 fn can_cast(kind: SyntaxKind) -> bool {
2922 fn cast(syntax: SyntaxNode) -> Option<Self> {
2923 if Self::can_cast(syntax.kind()) {
2924 Some(Self { syntax })
2929 fn syntax(&self) -> &SyntaxNode {
2934 pub fn type_ref(&self) -> Option<TypeRef> {
2935 AstChildren::new(&self.syntax).next()
2938 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2939 pub struct SourceFile {
2940 pub(crate) syntax: SyntaxNode,
2942 impl AstNode for SourceFile {
2943 fn can_cast(kind: SyntaxKind) -> bool {
2945 SOURCE_FILE => true,
2949 fn cast(syntax: SyntaxNode) -> Option<Self> {
2950 if Self::can_cast(syntax.kind()) {
2951 Some(Self { syntax })
2956 fn syntax(&self) -> &SyntaxNode {
2960 impl ast::ModuleItemOwner for SourceFile {}
2961 impl ast::FnDefOwner for SourceFile {}
2963 pub fn modules(&self) -> AstChildren<Module> {
2964 AstChildren::new(&self.syntax)
2967 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2968 pub struct StaticDef {
2969 pub(crate) syntax: SyntaxNode,
2971 impl AstNode for StaticDef {
2972 fn can_cast(kind: SyntaxKind) -> bool {
2978 fn cast(syntax: SyntaxNode) -> Option<Self> {
2979 if Self::can_cast(syntax.kind()) {
2980 Some(Self { syntax })
2985 fn syntax(&self) -> &SyntaxNode {
2989 impl ast::VisibilityOwner for StaticDef {}
2990 impl ast::NameOwner for StaticDef {}
2991 impl ast::TypeParamsOwner for StaticDef {}
2992 impl ast::AttrsOwner for StaticDef {}
2993 impl ast::DocCommentsOwner for StaticDef {}
2994 impl ast::TypeAscriptionOwner for StaticDef {}
2996 pub fn body(&self) -> Option<Expr> {
2997 AstChildren::new(&self.syntax).next()
3000 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3005 impl From<ExprStmt> for Stmt {
3006 fn from(node: ExprStmt) -> Stmt {
3007 Stmt::ExprStmt(node)
3010 impl From<LetStmt> for Stmt {
3011 fn from(node: LetStmt) -> Stmt {
3015 impl AstNode for Stmt {
3016 fn can_cast(kind: SyntaxKind) -> bool {
3018 EXPR_STMT | LET_STMT => true,
3022 fn cast(syntax: SyntaxNode) -> Option<Self> {
3023 let res = match syntax.kind() {
3024 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
3025 LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
3030 fn syntax(&self) -> &SyntaxNode {
3032 Stmt::ExprStmt(it) => &it.syntax,
3033 Stmt::LetStmt(it) => &it.syntax,
3038 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3039 pub struct StructDef {
3040 pub(crate) syntax: SyntaxNode,
3042 impl AstNode for StructDef {
3043 fn can_cast(kind: SyntaxKind) -> bool {
3049 fn cast(syntax: SyntaxNode) -> Option<Self> {
3050 if Self::can_cast(syntax.kind()) {
3051 Some(Self { syntax })
3056 fn syntax(&self) -> &SyntaxNode {
3060 impl ast::VisibilityOwner for StructDef {}
3061 impl ast::NameOwner for StructDef {}
3062 impl ast::TypeParamsOwner for StructDef {}
3063 impl ast::AttrsOwner for StructDef {}
3064 impl ast::DocCommentsOwner for StructDef {}
3066 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3067 pub struct TokenTree {
3068 pub(crate) syntax: SyntaxNode,
3070 impl AstNode for TokenTree {
3071 fn can_cast(kind: SyntaxKind) -> bool {
3077 fn cast(syntax: SyntaxNode) -> Option<Self> {
3078 if Self::can_cast(syntax.kind()) {
3079 Some(Self { syntax })
3084 fn syntax(&self) -> &SyntaxNode {
3089 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3090 pub struct TraitDef {
3091 pub(crate) syntax: SyntaxNode,
3093 impl AstNode for TraitDef {
3094 fn can_cast(kind: SyntaxKind) -> bool {
3100 fn cast(syntax: SyntaxNode) -> Option<Self> {
3101 if Self::can_cast(syntax.kind()) {
3102 Some(Self { syntax })
3107 fn syntax(&self) -> &SyntaxNode {
3111 impl ast::VisibilityOwner for TraitDef {}
3112 impl ast::NameOwner for TraitDef {}
3113 impl ast::AttrsOwner for TraitDef {}
3114 impl ast::DocCommentsOwner for TraitDef {}
3115 impl ast::TypeParamsOwner for TraitDef {}
3116 impl ast::TypeBoundsOwner for TraitDef {}
3118 pub fn item_list(&self) -> Option<ItemList> {
3119 AstChildren::new(&self.syntax).next()
3122 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3123 pub struct TryBlockExpr {
3124 pub(crate) syntax: SyntaxNode,
3126 impl AstNode for TryBlockExpr {
3127 fn can_cast(kind: SyntaxKind) -> bool {
3129 TRY_BLOCK_EXPR => true,
3133 fn cast(syntax: SyntaxNode) -> Option<Self> {
3134 if Self::can_cast(syntax.kind()) {
3135 Some(Self { syntax })
3140 fn syntax(&self) -> &SyntaxNode {
3145 pub fn body(&self) -> Option<BlockExpr> {
3146 AstChildren::new(&self.syntax).next()
3149 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3150 pub struct TryExpr {
3151 pub(crate) syntax: SyntaxNode,
3153 impl AstNode for TryExpr {
3154 fn can_cast(kind: SyntaxKind) -> bool {
3160 fn cast(syntax: SyntaxNode) -> Option<Self> {
3161 if Self::can_cast(syntax.kind()) {
3162 Some(Self { syntax })
3167 fn syntax(&self) -> &SyntaxNode {
3172 pub fn expr(&self) -> Option<Expr> {
3173 AstChildren::new(&self.syntax).next()
3176 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3177 pub struct TupleExpr {
3178 pub(crate) syntax: SyntaxNode,
3180 impl AstNode for TupleExpr {
3181 fn can_cast(kind: SyntaxKind) -> bool {
3187 fn cast(syntax: SyntaxNode) -> Option<Self> {
3188 if Self::can_cast(syntax.kind()) {
3189 Some(Self { syntax })
3194 fn syntax(&self) -> &SyntaxNode {
3199 pub fn exprs(&self) -> AstChildren<Expr> {
3200 AstChildren::new(&self.syntax)
3203 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3204 pub struct TupleFieldDef {
3205 pub(crate) syntax: SyntaxNode,
3207 impl AstNode for TupleFieldDef {
3208 fn can_cast(kind: SyntaxKind) -> bool {
3210 TUPLE_FIELD_DEF => true,
3214 fn cast(syntax: SyntaxNode) -> Option<Self> {
3215 if Self::can_cast(syntax.kind()) {
3216 Some(Self { syntax })
3221 fn syntax(&self) -> &SyntaxNode {
3225 impl ast::VisibilityOwner for TupleFieldDef {}
3226 impl ast::AttrsOwner for TupleFieldDef {}
3227 impl TupleFieldDef {
3228 pub fn type_ref(&self) -> Option<TypeRef> {
3229 AstChildren::new(&self.syntax).next()
3232 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3233 pub struct TupleFieldDefList {
3234 pub(crate) syntax: SyntaxNode,
3236 impl AstNode for TupleFieldDefList {
3237 fn can_cast(kind: SyntaxKind) -> bool {
3239 TUPLE_FIELD_DEF_LIST => true,
3243 fn cast(syntax: SyntaxNode) -> Option<Self> {
3244 if Self::can_cast(syntax.kind()) {
3245 Some(Self { syntax })
3250 fn syntax(&self) -> &SyntaxNode {
3254 impl TupleFieldDefList {
3255 pub fn fields(&self) -> AstChildren<TupleFieldDef> {
3256 AstChildren::new(&self.syntax)
3259 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3260 pub struct TuplePat {
3261 pub(crate) syntax: SyntaxNode,
3263 impl AstNode for TuplePat {
3264 fn can_cast(kind: SyntaxKind) -> bool {
3270 fn cast(syntax: SyntaxNode) -> Option<Self> {
3271 if Self::can_cast(syntax.kind()) {
3272 Some(Self { syntax })
3277 fn syntax(&self) -> &SyntaxNode {
3282 pub fn args(&self) -> AstChildren<Pat> {
3283 AstChildren::new(&self.syntax)
3286 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3287 pub struct TupleStructPat {
3288 pub(crate) syntax: SyntaxNode,
3290 impl AstNode for TupleStructPat {
3291 fn can_cast(kind: SyntaxKind) -> bool {
3293 TUPLE_STRUCT_PAT => true,
3297 fn cast(syntax: SyntaxNode) -> Option<Self> {
3298 if Self::can_cast(syntax.kind()) {
3299 Some(Self { syntax })
3304 fn syntax(&self) -> &SyntaxNode {
3308 impl TupleStructPat {
3309 pub fn args(&self) -> AstChildren<Pat> {
3310 AstChildren::new(&self.syntax)
3312 pub fn path(&self) -> Option<Path> {
3313 AstChildren::new(&self.syntax).next()
3316 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3317 pub struct TupleType {
3318 pub(crate) syntax: SyntaxNode,
3320 impl AstNode for TupleType {
3321 fn can_cast(kind: SyntaxKind) -> bool {
3327 fn cast(syntax: SyntaxNode) -> Option<Self> {
3328 if Self::can_cast(syntax.kind()) {
3329 Some(Self { syntax })
3334 fn syntax(&self) -> &SyntaxNode {
3339 pub fn fields(&self) -> AstChildren<TypeRef> {
3340 AstChildren::new(&self.syntax)
3343 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3344 pub struct TypeAliasDef {
3345 pub(crate) syntax: SyntaxNode,
3347 impl AstNode for TypeAliasDef {
3348 fn can_cast(kind: SyntaxKind) -> bool {
3350 TYPE_ALIAS_DEF => true,
3354 fn cast(syntax: SyntaxNode) -> Option<Self> {
3355 if Self::can_cast(syntax.kind()) {
3356 Some(Self { syntax })
3361 fn syntax(&self) -> &SyntaxNode {
3365 impl ast::VisibilityOwner for TypeAliasDef {}
3366 impl ast::NameOwner for TypeAliasDef {}
3367 impl ast::TypeParamsOwner for TypeAliasDef {}
3368 impl ast::AttrsOwner for TypeAliasDef {}
3369 impl ast::DocCommentsOwner for TypeAliasDef {}
3370 impl ast::TypeBoundsOwner for TypeAliasDef {}
3372 pub fn type_ref(&self) -> Option<TypeRef> {
3373 AstChildren::new(&self.syntax).next()
3376 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3377 pub struct TypeArg {
3378 pub(crate) syntax: SyntaxNode,
3380 impl AstNode for TypeArg {
3381 fn can_cast(kind: SyntaxKind) -> bool {
3387 fn cast(syntax: SyntaxNode) -> Option<Self> {
3388 if Self::can_cast(syntax.kind()) {
3389 Some(Self { syntax })
3394 fn syntax(&self) -> &SyntaxNode {
3399 pub fn type_ref(&self) -> Option<TypeRef> {
3400 AstChildren::new(&self.syntax).next()
3403 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3404 pub struct TypeArgList {
3405 pub(crate) syntax: SyntaxNode,
3407 impl AstNode for TypeArgList {
3408 fn can_cast(kind: SyntaxKind) -> bool {
3410 TYPE_ARG_LIST => true,
3414 fn cast(syntax: SyntaxNode) -> Option<Self> {
3415 if Self::can_cast(syntax.kind()) {
3416 Some(Self { syntax })
3421 fn syntax(&self) -> &SyntaxNode {
3426 pub fn type_args(&self) -> AstChildren<TypeArg> {
3427 AstChildren::new(&self.syntax)
3429 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> {
3430 AstChildren::new(&self.syntax)
3432 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> {
3433 AstChildren::new(&self.syntax)
3436 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3437 pub struct TypeBound {
3438 pub(crate) syntax: SyntaxNode,
3440 impl AstNode for TypeBound {
3441 fn can_cast(kind: SyntaxKind) -> bool {
3447 fn cast(syntax: SyntaxNode) -> Option<Self> {
3448 if Self::can_cast(syntax.kind()) {
3449 Some(Self { syntax })
3454 fn syntax(&self) -> &SyntaxNode {
3459 pub fn type_ref(&self) -> Option<TypeRef> {
3460 AstChildren::new(&self.syntax).next()
3463 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3464 pub struct TypeBoundList {
3465 pub(crate) syntax: SyntaxNode,
3467 impl AstNode for TypeBoundList {
3468 fn can_cast(kind: SyntaxKind) -> bool {
3470 TYPE_BOUND_LIST => true,
3474 fn cast(syntax: SyntaxNode) -> Option<Self> {
3475 if Self::can_cast(syntax.kind()) {
3476 Some(Self { syntax })
3481 fn syntax(&self) -> &SyntaxNode {
3485 impl TypeBoundList {
3486 pub fn bounds(&self) -> AstChildren<TypeBound> {
3487 AstChildren::new(&self.syntax)
3490 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3491 pub struct TypeParam {
3492 pub(crate) syntax: SyntaxNode,
3494 impl AstNode for TypeParam {
3495 fn can_cast(kind: SyntaxKind) -> bool {
3501 fn cast(syntax: SyntaxNode) -> Option<Self> {
3502 if Self::can_cast(syntax.kind()) {
3503 Some(Self { syntax })
3508 fn syntax(&self) -> &SyntaxNode {
3512 impl ast::NameOwner for TypeParam {}
3513 impl ast::AttrsOwner for TypeParam {}
3514 impl ast::TypeBoundsOwner for TypeParam {}
3515 impl ast::DefaultTypeParamOwner for TypeParam {}
3517 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3518 pub struct TypeParamList {
3519 pub(crate) syntax: SyntaxNode,
3521 impl AstNode for TypeParamList {
3522 fn can_cast(kind: SyntaxKind) -> bool {
3524 TYPE_PARAM_LIST => true,
3528 fn cast(syntax: SyntaxNode) -> Option<Self> {
3529 if Self::can_cast(syntax.kind()) {
3530 Some(Self { syntax })
3535 fn syntax(&self) -> &SyntaxNode {
3539 impl TypeParamList {
3540 pub fn type_params(&self) -> AstChildren<TypeParam> {
3541 AstChildren::new(&self.syntax)
3543 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> {
3544 AstChildren::new(&self.syntax)
3547 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3549 ParenType(ParenType),
3550 TupleType(TupleType),
3551 NeverType(NeverType),
3553 PointerType(PointerType),
3554 ArrayType(ArrayType),
3555 SliceType(SliceType),
3556 ReferenceType(ReferenceType),
3557 PlaceholderType(PlaceholderType),
3558 FnPointerType(FnPointerType),
3560 ImplTraitType(ImplTraitType),
3561 DynTraitType(DynTraitType),
3563 impl From<ParenType> for TypeRef {
3564 fn from(node: ParenType) -> TypeRef {
3565 TypeRef::ParenType(node)
3568 impl From<TupleType> for TypeRef {
3569 fn from(node: TupleType) -> TypeRef {
3570 TypeRef::TupleType(node)
3573 impl From<NeverType> for TypeRef {
3574 fn from(node: NeverType) -> TypeRef {
3575 TypeRef::NeverType(node)
3578 impl From<PathType> for TypeRef {
3579 fn from(node: PathType) -> TypeRef {
3580 TypeRef::PathType(node)
3583 impl From<PointerType> for TypeRef {
3584 fn from(node: PointerType) -> TypeRef {
3585 TypeRef::PointerType(node)
3588 impl From<ArrayType> for TypeRef {
3589 fn from(node: ArrayType) -> TypeRef {
3590 TypeRef::ArrayType(node)
3593 impl From<SliceType> for TypeRef {
3594 fn from(node: SliceType) -> TypeRef {
3595 TypeRef::SliceType(node)
3598 impl From<ReferenceType> for TypeRef {
3599 fn from(node: ReferenceType) -> TypeRef {
3600 TypeRef::ReferenceType(node)
3603 impl From<PlaceholderType> for TypeRef {
3604 fn from(node: PlaceholderType) -> TypeRef {
3605 TypeRef::PlaceholderType(node)
3608 impl From<FnPointerType> for TypeRef {
3609 fn from(node: FnPointerType) -> TypeRef {
3610 TypeRef::FnPointerType(node)
3613 impl From<ForType> for TypeRef {
3614 fn from(node: ForType) -> TypeRef {
3615 TypeRef::ForType(node)
3618 impl From<ImplTraitType> for TypeRef {
3619 fn from(node: ImplTraitType) -> TypeRef {
3620 TypeRef::ImplTraitType(node)
3623 impl From<DynTraitType> for TypeRef {
3624 fn from(node: DynTraitType) -> TypeRef {
3625 TypeRef::DynTraitType(node)
3628 impl AstNode for TypeRef {
3629 fn can_cast(kind: SyntaxKind) -> bool {
3631 PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
3632 | SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE
3633 | IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
3637 fn cast(syntax: SyntaxNode) -> Option<Self> {
3638 let res = match syntax.kind() {
3639 PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }),
3640 TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }),
3641 NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }),
3642 PATH_TYPE => TypeRef::PathType(PathType { syntax }),
3643 POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }),
3644 ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }),
3645 SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }),
3646 REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }),
3647 PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }),
3648 FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }),
3649 FOR_TYPE => TypeRef::ForType(ForType { syntax }),
3650 IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }),
3651 DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }),
3656 fn syntax(&self) -> &SyntaxNode {
3658 TypeRef::ParenType(it) => &it.syntax,
3659 TypeRef::TupleType(it) => &it.syntax,
3660 TypeRef::NeverType(it) => &it.syntax,
3661 TypeRef::PathType(it) => &it.syntax,
3662 TypeRef::PointerType(it) => &it.syntax,
3663 TypeRef::ArrayType(it) => &it.syntax,
3664 TypeRef::SliceType(it) => &it.syntax,
3665 TypeRef::ReferenceType(it) => &it.syntax,
3666 TypeRef::PlaceholderType(it) => &it.syntax,
3667 TypeRef::FnPointerType(it) => &it.syntax,
3668 TypeRef::ForType(it) => &it.syntax,
3669 TypeRef::ImplTraitType(it) => &it.syntax,
3670 TypeRef::DynTraitType(it) => &it.syntax,
3675 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3676 pub struct UseItem {
3677 pub(crate) syntax: SyntaxNode,
3679 impl AstNode for UseItem {
3680 fn can_cast(kind: SyntaxKind) -> bool {
3686 fn cast(syntax: SyntaxNode) -> Option<Self> {
3687 if Self::can_cast(syntax.kind()) {
3688 Some(Self { syntax })
3693 fn syntax(&self) -> &SyntaxNode {
3697 impl ast::AttrsOwner for UseItem {}
3699 pub fn use_tree(&self) -> Option<UseTree> {
3700 AstChildren::new(&self.syntax).next()
3703 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3704 pub struct UseTree {
3705 pub(crate) syntax: SyntaxNode,
3707 impl AstNode for UseTree {
3708 fn can_cast(kind: SyntaxKind) -> bool {
3714 fn cast(syntax: SyntaxNode) -> Option<Self> {
3715 if Self::can_cast(syntax.kind()) {
3716 Some(Self { syntax })
3721 fn syntax(&self) -> &SyntaxNode {
3726 pub fn path(&self) -> Option<Path> {
3727 AstChildren::new(&self.syntax).next()
3729 pub fn use_tree_list(&self) -> Option<UseTreeList> {
3730 AstChildren::new(&self.syntax).next()
3732 pub fn alias(&self) -> Option<Alias> {
3733 AstChildren::new(&self.syntax).next()
3736 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3737 pub struct UseTreeList {
3738 pub(crate) syntax: SyntaxNode,
3740 impl AstNode for UseTreeList {
3741 fn can_cast(kind: SyntaxKind) -> bool {
3743 USE_TREE_LIST => true,
3747 fn cast(syntax: SyntaxNode) -> Option<Self> {
3748 if Self::can_cast(syntax.kind()) {
3749 Some(Self { syntax })
3754 fn syntax(&self) -> &SyntaxNode {
3759 pub fn use_trees(&self) -> AstChildren<UseTree> {
3760 AstChildren::new(&self.syntax)
3763 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3764 pub struct Visibility {
3765 pub(crate) syntax: SyntaxNode,
3767 impl AstNode for Visibility {
3768 fn can_cast(kind: SyntaxKind) -> bool {
3774 fn cast(syntax: SyntaxNode) -> Option<Self> {
3775 if Self::can_cast(syntax.kind()) {
3776 Some(Self { syntax })
3781 fn syntax(&self) -> &SyntaxNode {
3786 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3787 pub struct WhereClause {
3788 pub(crate) syntax: SyntaxNode,
3790 impl AstNode for WhereClause {
3791 fn can_cast(kind: SyntaxKind) -> bool {
3793 WHERE_CLAUSE => true,
3797 fn cast(syntax: SyntaxNode) -> Option<Self> {
3798 if Self::can_cast(syntax.kind()) {
3799 Some(Self { syntax })
3804 fn syntax(&self) -> &SyntaxNode {
3809 pub fn predicates(&self) -> AstChildren<WherePred> {
3810 AstChildren::new(&self.syntax)
3813 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3814 pub struct WherePred {
3815 pub(crate) syntax: SyntaxNode,
3817 impl AstNode for WherePred {
3818 fn can_cast(kind: SyntaxKind) -> bool {
3824 fn cast(syntax: SyntaxNode) -> Option<Self> {
3825 if Self::can_cast(syntax.kind()) {
3826 Some(Self { syntax })
3831 fn syntax(&self) -> &SyntaxNode {
3835 impl ast::TypeBoundsOwner for WherePred {}
3837 pub fn type_ref(&self) -> Option<TypeRef> {
3838 AstChildren::new(&self.syntax).next()
3841 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3842 pub struct WhileExpr {
3843 pub(crate) syntax: SyntaxNode,
3845 impl AstNode for WhileExpr {
3846 fn can_cast(kind: SyntaxKind) -> bool {
3852 fn cast(syntax: SyntaxNode) -> Option<Self> {
3853 if Self::can_cast(syntax.kind()) {
3854 Some(Self { syntax })
3859 fn syntax(&self) -> &SyntaxNode {
3863 impl ast::LoopBodyOwner for WhileExpr {}
3865 pub fn condition(&self) -> Option<Condition> {
3866 AstChildren::new(&self.syntax).next()