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)]
310 pub struct BreakExpr {
311 pub(crate) syntax: SyntaxNode,
313 impl AstNode for BreakExpr {
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 expr(&self) -> Option<Expr> {
333 AstChildren::new(&self.syntax).next()
336 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
337 pub struct CallExpr {
338 pub(crate) syntax: SyntaxNode,
340 impl AstNode for CallExpr {
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 {
358 impl ast::ArgListOwner for CallExpr {}
360 pub fn expr(&self) -> Option<Expr> {
361 AstChildren::new(&self.syntax).next()
364 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
365 pub struct CastExpr {
366 pub(crate) syntax: SyntaxNode,
368 impl AstNode for CastExpr {
369 fn can_cast(kind: SyntaxKind) -> bool {
375 fn cast(syntax: SyntaxNode) -> Option<Self> {
376 if Self::can_cast(syntax.kind()) {
377 Some(Self { syntax })
382 fn syntax(&self) -> &SyntaxNode {
387 pub fn expr(&self) -> Option<Expr> {
388 AstChildren::new(&self.syntax).next()
390 pub fn type_ref(&self) -> Option<TypeRef> {
391 AstChildren::new(&self.syntax).next()
394 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
395 pub struct Condition {
396 pub(crate) syntax: SyntaxNode,
398 impl AstNode for Condition {
399 fn can_cast(kind: SyntaxKind) -> bool {
405 fn cast(syntax: SyntaxNode) -> Option<Self> {
406 if Self::can_cast(syntax.kind()) {
407 Some(Self { syntax })
412 fn syntax(&self) -> &SyntaxNode {
417 pub fn pat(&self) -> Option<Pat> {
418 AstChildren::new(&self.syntax).next()
420 pub fn expr(&self) -> Option<Expr> {
421 AstChildren::new(&self.syntax).next()
424 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
425 pub struct ConstDef {
426 pub(crate) syntax: SyntaxNode,
428 impl AstNode for ConstDef {
429 fn can_cast(kind: SyntaxKind) -> bool {
435 fn cast(syntax: SyntaxNode) -> Option<Self> {
436 if Self::can_cast(syntax.kind()) {
437 Some(Self { syntax })
442 fn syntax(&self) -> &SyntaxNode {
446 impl ast::VisibilityOwner for ConstDef {}
447 impl ast::NameOwner for ConstDef {}
448 impl ast::TypeParamsOwner for ConstDef {}
449 impl ast::AttrsOwner for ConstDef {}
450 impl ast::DocCommentsOwner for ConstDef {}
451 impl ast::TypeAscriptionOwner for ConstDef {}
453 pub fn body(&self) -> Option<Expr> {
454 AstChildren::new(&self.syntax).next()
457 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
458 pub struct ContinueExpr {
459 pub(crate) syntax: SyntaxNode,
461 impl AstNode for ContinueExpr {
462 fn can_cast(kind: SyntaxKind) -> bool {
464 CONTINUE_EXPR => true,
468 fn cast(syntax: SyntaxNode) -> Option<Self> {
469 if Self::can_cast(syntax.kind()) {
470 Some(Self { syntax })
475 fn syntax(&self) -> &SyntaxNode {
480 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
481 pub struct DynTraitType {
482 pub(crate) syntax: SyntaxNode,
484 impl AstNode for DynTraitType {
485 fn can_cast(kind: SyntaxKind) -> bool {
487 DYN_TRAIT_TYPE => true,
491 fn cast(syntax: SyntaxNode) -> Option<Self> {
492 if Self::can_cast(syntax.kind()) {
493 Some(Self { syntax })
498 fn syntax(&self) -> &SyntaxNode {
502 impl ast::TypeBoundsOwner for DynTraitType {}
504 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
506 pub(crate) syntax: SyntaxNode,
508 impl AstNode for EnumDef {
509 fn can_cast(kind: SyntaxKind) -> bool {
515 fn cast(syntax: SyntaxNode) -> Option<Self> {
516 if Self::can_cast(syntax.kind()) {
517 Some(Self { syntax })
522 fn syntax(&self) -> &SyntaxNode {
526 impl ast::VisibilityOwner for EnumDef {}
527 impl ast::NameOwner for EnumDef {}
528 impl ast::TypeParamsOwner for EnumDef {}
529 impl ast::AttrsOwner for EnumDef {}
530 impl ast::DocCommentsOwner for EnumDef {}
532 pub fn variant_list(&self) -> Option<EnumVariantList> {
533 AstChildren::new(&self.syntax).next()
536 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
537 pub struct EnumVariant {
538 pub(crate) syntax: SyntaxNode,
540 impl AstNode for EnumVariant {
541 fn can_cast(kind: SyntaxKind) -> bool {
543 ENUM_VARIANT => true,
547 fn cast(syntax: SyntaxNode) -> Option<Self> {
548 if Self::can_cast(syntax.kind()) {
549 Some(Self { syntax })
554 fn syntax(&self) -> &SyntaxNode {
558 impl ast::NameOwner for EnumVariant {}
559 impl ast::DocCommentsOwner for EnumVariant {}
560 impl ast::AttrsOwner for EnumVariant {}
562 pub fn expr(&self) -> Option<Expr> {
563 AstChildren::new(&self.syntax).next()
566 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
567 pub struct EnumVariantList {
568 pub(crate) syntax: SyntaxNode,
570 impl AstNode for EnumVariantList {
571 fn can_cast(kind: SyntaxKind) -> bool {
573 ENUM_VARIANT_LIST => true,
577 fn cast(syntax: SyntaxNode) -> Option<Self> {
578 if Self::can_cast(syntax.kind()) {
579 Some(Self { syntax })
584 fn syntax(&self) -> &SyntaxNode {
588 impl EnumVariantList {
589 pub fn variants(&self) -> AstChildren<EnumVariant> {
590 AstChildren::new(&self.syntax)
593 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
595 TupleExpr(TupleExpr),
596 ArrayExpr(ArrayExpr),
597 ParenExpr(ParenExpr),
599 LambdaExpr(LambdaExpr),
603 WhileExpr(WhileExpr),
604 ContinueExpr(ContinueExpr),
605 BreakExpr(BreakExpr),
607 BlockExpr(BlockExpr),
608 ReturnExpr(ReturnExpr),
609 MatchExpr(MatchExpr),
610 StructLit(StructLit),
612 IndexExpr(IndexExpr),
613 MethodCallExpr(MethodCallExpr),
614 FieldExpr(FieldExpr),
615 AwaitExpr(AwaitExpr),
617 TryBlockExpr(TryBlockExpr),
620 PrefixExpr(PrefixExpr),
621 RangeExpr(RangeExpr),
624 MacroCall(MacroCall),
626 impl From<TupleExpr> for Expr {
627 fn from(node: TupleExpr) -> Expr {
628 Expr::TupleExpr(node)
631 impl From<ArrayExpr> for Expr {
632 fn from(node: ArrayExpr) -> Expr {
633 Expr::ArrayExpr(node)
636 impl From<ParenExpr> for Expr {
637 fn from(node: ParenExpr) -> Expr {
638 Expr::ParenExpr(node)
641 impl From<PathExpr> for Expr {
642 fn from(node: PathExpr) -> Expr {
646 impl From<LambdaExpr> for Expr {
647 fn from(node: LambdaExpr) -> Expr {
648 Expr::LambdaExpr(node)
651 impl From<IfExpr> for Expr {
652 fn from(node: IfExpr) -> Expr {
656 impl From<LoopExpr> for Expr {
657 fn from(node: LoopExpr) -> Expr {
661 impl From<ForExpr> for Expr {
662 fn from(node: ForExpr) -> Expr {
666 impl From<WhileExpr> for Expr {
667 fn from(node: WhileExpr) -> Expr {
668 Expr::WhileExpr(node)
671 impl From<ContinueExpr> for Expr {
672 fn from(node: ContinueExpr) -> Expr {
673 Expr::ContinueExpr(node)
676 impl From<BreakExpr> for Expr {
677 fn from(node: BreakExpr) -> Expr {
678 Expr::BreakExpr(node)
681 impl From<Label> for Expr {
682 fn from(node: Label) -> Expr {
686 impl From<BlockExpr> for Expr {
687 fn from(node: BlockExpr) -> Expr {
688 Expr::BlockExpr(node)
691 impl From<ReturnExpr> for Expr {
692 fn from(node: ReturnExpr) -> Expr {
693 Expr::ReturnExpr(node)
696 impl From<MatchExpr> for Expr {
697 fn from(node: MatchExpr) -> Expr {
698 Expr::MatchExpr(node)
701 impl From<StructLit> for Expr {
702 fn from(node: StructLit) -> Expr {
703 Expr::StructLit(node)
706 impl From<CallExpr> for Expr {
707 fn from(node: CallExpr) -> Expr {
711 impl From<IndexExpr> for Expr {
712 fn from(node: IndexExpr) -> Expr {
713 Expr::IndexExpr(node)
716 impl From<MethodCallExpr> for Expr {
717 fn from(node: MethodCallExpr) -> Expr {
718 Expr::MethodCallExpr(node)
721 impl From<FieldExpr> for Expr {
722 fn from(node: FieldExpr) -> Expr {
723 Expr::FieldExpr(node)
726 impl From<AwaitExpr> for Expr {
727 fn from(node: AwaitExpr) -> Expr {
728 Expr::AwaitExpr(node)
731 impl From<TryExpr> for Expr {
732 fn from(node: TryExpr) -> Expr {
736 impl From<TryBlockExpr> for Expr {
737 fn from(node: TryBlockExpr) -> Expr {
738 Expr::TryBlockExpr(node)
741 impl From<CastExpr> for Expr {
742 fn from(node: CastExpr) -> Expr {
746 impl From<RefExpr> for Expr {
747 fn from(node: RefExpr) -> Expr {
751 impl From<PrefixExpr> for Expr {
752 fn from(node: PrefixExpr) -> Expr {
753 Expr::PrefixExpr(node)
756 impl From<RangeExpr> for Expr {
757 fn from(node: RangeExpr) -> Expr {
758 Expr::RangeExpr(node)
761 impl From<BinExpr> for Expr {
762 fn from(node: BinExpr) -> Expr {
766 impl From<Literal> for Expr {
767 fn from(node: Literal) -> Expr {
771 impl From<MacroCall> for Expr {
772 fn from(node: MacroCall) -> Expr {
773 Expr::MacroCall(node)
776 impl AstNode for Expr {
777 fn can_cast(kind: SyntaxKind) -> bool {
779 TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR
780 | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL
781 | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | STRUCT_LIT | CALL_EXPR | INDEX_EXPR
782 | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR
783 | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL => {
789 fn cast(syntax: SyntaxNode) -> Option<Self> {
790 let res = match syntax.kind() {
791 TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }),
792 ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }),
793 PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }),
794 PATH_EXPR => Expr::PathExpr(PathExpr { syntax }),
795 LAMBDA_EXPR => Expr::LambdaExpr(LambdaExpr { syntax }),
796 IF_EXPR => Expr::IfExpr(IfExpr { syntax }),
797 LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }),
798 FOR_EXPR => Expr::ForExpr(ForExpr { syntax }),
799 WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }),
800 CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }),
801 BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }),
802 LABEL => Expr::Label(Label { syntax }),
803 BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
804 RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }),
805 MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
806 STRUCT_LIT => Expr::StructLit(StructLit { syntax }),
807 CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
808 INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
809 METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
810 FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }),
811 AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }),
812 TRY_EXPR => Expr::TryExpr(TryExpr { syntax }),
813 TRY_BLOCK_EXPR => Expr::TryBlockExpr(TryBlockExpr { syntax }),
814 CAST_EXPR => Expr::CastExpr(CastExpr { syntax }),
815 REF_EXPR => Expr::RefExpr(RefExpr { syntax }),
816 PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }),
817 RANGE_EXPR => Expr::RangeExpr(RangeExpr { syntax }),
818 BIN_EXPR => Expr::BinExpr(BinExpr { syntax }),
819 LITERAL => Expr::Literal(Literal { syntax }),
820 MACRO_CALL => Expr::MacroCall(MacroCall { syntax }),
825 fn syntax(&self) -> &SyntaxNode {
827 Expr::TupleExpr(it) => &it.syntax,
828 Expr::ArrayExpr(it) => &it.syntax,
829 Expr::ParenExpr(it) => &it.syntax,
830 Expr::PathExpr(it) => &it.syntax,
831 Expr::LambdaExpr(it) => &it.syntax,
832 Expr::IfExpr(it) => &it.syntax,
833 Expr::LoopExpr(it) => &it.syntax,
834 Expr::ForExpr(it) => &it.syntax,
835 Expr::WhileExpr(it) => &it.syntax,
836 Expr::ContinueExpr(it) => &it.syntax,
837 Expr::BreakExpr(it) => &it.syntax,
838 Expr::Label(it) => &it.syntax,
839 Expr::BlockExpr(it) => &it.syntax,
840 Expr::ReturnExpr(it) => &it.syntax,
841 Expr::MatchExpr(it) => &it.syntax,
842 Expr::StructLit(it) => &it.syntax,
843 Expr::CallExpr(it) => &it.syntax,
844 Expr::IndexExpr(it) => &it.syntax,
845 Expr::MethodCallExpr(it) => &it.syntax,
846 Expr::FieldExpr(it) => &it.syntax,
847 Expr::AwaitExpr(it) => &it.syntax,
848 Expr::TryExpr(it) => &it.syntax,
849 Expr::TryBlockExpr(it) => &it.syntax,
850 Expr::CastExpr(it) => &it.syntax,
851 Expr::RefExpr(it) => &it.syntax,
852 Expr::PrefixExpr(it) => &it.syntax,
853 Expr::RangeExpr(it) => &it.syntax,
854 Expr::BinExpr(it) => &it.syntax,
855 Expr::Literal(it) => &it.syntax,
856 Expr::MacroCall(it) => &it.syntax,
861 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
862 pub struct ExprStmt {
863 pub(crate) syntax: SyntaxNode,
865 impl AstNode for ExprStmt {
866 fn can_cast(kind: SyntaxKind) -> bool {
872 fn cast(syntax: SyntaxNode) -> Option<Self> {
873 if Self::can_cast(syntax.kind()) {
874 Some(Self { syntax })
879 fn syntax(&self) -> &SyntaxNode {
884 pub fn expr(&self) -> Option<Expr> {
885 AstChildren::new(&self.syntax).next()
888 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
889 pub struct ExternCrateItem {
890 pub(crate) syntax: SyntaxNode,
892 impl AstNode for ExternCrateItem {
893 fn can_cast(kind: SyntaxKind) -> bool {
895 EXTERN_CRATE_ITEM => true,
899 fn cast(syntax: SyntaxNode) -> Option<Self> {
900 if Self::can_cast(syntax.kind()) {
901 Some(Self { syntax })
906 fn syntax(&self) -> &SyntaxNode {
910 impl ExternCrateItem {
911 pub fn name_ref(&self) -> Option<NameRef> {
912 AstChildren::new(&self.syntax).next()
914 pub fn alias(&self) -> Option<Alias> {
915 AstChildren::new(&self.syntax).next()
918 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
919 pub struct FieldExpr {
920 pub(crate) syntax: SyntaxNode,
922 impl AstNode for FieldExpr {
923 fn can_cast(kind: SyntaxKind) -> bool {
929 fn cast(syntax: SyntaxNode) -> Option<Self> {
930 if Self::can_cast(syntax.kind()) {
931 Some(Self { syntax })
936 fn syntax(&self) -> &SyntaxNode {
941 pub fn expr(&self) -> Option<Expr> {
942 AstChildren::new(&self.syntax).next()
944 pub fn name_ref(&self) -> Option<NameRef> {
945 AstChildren::new(&self.syntax).next()
948 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
949 pub struct FieldPat {
950 pub(crate) syntax: SyntaxNode,
952 impl AstNode for FieldPat {
953 fn can_cast(kind: SyntaxKind) -> bool {
959 fn cast(syntax: SyntaxNode) -> Option<Self> {
960 if Self::can_cast(syntax.kind()) {
961 Some(Self { syntax })
966 fn syntax(&self) -> &SyntaxNode {
970 impl ast::NameOwner for FieldPat {}
972 pub fn pat(&self) -> Option<Pat> {
973 AstChildren::new(&self.syntax).next()
976 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
977 pub struct FieldPatList {
978 pub(crate) syntax: SyntaxNode,
980 impl AstNode for FieldPatList {
981 fn can_cast(kind: SyntaxKind) -> bool {
983 FIELD_PAT_LIST => true,
987 fn cast(syntax: SyntaxNode) -> Option<Self> {
988 if Self::can_cast(syntax.kind()) {
989 Some(Self { syntax })
994 fn syntax(&self) -> &SyntaxNode {
999 pub fn field_pats(&self) -> AstChildren<FieldPat> {
1000 AstChildren::new(&self.syntax)
1002 pub fn bind_pats(&self) -> AstChildren<BindPat> {
1003 AstChildren::new(&self.syntax)
1006 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1008 pub(crate) syntax: SyntaxNode,
1010 impl AstNode for FnDef {
1011 fn can_cast(kind: SyntaxKind) -> bool {
1017 fn cast(syntax: SyntaxNode) -> Option<Self> {
1018 if Self::can_cast(syntax.kind()) {
1019 Some(Self { syntax })
1024 fn syntax(&self) -> &SyntaxNode {
1028 impl ast::VisibilityOwner for FnDef {}
1029 impl ast::NameOwner for FnDef {}
1030 impl ast::TypeParamsOwner for FnDef {}
1031 impl ast::AttrsOwner for FnDef {}
1032 impl ast::DocCommentsOwner for FnDef {}
1034 pub fn param_list(&self) -> Option<ParamList> {
1035 AstChildren::new(&self.syntax).next()
1037 pub fn body(&self) -> Option<Block> {
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 FnPointerType {
1046 pub(crate) syntax: SyntaxNode,
1048 impl AstNode for FnPointerType {
1049 fn can_cast(kind: SyntaxKind) -> bool {
1051 FN_POINTER_TYPE => true,
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 FnPointerType {
1067 pub fn param_list(&self) -> Option<ParamList> {
1068 AstChildren::new(&self.syntax).next()
1070 pub fn ret_type(&self) -> Option<RetType> {
1071 AstChildren::new(&self.syntax).next()
1074 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1075 pub struct ForExpr {
1076 pub(crate) syntax: SyntaxNode,
1078 impl AstNode for ForExpr {
1079 fn can_cast(kind: SyntaxKind) -> bool {
1085 fn cast(syntax: SyntaxNode) -> Option<Self> {
1086 if Self::can_cast(syntax.kind()) {
1087 Some(Self { syntax })
1092 fn syntax(&self) -> &SyntaxNode {
1096 impl ast::LoopBodyOwner for ForExpr {}
1098 pub fn pat(&self) -> Option<Pat> {
1099 AstChildren::new(&self.syntax).next()
1101 pub fn iterable(&self) -> Option<Expr> {
1102 AstChildren::new(&self.syntax).next()
1105 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1106 pub struct ForType {
1107 pub(crate) syntax: SyntaxNode,
1109 impl AstNode for ForType {
1110 fn can_cast(kind: SyntaxKind) -> bool {
1116 fn cast(syntax: SyntaxNode) -> Option<Self> {
1117 if Self::can_cast(syntax.kind()) {
1118 Some(Self { syntax })
1123 fn syntax(&self) -> &SyntaxNode {
1128 pub fn type_ref(&self) -> Option<TypeRef> {
1129 AstChildren::new(&self.syntax).next()
1132 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1134 pub(crate) syntax: SyntaxNode,
1136 impl AstNode for IfExpr {
1137 fn can_cast(kind: SyntaxKind) -> bool {
1143 fn cast(syntax: SyntaxNode) -> Option<Self> {
1144 if Self::can_cast(syntax.kind()) {
1145 Some(Self { syntax })
1150 fn syntax(&self) -> &SyntaxNode {
1155 pub fn condition(&self) -> Option<Condition> {
1156 AstChildren::new(&self.syntax).next()
1159 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1160 pub struct ImplBlock {
1161 pub(crate) syntax: SyntaxNode,
1163 impl AstNode for ImplBlock {
1164 fn can_cast(kind: SyntaxKind) -> bool {
1170 fn cast(syntax: SyntaxNode) -> Option<Self> {
1171 if Self::can_cast(syntax.kind()) {
1172 Some(Self { syntax })
1177 fn syntax(&self) -> &SyntaxNode {
1181 impl ast::TypeParamsOwner for ImplBlock {}
1182 impl ast::AttrsOwner for ImplBlock {}
1184 pub fn item_list(&self) -> Option<ItemList> {
1185 AstChildren::new(&self.syntax).next()
1188 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1191 TypeAliasDef(TypeAliasDef),
1194 impl From<FnDef> for ImplItem {
1195 fn from(node: FnDef) -> ImplItem {
1196 ImplItem::FnDef(node)
1199 impl From<TypeAliasDef> for ImplItem {
1200 fn from(node: TypeAliasDef) -> ImplItem {
1201 ImplItem::TypeAliasDef(node)
1204 impl From<ConstDef> for ImplItem {
1205 fn from(node: ConstDef) -> ImplItem {
1206 ImplItem::ConstDef(node)
1209 impl AstNode for ImplItem {
1210 fn can_cast(kind: SyntaxKind) -> bool {
1212 FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true,
1216 fn cast(syntax: SyntaxNode) -> Option<Self> {
1217 let res = match syntax.kind() {
1218 FN_DEF => ImplItem::FnDef(FnDef { syntax }),
1219 TYPE_ALIAS_DEF => ImplItem::TypeAliasDef(TypeAliasDef { syntax }),
1220 CONST_DEF => ImplItem::ConstDef(ConstDef { syntax }),
1225 fn syntax(&self) -> &SyntaxNode {
1227 ImplItem::FnDef(it) => &it.syntax,
1228 ImplItem::TypeAliasDef(it) => &it.syntax,
1229 ImplItem::ConstDef(it) => &it.syntax,
1234 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1235 pub struct ImplTraitType {
1236 pub(crate) syntax: SyntaxNode,
1238 impl AstNode for ImplTraitType {
1239 fn can_cast(kind: SyntaxKind) -> bool {
1241 IMPL_TRAIT_TYPE => true,
1245 fn cast(syntax: SyntaxNode) -> Option<Self> {
1246 if Self::can_cast(syntax.kind()) {
1247 Some(Self { syntax })
1252 fn syntax(&self) -> &SyntaxNode {
1256 impl ast::TypeBoundsOwner for ImplTraitType {}
1257 impl ImplTraitType {}
1258 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1259 pub struct IndexExpr {
1260 pub(crate) syntax: SyntaxNode,
1262 impl AstNode for IndexExpr {
1263 fn can_cast(kind: SyntaxKind) -> bool {
1269 fn cast(syntax: SyntaxNode) -> Option<Self> {
1270 if Self::can_cast(syntax.kind()) {
1271 Some(Self { syntax })
1276 fn syntax(&self) -> &SyntaxNode {
1281 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1282 pub struct ItemList {
1283 pub(crate) syntax: SyntaxNode,
1285 impl AstNode for ItemList {
1286 fn can_cast(kind: SyntaxKind) -> bool {
1292 fn cast(syntax: SyntaxNode) -> Option<Self> {
1293 if Self::can_cast(syntax.kind()) {
1294 Some(Self { syntax })
1299 fn syntax(&self) -> &SyntaxNode {
1303 impl ast::FnDefOwner for ItemList {}
1304 impl ast::ModuleItemOwner for ItemList {}
1306 pub fn impl_items(&self) -> AstChildren<ImplItem> {
1307 AstChildren::new(&self.syntax)
1310 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1312 pub(crate) syntax: SyntaxNode,
1314 impl AstNode for Label {
1315 fn can_cast(kind: SyntaxKind) -> bool {
1321 fn cast(syntax: SyntaxNode) -> Option<Self> {
1322 if Self::can_cast(syntax.kind()) {
1323 Some(Self { syntax })
1328 fn syntax(&self) -> &SyntaxNode {
1333 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1334 pub struct LambdaExpr {
1335 pub(crate) syntax: SyntaxNode,
1337 impl AstNode for LambdaExpr {
1338 fn can_cast(kind: SyntaxKind) -> bool {
1340 LAMBDA_EXPR => true,
1344 fn cast(syntax: SyntaxNode) -> Option<Self> {
1345 if Self::can_cast(syntax.kind()) {
1346 Some(Self { syntax })
1351 fn syntax(&self) -> &SyntaxNode {
1356 pub fn param_list(&self) -> Option<ParamList> {
1357 AstChildren::new(&self.syntax).next()
1359 pub fn body(&self) -> Option<Expr> {
1360 AstChildren::new(&self.syntax).next()
1363 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1364 pub struct LetStmt {
1365 pub(crate) syntax: SyntaxNode,
1367 impl AstNode for LetStmt {
1368 fn can_cast(kind: SyntaxKind) -> bool {
1374 fn cast(syntax: SyntaxNode) -> Option<Self> {
1375 if Self::can_cast(syntax.kind()) {
1376 Some(Self { syntax })
1381 fn syntax(&self) -> &SyntaxNode {
1385 impl ast::TypeAscriptionOwner for LetStmt {}
1387 pub fn pat(&self) -> Option<Pat> {
1388 AstChildren::new(&self.syntax).next()
1390 pub fn initializer(&self) -> Option<Expr> {
1391 AstChildren::new(&self.syntax).next()
1394 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1395 pub struct LifetimeArg {
1396 pub(crate) syntax: SyntaxNode,
1398 impl AstNode for LifetimeArg {
1399 fn can_cast(kind: SyntaxKind) -> bool {
1401 LIFETIME_ARG => true,
1405 fn cast(syntax: SyntaxNode) -> Option<Self> {
1406 if Self::can_cast(syntax.kind()) {
1407 Some(Self { syntax })
1412 fn syntax(&self) -> &SyntaxNode {
1417 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1418 pub struct LifetimeParam {
1419 pub(crate) syntax: SyntaxNode,
1421 impl AstNode for LifetimeParam {
1422 fn can_cast(kind: SyntaxKind) -> bool {
1424 LIFETIME_PARAM => true,
1428 fn cast(syntax: SyntaxNode) -> Option<Self> {
1429 if Self::can_cast(syntax.kind()) {
1430 Some(Self { syntax })
1435 fn syntax(&self) -> &SyntaxNode {
1439 impl ast::AttrsOwner for LifetimeParam {}
1440 impl LifetimeParam {}
1441 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1442 pub struct Literal {
1443 pub(crate) syntax: SyntaxNode,
1445 impl AstNode for Literal {
1446 fn can_cast(kind: SyntaxKind) -> bool {
1452 fn cast(syntax: SyntaxNode) -> Option<Self> {
1453 if Self::can_cast(syntax.kind()) {
1454 Some(Self { syntax })
1459 fn syntax(&self) -> &SyntaxNode {
1464 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1465 pub struct LiteralPat {
1466 pub(crate) syntax: SyntaxNode,
1468 impl AstNode for LiteralPat {
1469 fn can_cast(kind: SyntaxKind) -> bool {
1471 LITERAL_PAT => true,
1475 fn cast(syntax: SyntaxNode) -> Option<Self> {
1476 if Self::can_cast(syntax.kind()) {
1477 Some(Self { syntax })
1482 fn syntax(&self) -> &SyntaxNode {
1487 pub fn literal(&self) -> Option<Literal> {
1488 AstChildren::new(&self.syntax).next()
1491 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1492 pub struct LoopExpr {
1493 pub(crate) syntax: SyntaxNode,
1495 impl AstNode for LoopExpr {
1496 fn can_cast(kind: SyntaxKind) -> bool {
1502 fn cast(syntax: SyntaxNode) -> Option<Self> {
1503 if Self::can_cast(syntax.kind()) {
1504 Some(Self { syntax })
1509 fn syntax(&self) -> &SyntaxNode {
1513 impl ast::LoopBodyOwner for LoopExpr {}
1515 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1516 pub struct MacroCall {
1517 pub(crate) syntax: SyntaxNode,
1519 impl AstNode for MacroCall {
1520 fn can_cast(kind: SyntaxKind) -> bool {
1526 fn cast(syntax: SyntaxNode) -> Option<Self> {
1527 if Self::can_cast(syntax.kind()) {
1528 Some(Self { syntax })
1533 fn syntax(&self) -> &SyntaxNode {
1537 impl ast::NameOwner for MacroCall {}
1538 impl ast::AttrsOwner for MacroCall {}
1539 impl ast::DocCommentsOwner for MacroCall {}
1541 pub fn token_tree(&self) -> Option<TokenTree> {
1542 AstChildren::new(&self.syntax).next()
1544 pub fn path(&self) -> Option<Path> {
1545 AstChildren::new(&self.syntax).next()
1548 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1549 pub struct MacroItems {
1550 pub(crate) syntax: SyntaxNode,
1552 impl AstNode for MacroItems {
1553 fn can_cast(kind: SyntaxKind) -> bool {
1555 MACRO_ITEMS => true,
1559 fn cast(syntax: SyntaxNode) -> Option<Self> {
1560 if Self::can_cast(syntax.kind()) {
1561 Some(Self { syntax })
1566 fn syntax(&self) -> &SyntaxNode {
1570 impl ast::ModuleItemOwner for MacroItems {}
1571 impl ast::FnDefOwner for MacroItems {}
1573 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1574 pub struct MacroStmts {
1575 pub(crate) syntax: SyntaxNode,
1577 impl AstNode for MacroStmts {
1578 fn can_cast(kind: SyntaxKind) -> bool {
1580 MACRO_STMTS => true,
1584 fn cast(syntax: SyntaxNode) -> Option<Self> {
1585 if Self::can_cast(syntax.kind()) {
1586 Some(Self { syntax })
1591 fn syntax(&self) -> &SyntaxNode {
1596 pub fn statements(&self) -> AstChildren<Stmt> {
1597 AstChildren::new(&self.syntax)
1599 pub fn expr(&self) -> Option<Expr> {
1600 AstChildren::new(&self.syntax).next()
1603 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1604 pub struct MatchArm {
1605 pub(crate) syntax: SyntaxNode,
1607 impl AstNode for MatchArm {
1608 fn can_cast(kind: SyntaxKind) -> bool {
1614 fn cast(syntax: SyntaxNode) -> Option<Self> {
1615 if Self::can_cast(syntax.kind()) {
1616 Some(Self { syntax })
1621 fn syntax(&self) -> &SyntaxNode {
1625 impl ast::AttrsOwner for MatchArm {}
1627 pub fn pats(&self) -> AstChildren<Pat> {
1628 AstChildren::new(&self.syntax)
1630 pub fn guard(&self) -> Option<MatchGuard> {
1631 AstChildren::new(&self.syntax).next()
1633 pub fn expr(&self) -> Option<Expr> {
1634 AstChildren::new(&self.syntax).next()
1637 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1638 pub struct MatchArmList {
1639 pub(crate) syntax: SyntaxNode,
1641 impl AstNode for MatchArmList {
1642 fn can_cast(kind: SyntaxKind) -> bool {
1644 MATCH_ARM_LIST => true,
1648 fn cast(syntax: SyntaxNode) -> Option<Self> {
1649 if Self::can_cast(syntax.kind()) {
1650 Some(Self { syntax })
1655 fn syntax(&self) -> &SyntaxNode {
1659 impl ast::AttrsOwner for MatchArmList {}
1661 pub fn arms(&self) -> AstChildren<MatchArm> {
1662 AstChildren::new(&self.syntax)
1665 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1666 pub struct MatchExpr {
1667 pub(crate) syntax: SyntaxNode,
1669 impl AstNode for MatchExpr {
1670 fn can_cast(kind: SyntaxKind) -> bool {
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()
1691 pub fn match_arm_list(&self) -> Option<MatchArmList> {
1692 AstChildren::new(&self.syntax).next()
1695 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1696 pub struct MatchGuard {
1697 pub(crate) syntax: SyntaxNode,
1699 impl AstNode for MatchGuard {
1700 fn can_cast(kind: SyntaxKind) -> bool {
1702 MATCH_GUARD => true,
1706 fn cast(syntax: SyntaxNode) -> Option<Self> {
1707 if Self::can_cast(syntax.kind()) {
1708 Some(Self { syntax })
1713 fn syntax(&self) -> &SyntaxNode {
1718 pub fn expr(&self) -> Option<Expr> {
1719 AstChildren::new(&self.syntax).next()
1722 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1723 pub struct MethodCallExpr {
1724 pub(crate) syntax: SyntaxNode,
1726 impl AstNode for MethodCallExpr {
1727 fn can_cast(kind: SyntaxKind) -> bool {
1729 METHOD_CALL_EXPR => true,
1733 fn cast(syntax: SyntaxNode) -> Option<Self> {
1734 if Self::can_cast(syntax.kind()) {
1735 Some(Self { syntax })
1740 fn syntax(&self) -> &SyntaxNode {
1744 impl ast::ArgListOwner for MethodCallExpr {}
1745 impl MethodCallExpr {
1746 pub fn expr(&self) -> Option<Expr> {
1747 AstChildren::new(&self.syntax).next()
1749 pub fn name_ref(&self) -> Option<NameRef> {
1750 AstChildren::new(&self.syntax).next()
1752 pub fn type_arg_list(&self) -> Option<TypeArgList> {
1753 AstChildren::new(&self.syntax).next()
1756 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1758 pub(crate) syntax: SyntaxNode,
1760 impl AstNode for Module {
1761 fn can_cast(kind: SyntaxKind) -> bool {
1767 fn cast(syntax: SyntaxNode) -> Option<Self> {
1768 if Self::can_cast(syntax.kind()) {
1769 Some(Self { syntax })
1774 fn syntax(&self) -> &SyntaxNode {
1778 impl ast::VisibilityOwner for Module {}
1779 impl ast::NameOwner for Module {}
1780 impl ast::AttrsOwner for Module {}
1781 impl ast::DocCommentsOwner for Module {}
1783 pub fn item_list(&self) -> Option<ItemList> {
1784 AstChildren::new(&self.syntax).next()
1787 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1788 pub enum ModuleItem {
1789 StructDef(StructDef),
1793 TypeAliasDef(TypeAliasDef),
1794 ImplBlock(ImplBlock),
1796 ExternCrateItem(ExternCrateItem),
1798 StaticDef(StaticDef),
1801 impl From<StructDef> for ModuleItem {
1802 fn from(node: StructDef) -> ModuleItem {
1803 ModuleItem::StructDef(node)
1806 impl From<EnumDef> for ModuleItem {
1807 fn from(node: EnumDef) -> ModuleItem {
1808 ModuleItem::EnumDef(node)
1811 impl From<FnDef> for ModuleItem {
1812 fn from(node: FnDef) -> ModuleItem {
1813 ModuleItem::FnDef(node)
1816 impl From<TraitDef> for ModuleItem {
1817 fn from(node: TraitDef) -> ModuleItem {
1818 ModuleItem::TraitDef(node)
1821 impl From<TypeAliasDef> for ModuleItem {
1822 fn from(node: TypeAliasDef) -> ModuleItem {
1823 ModuleItem::TypeAliasDef(node)
1826 impl From<ImplBlock> for ModuleItem {
1827 fn from(node: ImplBlock) -> ModuleItem {
1828 ModuleItem::ImplBlock(node)
1831 impl From<UseItem> for ModuleItem {
1832 fn from(node: UseItem) -> ModuleItem {
1833 ModuleItem::UseItem(node)
1836 impl From<ExternCrateItem> for ModuleItem {
1837 fn from(node: ExternCrateItem) -> ModuleItem {
1838 ModuleItem::ExternCrateItem(node)
1841 impl From<ConstDef> for ModuleItem {
1842 fn from(node: ConstDef) -> ModuleItem {
1843 ModuleItem::ConstDef(node)
1846 impl From<StaticDef> for ModuleItem {
1847 fn from(node: StaticDef) -> ModuleItem {
1848 ModuleItem::StaticDef(node)
1851 impl From<Module> for ModuleItem {
1852 fn from(node: Module) -> ModuleItem {
1853 ModuleItem::Module(node)
1856 impl AstNode for ModuleItem {
1857 fn can_cast(kind: SyntaxKind) -> bool {
1859 STRUCT_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_BLOCK | USE_ITEM
1860 | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true,
1864 fn cast(syntax: SyntaxNode) -> Option<Self> {
1865 let res = match syntax.kind() {
1866 STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }),
1867 ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }),
1868 FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
1869 TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
1870 TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
1871 IMPL_BLOCK => ModuleItem::ImplBlock(ImplBlock { syntax }),
1872 USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
1873 EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
1874 CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
1875 STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }),
1876 MODULE => ModuleItem::Module(Module { syntax }),
1881 fn syntax(&self) -> &SyntaxNode {
1883 ModuleItem::StructDef(it) => &it.syntax,
1884 ModuleItem::EnumDef(it) => &it.syntax,
1885 ModuleItem::FnDef(it) => &it.syntax,
1886 ModuleItem::TraitDef(it) => &it.syntax,
1887 ModuleItem::TypeAliasDef(it) => &it.syntax,
1888 ModuleItem::ImplBlock(it) => &it.syntax,
1889 ModuleItem::UseItem(it) => &it.syntax,
1890 ModuleItem::ExternCrateItem(it) => &it.syntax,
1891 ModuleItem::ConstDef(it) => &it.syntax,
1892 ModuleItem::StaticDef(it) => &it.syntax,
1893 ModuleItem::Module(it) => &it.syntax,
1898 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1900 pub(crate) syntax: SyntaxNode,
1902 impl AstNode for Name {
1903 fn can_cast(kind: SyntaxKind) -> bool {
1909 fn cast(syntax: SyntaxNode) -> Option<Self> {
1910 if Self::can_cast(syntax.kind()) {
1911 Some(Self { syntax })
1916 fn syntax(&self) -> &SyntaxNode {
1921 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1922 pub struct NameRef {
1923 pub(crate) syntax: SyntaxNode,
1925 impl AstNode for NameRef {
1926 fn can_cast(kind: SyntaxKind) -> bool {
1932 fn cast(syntax: SyntaxNode) -> Option<Self> {
1933 if Self::can_cast(syntax.kind()) {
1934 Some(Self { syntax })
1939 fn syntax(&self) -> &SyntaxNode {
1944 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1945 pub struct NamedField {
1946 pub(crate) syntax: SyntaxNode,
1948 impl AstNode for NamedField {
1949 fn can_cast(kind: SyntaxKind) -> bool {
1951 NAMED_FIELD => true,
1955 fn cast(syntax: SyntaxNode) -> Option<Self> {
1956 if Self::can_cast(syntax.kind()) {
1957 Some(Self { syntax })
1962 fn syntax(&self) -> &SyntaxNode {
1967 pub fn name_ref(&self) -> Option<NameRef> {
1968 AstChildren::new(&self.syntax).next()
1970 pub fn expr(&self) -> Option<Expr> {
1971 AstChildren::new(&self.syntax).next()
1974 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1975 pub struct NamedFieldDef {
1976 pub(crate) syntax: SyntaxNode,
1978 impl AstNode for NamedFieldDef {
1979 fn can_cast(kind: SyntaxKind) -> bool {
1981 NAMED_FIELD_DEF => true,
1985 fn cast(syntax: SyntaxNode) -> Option<Self> {
1986 if Self::can_cast(syntax.kind()) {
1987 Some(Self { syntax })
1992 fn syntax(&self) -> &SyntaxNode {
1996 impl ast::VisibilityOwner for NamedFieldDef {}
1997 impl ast::NameOwner for NamedFieldDef {}
1998 impl ast::AttrsOwner for NamedFieldDef {}
1999 impl ast::DocCommentsOwner for NamedFieldDef {}
2000 impl ast::TypeAscriptionOwner for NamedFieldDef {}
2001 impl NamedFieldDef {}
2002 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2003 pub struct NamedFieldDefList {
2004 pub(crate) syntax: SyntaxNode,
2006 impl AstNode for NamedFieldDefList {
2007 fn can_cast(kind: SyntaxKind) -> bool {
2009 NAMED_FIELD_DEF_LIST => true,
2013 fn cast(syntax: SyntaxNode) -> Option<Self> {
2014 if Self::can_cast(syntax.kind()) {
2015 Some(Self { syntax })
2020 fn syntax(&self) -> &SyntaxNode {
2024 impl NamedFieldDefList {
2025 pub fn fields(&self) -> AstChildren<NamedFieldDef> {
2026 AstChildren::new(&self.syntax)
2029 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2030 pub struct NamedFieldList {
2031 pub(crate) syntax: SyntaxNode,
2033 impl AstNode for NamedFieldList {
2034 fn can_cast(kind: SyntaxKind) -> bool {
2036 NAMED_FIELD_LIST => true,
2040 fn cast(syntax: SyntaxNode) -> Option<Self> {
2041 if Self::can_cast(syntax.kind()) {
2042 Some(Self { syntax })
2047 fn syntax(&self) -> &SyntaxNode {
2051 impl NamedFieldList {
2052 pub fn fields(&self) -> AstChildren<NamedField> {
2053 AstChildren::new(&self.syntax)
2055 pub fn spread(&self) -> Option<Expr> {
2056 AstChildren::new(&self.syntax).next()
2059 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2060 pub struct NeverType {
2061 pub(crate) syntax: SyntaxNode,
2063 impl AstNode for NeverType {
2064 fn can_cast(kind: SyntaxKind) -> bool {
2070 fn cast(syntax: SyntaxNode) -> Option<Self> {
2071 if Self::can_cast(syntax.kind()) {
2072 Some(Self { syntax })
2077 fn syntax(&self) -> &SyntaxNode {
2082 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2083 pub enum NominalDef {
2084 StructDef(StructDef),
2087 impl From<StructDef> for NominalDef {
2088 fn from(node: StructDef) -> NominalDef {
2089 NominalDef::StructDef(node)
2092 impl From<EnumDef> for NominalDef {
2093 fn from(node: EnumDef) -> NominalDef {
2094 NominalDef::EnumDef(node)
2097 impl AstNode for NominalDef {
2098 fn can_cast(kind: SyntaxKind) -> bool {
2100 STRUCT_DEF | ENUM_DEF => true,
2104 fn cast(syntax: SyntaxNode) -> Option<Self> {
2105 let res = match syntax.kind() {
2106 STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }),
2107 ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }),
2112 fn syntax(&self) -> &SyntaxNode {
2114 NominalDef::StructDef(it) => &it.syntax,
2115 NominalDef::EnumDef(it) => &it.syntax,
2119 impl ast::NameOwner for NominalDef {}
2120 impl ast::TypeParamsOwner for NominalDef {}
2121 impl ast::AttrsOwner for NominalDef {}
2123 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2125 pub(crate) syntax: SyntaxNode,
2127 impl AstNode for Param {
2128 fn can_cast(kind: SyntaxKind) -> bool {
2134 fn cast(syntax: SyntaxNode) -> Option<Self> {
2135 if Self::can_cast(syntax.kind()) {
2136 Some(Self { syntax })
2141 fn syntax(&self) -> &SyntaxNode {
2145 impl ast::TypeAscriptionOwner for Param {}
2146 impl ast::AttrsOwner for Param {}
2148 pub fn pat(&self) -> Option<Pat> {
2149 AstChildren::new(&self.syntax).next()
2152 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2153 pub struct ParamList {
2154 pub(crate) syntax: SyntaxNode,
2156 impl AstNode for ParamList {
2157 fn can_cast(kind: SyntaxKind) -> bool {
2163 fn cast(syntax: SyntaxNode) -> Option<Self> {
2164 if Self::can_cast(syntax.kind()) {
2165 Some(Self { syntax })
2170 fn syntax(&self) -> &SyntaxNode {
2175 pub fn params(&self) -> AstChildren<Param> {
2176 AstChildren::new(&self.syntax)
2178 pub fn self_param(&self) -> Option<SelfParam> {
2179 AstChildren::new(&self.syntax).next()
2182 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2183 pub struct ParenExpr {
2184 pub(crate) syntax: SyntaxNode,
2186 impl AstNode for ParenExpr {
2187 fn can_cast(kind: SyntaxKind) -> bool {
2193 fn cast(syntax: SyntaxNode) -> Option<Self> {
2194 if Self::can_cast(syntax.kind()) {
2195 Some(Self { syntax })
2200 fn syntax(&self) -> &SyntaxNode {
2205 pub fn expr(&self) -> Option<Expr> {
2206 AstChildren::new(&self.syntax).next()
2209 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2210 pub struct ParenType {
2211 pub(crate) syntax: SyntaxNode,
2213 impl AstNode for ParenType {
2214 fn can_cast(kind: SyntaxKind) -> bool {
2220 fn cast(syntax: SyntaxNode) -> Option<Self> {
2221 if Self::can_cast(syntax.kind()) {
2222 Some(Self { syntax })
2227 fn syntax(&self) -> &SyntaxNode {
2232 pub fn type_ref(&self) -> Option<TypeRef> {
2233 AstChildren::new(&self.syntax).next()
2236 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2240 PlaceholderPat(PlaceholderPat),
2242 StructPat(StructPat),
2243 TupleStructPat(TupleStructPat),
2247 LiteralPat(LiteralPat),
2249 impl From<RefPat> for Pat {
2250 fn from(node: RefPat) -> Pat {
2254 impl From<BindPat> for Pat {
2255 fn from(node: BindPat) -> Pat {
2259 impl From<PlaceholderPat> for Pat {
2260 fn from(node: PlaceholderPat) -> Pat {
2261 Pat::PlaceholderPat(node)
2264 impl From<PathPat> for Pat {
2265 fn from(node: PathPat) -> Pat {
2269 impl From<StructPat> for Pat {
2270 fn from(node: StructPat) -> Pat {
2271 Pat::StructPat(node)
2274 impl From<TupleStructPat> for Pat {
2275 fn from(node: TupleStructPat) -> Pat {
2276 Pat::TupleStructPat(node)
2279 impl From<TuplePat> for Pat {
2280 fn from(node: TuplePat) -> Pat {
2284 impl From<SlicePat> for Pat {
2285 fn from(node: SlicePat) -> Pat {
2289 impl From<RangePat> for Pat {
2290 fn from(node: RangePat) -> Pat {
2294 impl From<LiteralPat> for Pat {
2295 fn from(node: LiteralPat) -> Pat {
2296 Pat::LiteralPat(node)
2299 impl AstNode for Pat {
2300 fn can_cast(kind: SyntaxKind) -> bool {
2302 REF_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | STRUCT_PAT | TUPLE_STRUCT_PAT
2303 | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true,
2307 fn cast(syntax: SyntaxNode) -> Option<Self> {
2308 let res = match syntax.kind() {
2309 REF_PAT => Pat::RefPat(RefPat { syntax }),
2310 BIND_PAT => Pat::BindPat(BindPat { syntax }),
2311 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
2312 PATH_PAT => Pat::PathPat(PathPat { syntax }),
2313 STRUCT_PAT => Pat::StructPat(StructPat { syntax }),
2314 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
2315 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
2316 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
2317 RANGE_PAT => Pat::RangePat(RangePat { syntax }),
2318 LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
2323 fn syntax(&self) -> &SyntaxNode {
2325 Pat::RefPat(it) => &it.syntax,
2326 Pat::BindPat(it) => &it.syntax,
2327 Pat::PlaceholderPat(it) => &it.syntax,
2328 Pat::PathPat(it) => &it.syntax,
2329 Pat::StructPat(it) => &it.syntax,
2330 Pat::TupleStructPat(it) => &it.syntax,
2331 Pat::TuplePat(it) => &it.syntax,
2332 Pat::SlicePat(it) => &it.syntax,
2333 Pat::RangePat(it) => &it.syntax,
2334 Pat::LiteralPat(it) => &it.syntax,
2339 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2341 pub(crate) syntax: SyntaxNode,
2343 impl AstNode for Path {
2344 fn can_cast(kind: SyntaxKind) -> bool {
2350 fn cast(syntax: SyntaxNode) -> Option<Self> {
2351 if Self::can_cast(syntax.kind()) {
2352 Some(Self { syntax })
2357 fn syntax(&self) -> &SyntaxNode {
2362 pub fn segment(&self) -> Option<PathSegment> {
2363 AstChildren::new(&self.syntax).next()
2365 pub fn qualifier(&self) -> Option<Path> {
2366 AstChildren::new(&self.syntax).next()
2369 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2370 pub struct PathExpr {
2371 pub(crate) syntax: SyntaxNode,
2373 impl AstNode for PathExpr {
2374 fn can_cast(kind: SyntaxKind) -> bool {
2380 fn cast(syntax: SyntaxNode) -> Option<Self> {
2381 if Self::can_cast(syntax.kind()) {
2382 Some(Self { syntax })
2387 fn syntax(&self) -> &SyntaxNode {
2392 pub fn path(&self) -> Option<Path> {
2393 AstChildren::new(&self.syntax).next()
2396 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2397 pub struct PathPat {
2398 pub(crate) syntax: SyntaxNode,
2400 impl AstNode for PathPat {
2401 fn can_cast(kind: SyntaxKind) -> bool {
2407 fn cast(syntax: SyntaxNode) -> Option<Self> {
2408 if Self::can_cast(syntax.kind()) {
2409 Some(Self { syntax })
2414 fn syntax(&self) -> &SyntaxNode {
2419 pub fn path(&self) -> Option<Path> {
2420 AstChildren::new(&self.syntax).next()
2423 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2424 pub struct PathSegment {
2425 pub(crate) syntax: SyntaxNode,
2427 impl AstNode for PathSegment {
2428 fn can_cast(kind: SyntaxKind) -> bool {
2430 PATH_SEGMENT => true,
2434 fn cast(syntax: SyntaxNode) -> Option<Self> {
2435 if Self::can_cast(syntax.kind()) {
2436 Some(Self { syntax })
2441 fn syntax(&self) -> &SyntaxNode {
2446 pub fn name_ref(&self) -> Option<NameRef> {
2447 AstChildren::new(&self.syntax).next()
2449 pub fn type_arg_list(&self) -> Option<TypeArgList> {
2450 AstChildren::new(&self.syntax).next()
2453 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2454 pub struct PathType {
2455 pub(crate) syntax: SyntaxNode,
2457 impl AstNode for PathType {
2458 fn can_cast(kind: SyntaxKind) -> bool {
2464 fn cast(syntax: SyntaxNode) -> Option<Self> {
2465 if Self::can_cast(syntax.kind()) {
2466 Some(Self { syntax })
2471 fn syntax(&self) -> &SyntaxNode {
2476 pub fn path(&self) -> Option<Path> {
2477 AstChildren::new(&self.syntax).next()
2480 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2481 pub struct PlaceholderPat {
2482 pub(crate) syntax: SyntaxNode,
2484 impl AstNode for PlaceholderPat {
2485 fn can_cast(kind: SyntaxKind) -> bool {
2487 PLACEHOLDER_PAT => true,
2491 fn cast(syntax: SyntaxNode) -> Option<Self> {
2492 if Self::can_cast(syntax.kind()) {
2493 Some(Self { syntax })
2498 fn syntax(&self) -> &SyntaxNode {
2502 impl PlaceholderPat {}
2503 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2504 pub struct PlaceholderType {
2505 pub(crate) syntax: SyntaxNode,
2507 impl AstNode for PlaceholderType {
2508 fn can_cast(kind: SyntaxKind) -> bool {
2510 PLACEHOLDER_TYPE => true,
2514 fn cast(syntax: SyntaxNode) -> Option<Self> {
2515 if Self::can_cast(syntax.kind()) {
2516 Some(Self { syntax })
2521 fn syntax(&self) -> &SyntaxNode {
2525 impl PlaceholderType {}
2526 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2527 pub struct PointerType {
2528 pub(crate) syntax: SyntaxNode,
2530 impl AstNode for PointerType {
2531 fn can_cast(kind: SyntaxKind) -> bool {
2533 POINTER_TYPE => true,
2537 fn cast(syntax: SyntaxNode) -> Option<Self> {
2538 if Self::can_cast(syntax.kind()) {
2539 Some(Self { syntax })
2544 fn syntax(&self) -> &SyntaxNode {
2549 pub fn type_ref(&self) -> Option<TypeRef> {
2550 AstChildren::new(&self.syntax).next()
2553 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2554 pub struct PosFieldDef {
2555 pub(crate) syntax: SyntaxNode,
2557 impl AstNode for PosFieldDef {
2558 fn can_cast(kind: SyntaxKind) -> bool {
2560 POS_FIELD_DEF => 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 ast::VisibilityOwner for PosFieldDef {}
2576 impl ast::AttrsOwner for PosFieldDef {}
2578 pub fn type_ref(&self) -> Option<TypeRef> {
2579 AstChildren::new(&self.syntax).next()
2582 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2583 pub struct PosFieldDefList {
2584 pub(crate) syntax: SyntaxNode,
2586 impl AstNode for PosFieldDefList {
2587 fn can_cast(kind: SyntaxKind) -> bool {
2589 POS_FIELD_DEF_LIST => true,
2593 fn cast(syntax: SyntaxNode) -> Option<Self> {
2594 if Self::can_cast(syntax.kind()) {
2595 Some(Self { syntax })
2600 fn syntax(&self) -> &SyntaxNode {
2604 impl PosFieldDefList {
2605 pub fn fields(&self) -> AstChildren<PosFieldDef> {
2606 AstChildren::new(&self.syntax)
2609 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2610 pub struct PrefixExpr {
2611 pub(crate) syntax: SyntaxNode,
2613 impl AstNode for PrefixExpr {
2614 fn can_cast(kind: SyntaxKind) -> bool {
2616 PREFIX_EXPR => true,
2620 fn cast(syntax: SyntaxNode) -> Option<Self> {
2621 if Self::can_cast(syntax.kind()) {
2622 Some(Self { syntax })
2627 fn syntax(&self) -> &SyntaxNode {
2632 pub fn expr(&self) -> Option<Expr> {
2633 AstChildren::new(&self.syntax).next()
2636 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2637 pub struct RangeExpr {
2638 pub(crate) syntax: SyntaxNode,
2640 impl AstNode for RangeExpr {
2641 fn can_cast(kind: SyntaxKind) -> bool {
2647 fn cast(syntax: SyntaxNode) -> Option<Self> {
2648 if Self::can_cast(syntax.kind()) {
2649 Some(Self { syntax })
2654 fn syntax(&self) -> &SyntaxNode {
2659 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2660 pub struct RangePat {
2661 pub(crate) syntax: SyntaxNode,
2663 impl AstNode for RangePat {
2664 fn can_cast(kind: SyntaxKind) -> bool {
2670 fn cast(syntax: SyntaxNode) -> Option<Self> {
2671 if Self::can_cast(syntax.kind()) {
2672 Some(Self { syntax })
2677 fn syntax(&self) -> &SyntaxNode {
2682 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2683 pub struct RefExpr {
2684 pub(crate) syntax: SyntaxNode,
2686 impl AstNode for RefExpr {
2687 fn can_cast(kind: SyntaxKind) -> bool {
2693 fn cast(syntax: SyntaxNode) -> Option<Self> {
2694 if Self::can_cast(syntax.kind()) {
2695 Some(Self { syntax })
2700 fn syntax(&self) -> &SyntaxNode {
2705 pub fn expr(&self) -> Option<Expr> {
2706 AstChildren::new(&self.syntax).next()
2709 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2711 pub(crate) syntax: SyntaxNode,
2713 impl AstNode for RefPat {
2714 fn can_cast(kind: SyntaxKind) -> bool {
2720 fn cast(syntax: SyntaxNode) -> Option<Self> {
2721 if Self::can_cast(syntax.kind()) {
2722 Some(Self { syntax })
2727 fn syntax(&self) -> &SyntaxNode {
2732 pub fn pat(&self) -> Option<Pat> {
2733 AstChildren::new(&self.syntax).next()
2736 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2737 pub struct ReferenceType {
2738 pub(crate) syntax: SyntaxNode,
2740 impl AstNode for ReferenceType {
2741 fn can_cast(kind: SyntaxKind) -> bool {
2743 REFERENCE_TYPE => true,
2747 fn cast(syntax: SyntaxNode) -> Option<Self> {
2748 if Self::can_cast(syntax.kind()) {
2749 Some(Self { syntax })
2754 fn syntax(&self) -> &SyntaxNode {
2758 impl ReferenceType {
2759 pub fn type_ref(&self) -> Option<TypeRef> {
2760 AstChildren::new(&self.syntax).next()
2763 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2764 pub struct RetType {
2765 pub(crate) syntax: SyntaxNode,
2767 impl AstNode for RetType {
2768 fn can_cast(kind: SyntaxKind) -> bool {
2774 fn cast(syntax: SyntaxNode) -> Option<Self> {
2775 if Self::can_cast(syntax.kind()) {
2776 Some(Self { syntax })
2781 fn syntax(&self) -> &SyntaxNode {
2786 pub fn type_ref(&self) -> Option<TypeRef> {
2787 AstChildren::new(&self.syntax).next()
2790 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2791 pub struct ReturnExpr {
2792 pub(crate) syntax: SyntaxNode,
2794 impl AstNode for ReturnExpr {
2795 fn can_cast(kind: SyntaxKind) -> bool {
2797 RETURN_EXPR => true,
2801 fn cast(syntax: SyntaxNode) -> Option<Self> {
2802 if Self::can_cast(syntax.kind()) {
2803 Some(Self { syntax })
2808 fn syntax(&self) -> &SyntaxNode {
2813 pub fn expr(&self) -> Option<Expr> {
2814 AstChildren::new(&self.syntax).next()
2817 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2818 pub struct SelfParam {
2819 pub(crate) syntax: SyntaxNode,
2821 impl AstNode for SelfParam {
2822 fn can_cast(kind: SyntaxKind) -> bool {
2828 fn cast(syntax: SyntaxNode) -> Option<Self> {
2829 if Self::can_cast(syntax.kind()) {
2830 Some(Self { syntax })
2835 fn syntax(&self) -> &SyntaxNode {
2839 impl ast::TypeAscriptionOwner for SelfParam {}
2840 impl ast::AttrsOwner for SelfParam {}
2842 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2843 pub struct SlicePat {
2844 pub(crate) syntax: SyntaxNode,
2846 impl AstNode for SlicePat {
2847 fn can_cast(kind: SyntaxKind) -> bool {
2853 fn cast(syntax: SyntaxNode) -> Option<Self> {
2854 if Self::can_cast(syntax.kind()) {
2855 Some(Self { syntax })
2860 fn syntax(&self) -> &SyntaxNode {
2865 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2866 pub struct SliceType {
2867 pub(crate) syntax: SyntaxNode,
2869 impl AstNode for SliceType {
2870 fn can_cast(kind: SyntaxKind) -> bool {
2876 fn cast(syntax: SyntaxNode) -> Option<Self> {
2877 if Self::can_cast(syntax.kind()) {
2878 Some(Self { syntax })
2883 fn syntax(&self) -> &SyntaxNode {
2888 pub fn type_ref(&self) -> Option<TypeRef> {
2889 AstChildren::new(&self.syntax).next()
2892 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2893 pub struct SourceFile {
2894 pub(crate) syntax: SyntaxNode,
2896 impl AstNode for SourceFile {
2897 fn can_cast(kind: SyntaxKind) -> bool {
2899 SOURCE_FILE => true,
2903 fn cast(syntax: SyntaxNode) -> Option<Self> {
2904 if Self::can_cast(syntax.kind()) {
2905 Some(Self { syntax })
2910 fn syntax(&self) -> &SyntaxNode {
2914 impl ast::ModuleItemOwner for SourceFile {}
2915 impl ast::FnDefOwner for SourceFile {}
2917 pub fn modules(&self) -> AstChildren<Module> {
2918 AstChildren::new(&self.syntax)
2921 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2922 pub struct StaticDef {
2923 pub(crate) syntax: SyntaxNode,
2925 impl AstNode for StaticDef {
2926 fn can_cast(kind: SyntaxKind) -> bool {
2932 fn cast(syntax: SyntaxNode) -> Option<Self> {
2933 if Self::can_cast(syntax.kind()) {
2934 Some(Self { syntax })
2939 fn syntax(&self) -> &SyntaxNode {
2943 impl ast::VisibilityOwner for StaticDef {}
2944 impl ast::NameOwner for StaticDef {}
2945 impl ast::TypeParamsOwner for StaticDef {}
2946 impl ast::AttrsOwner for StaticDef {}
2947 impl ast::DocCommentsOwner for StaticDef {}
2948 impl ast::TypeAscriptionOwner for StaticDef {}
2950 pub fn body(&self) -> Option<Expr> {
2951 AstChildren::new(&self.syntax).next()
2954 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2959 impl From<ExprStmt> for Stmt {
2960 fn from(node: ExprStmt) -> Stmt {
2961 Stmt::ExprStmt(node)
2964 impl From<LetStmt> for Stmt {
2965 fn from(node: LetStmt) -> Stmt {
2969 impl AstNode for Stmt {
2970 fn can_cast(kind: SyntaxKind) -> bool {
2972 EXPR_STMT | LET_STMT => true,
2976 fn cast(syntax: SyntaxNode) -> Option<Self> {
2977 let res = match syntax.kind() {
2978 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
2979 LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
2984 fn syntax(&self) -> &SyntaxNode {
2986 Stmt::ExprStmt(it) => &it.syntax,
2987 Stmt::LetStmt(it) => &it.syntax,
2992 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2993 pub struct StructDef {
2994 pub(crate) syntax: SyntaxNode,
2996 impl AstNode for StructDef {
2997 fn can_cast(kind: SyntaxKind) -> bool {
3003 fn cast(syntax: SyntaxNode) -> Option<Self> {
3004 if Self::can_cast(syntax.kind()) {
3005 Some(Self { syntax })
3010 fn syntax(&self) -> &SyntaxNode {
3014 impl ast::VisibilityOwner for StructDef {}
3015 impl ast::NameOwner for StructDef {}
3016 impl ast::TypeParamsOwner for StructDef {}
3017 impl ast::AttrsOwner for StructDef {}
3018 impl ast::DocCommentsOwner for StructDef {}
3020 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3021 pub struct StructLit {
3022 pub(crate) syntax: SyntaxNode,
3024 impl AstNode for StructLit {
3025 fn can_cast(kind: SyntaxKind) -> bool {
3031 fn cast(syntax: SyntaxNode) -> Option<Self> {
3032 if Self::can_cast(syntax.kind()) {
3033 Some(Self { syntax })
3038 fn syntax(&self) -> &SyntaxNode {
3043 pub fn path(&self) -> Option<Path> {
3044 AstChildren::new(&self.syntax).next()
3046 pub fn named_field_list(&self) -> Option<NamedFieldList> {
3047 AstChildren::new(&self.syntax).next()
3050 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3051 pub struct StructPat {
3052 pub(crate) syntax: SyntaxNode,
3054 impl AstNode for StructPat {
3055 fn can_cast(kind: SyntaxKind) -> bool {
3061 fn cast(syntax: SyntaxNode) -> Option<Self> {
3062 if Self::can_cast(syntax.kind()) {
3063 Some(Self { syntax })
3068 fn syntax(&self) -> &SyntaxNode {
3073 pub fn field_pat_list(&self) -> Option<FieldPatList> {
3074 AstChildren::new(&self.syntax).next()
3076 pub fn path(&self) -> Option<Path> {
3077 AstChildren::new(&self.syntax).next()
3080 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3081 pub struct TokenTree {
3082 pub(crate) syntax: SyntaxNode,
3084 impl AstNode for TokenTree {
3085 fn can_cast(kind: SyntaxKind) -> bool {
3091 fn cast(syntax: SyntaxNode) -> Option<Self> {
3092 if Self::can_cast(syntax.kind()) {
3093 Some(Self { syntax })
3098 fn syntax(&self) -> &SyntaxNode {
3103 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3104 pub struct TraitDef {
3105 pub(crate) syntax: SyntaxNode,
3107 impl AstNode for TraitDef {
3108 fn can_cast(kind: SyntaxKind) -> bool {
3114 fn cast(syntax: SyntaxNode) -> Option<Self> {
3115 if Self::can_cast(syntax.kind()) {
3116 Some(Self { syntax })
3121 fn syntax(&self) -> &SyntaxNode {
3125 impl ast::VisibilityOwner for TraitDef {}
3126 impl ast::NameOwner for TraitDef {}
3127 impl ast::AttrsOwner for TraitDef {}
3128 impl ast::DocCommentsOwner for TraitDef {}
3129 impl ast::TypeParamsOwner for TraitDef {}
3130 impl ast::TypeBoundsOwner for TraitDef {}
3132 pub fn item_list(&self) -> Option<ItemList> {
3133 AstChildren::new(&self.syntax).next()
3136 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3137 pub struct TryBlockExpr {
3138 pub(crate) syntax: SyntaxNode,
3140 impl AstNode for TryBlockExpr {
3141 fn can_cast(kind: SyntaxKind) -> bool {
3143 TRY_BLOCK_EXPR => true,
3147 fn cast(syntax: SyntaxNode) -> Option<Self> {
3148 if Self::can_cast(syntax.kind()) {
3149 Some(Self { syntax })
3154 fn syntax(&self) -> &SyntaxNode {
3158 impl ast::TryBlockBodyOwner for TryBlockExpr {}
3159 impl TryBlockExpr {}
3160 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3161 pub struct TryExpr {
3162 pub(crate) syntax: SyntaxNode,
3164 impl AstNode for TryExpr {
3165 fn can_cast(kind: SyntaxKind) -> bool {
3171 fn cast(syntax: SyntaxNode) -> Option<Self> {
3172 if Self::can_cast(syntax.kind()) {
3173 Some(Self { syntax })
3178 fn syntax(&self) -> &SyntaxNode {
3183 pub fn expr(&self) -> Option<Expr> {
3184 AstChildren::new(&self.syntax).next()
3187 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3188 pub struct TupleExpr {
3189 pub(crate) syntax: SyntaxNode,
3191 impl AstNode for TupleExpr {
3192 fn can_cast(kind: SyntaxKind) -> bool {
3198 fn cast(syntax: SyntaxNode) -> Option<Self> {
3199 if Self::can_cast(syntax.kind()) {
3200 Some(Self { syntax })
3205 fn syntax(&self) -> &SyntaxNode {
3210 pub fn exprs(&self) -> AstChildren<Expr> {
3211 AstChildren::new(&self.syntax)
3214 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3215 pub struct TuplePat {
3216 pub(crate) syntax: SyntaxNode,
3218 impl AstNode for TuplePat {
3219 fn can_cast(kind: SyntaxKind) -> bool {
3225 fn cast(syntax: SyntaxNode) -> Option<Self> {
3226 if Self::can_cast(syntax.kind()) {
3227 Some(Self { syntax })
3232 fn syntax(&self) -> &SyntaxNode {
3237 pub fn args(&self) -> AstChildren<Pat> {
3238 AstChildren::new(&self.syntax)
3241 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3242 pub struct TupleStructPat {
3243 pub(crate) syntax: SyntaxNode,
3245 impl AstNode for TupleStructPat {
3246 fn can_cast(kind: SyntaxKind) -> bool {
3248 TUPLE_STRUCT_PAT => true,
3252 fn cast(syntax: SyntaxNode) -> Option<Self> {
3253 if Self::can_cast(syntax.kind()) {
3254 Some(Self { syntax })
3259 fn syntax(&self) -> &SyntaxNode {
3263 impl TupleStructPat {
3264 pub fn args(&self) -> AstChildren<Pat> {
3265 AstChildren::new(&self.syntax)
3267 pub fn path(&self) -> Option<Path> {
3268 AstChildren::new(&self.syntax).next()
3271 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3272 pub struct TupleType {
3273 pub(crate) syntax: SyntaxNode,
3275 impl AstNode for TupleType {
3276 fn can_cast(kind: SyntaxKind) -> bool {
3282 fn cast(syntax: SyntaxNode) -> Option<Self> {
3283 if Self::can_cast(syntax.kind()) {
3284 Some(Self { syntax })
3289 fn syntax(&self) -> &SyntaxNode {
3294 pub fn fields(&self) -> AstChildren<TypeRef> {
3295 AstChildren::new(&self.syntax)
3298 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3299 pub struct TypeAliasDef {
3300 pub(crate) syntax: SyntaxNode,
3302 impl AstNode for TypeAliasDef {
3303 fn can_cast(kind: SyntaxKind) -> bool {
3305 TYPE_ALIAS_DEF => true,
3309 fn cast(syntax: SyntaxNode) -> Option<Self> {
3310 if Self::can_cast(syntax.kind()) {
3311 Some(Self { syntax })
3316 fn syntax(&self) -> &SyntaxNode {
3320 impl ast::VisibilityOwner for TypeAliasDef {}
3321 impl ast::NameOwner for TypeAliasDef {}
3322 impl ast::TypeParamsOwner for TypeAliasDef {}
3323 impl ast::AttrsOwner for TypeAliasDef {}
3324 impl ast::DocCommentsOwner for TypeAliasDef {}
3325 impl ast::TypeBoundsOwner for TypeAliasDef {}
3327 pub fn type_ref(&self) -> Option<TypeRef> {
3328 AstChildren::new(&self.syntax).next()
3331 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3332 pub struct TypeArg {
3333 pub(crate) syntax: SyntaxNode,
3335 impl AstNode for TypeArg {
3336 fn can_cast(kind: SyntaxKind) -> bool {
3342 fn cast(syntax: SyntaxNode) -> Option<Self> {
3343 if Self::can_cast(syntax.kind()) {
3344 Some(Self { syntax })
3349 fn syntax(&self) -> &SyntaxNode {
3354 pub fn type_ref(&self) -> Option<TypeRef> {
3355 AstChildren::new(&self.syntax).next()
3358 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3359 pub struct TypeArgList {
3360 pub(crate) syntax: SyntaxNode,
3362 impl AstNode for TypeArgList {
3363 fn can_cast(kind: SyntaxKind) -> bool {
3365 TYPE_ARG_LIST => true,
3369 fn cast(syntax: SyntaxNode) -> Option<Self> {
3370 if Self::can_cast(syntax.kind()) {
3371 Some(Self { syntax })
3376 fn syntax(&self) -> &SyntaxNode {
3381 pub fn type_args(&self) -> AstChildren<TypeArg> {
3382 AstChildren::new(&self.syntax)
3384 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> {
3385 AstChildren::new(&self.syntax)
3387 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> {
3388 AstChildren::new(&self.syntax)
3391 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3392 pub struct TypeBound {
3393 pub(crate) syntax: SyntaxNode,
3395 impl AstNode for TypeBound {
3396 fn can_cast(kind: SyntaxKind) -> bool {
3402 fn cast(syntax: SyntaxNode) -> Option<Self> {
3403 if Self::can_cast(syntax.kind()) {
3404 Some(Self { syntax })
3409 fn syntax(&self) -> &SyntaxNode {
3414 pub fn type_ref(&self) -> Option<TypeRef> {
3415 AstChildren::new(&self.syntax).next()
3418 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3419 pub struct TypeBoundList {
3420 pub(crate) syntax: SyntaxNode,
3422 impl AstNode for TypeBoundList {
3423 fn can_cast(kind: SyntaxKind) -> bool {
3425 TYPE_BOUND_LIST => true,
3429 fn cast(syntax: SyntaxNode) -> Option<Self> {
3430 if Self::can_cast(syntax.kind()) {
3431 Some(Self { syntax })
3436 fn syntax(&self) -> &SyntaxNode {
3440 impl TypeBoundList {
3441 pub fn bounds(&self) -> AstChildren<TypeBound> {
3442 AstChildren::new(&self.syntax)
3445 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3446 pub struct TypeParam {
3447 pub(crate) syntax: SyntaxNode,
3449 impl AstNode for TypeParam {
3450 fn can_cast(kind: SyntaxKind) -> bool {
3456 fn cast(syntax: SyntaxNode) -> Option<Self> {
3457 if Self::can_cast(syntax.kind()) {
3458 Some(Self { syntax })
3463 fn syntax(&self) -> &SyntaxNode {
3467 impl ast::NameOwner for TypeParam {}
3468 impl ast::AttrsOwner for TypeParam {}
3469 impl ast::TypeBoundsOwner for TypeParam {}
3470 impl ast::DefaultTypeParamOwner for TypeParam {}
3472 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3473 pub struct TypeParamList {
3474 pub(crate) syntax: SyntaxNode,
3476 impl AstNode for TypeParamList {
3477 fn can_cast(kind: SyntaxKind) -> bool {
3479 TYPE_PARAM_LIST => true,
3483 fn cast(syntax: SyntaxNode) -> Option<Self> {
3484 if Self::can_cast(syntax.kind()) {
3485 Some(Self { syntax })
3490 fn syntax(&self) -> &SyntaxNode {
3494 impl TypeParamList {
3495 pub fn type_params(&self) -> AstChildren<TypeParam> {
3496 AstChildren::new(&self.syntax)
3498 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> {
3499 AstChildren::new(&self.syntax)
3502 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3504 ParenType(ParenType),
3505 TupleType(TupleType),
3506 NeverType(NeverType),
3508 PointerType(PointerType),
3509 ArrayType(ArrayType),
3510 SliceType(SliceType),
3511 ReferenceType(ReferenceType),
3512 PlaceholderType(PlaceholderType),
3513 FnPointerType(FnPointerType),
3515 ImplTraitType(ImplTraitType),
3516 DynTraitType(DynTraitType),
3518 impl From<ParenType> for TypeRef {
3519 fn from(node: ParenType) -> TypeRef {
3520 TypeRef::ParenType(node)
3523 impl From<TupleType> for TypeRef {
3524 fn from(node: TupleType) -> TypeRef {
3525 TypeRef::TupleType(node)
3528 impl From<NeverType> for TypeRef {
3529 fn from(node: NeverType) -> TypeRef {
3530 TypeRef::NeverType(node)
3533 impl From<PathType> for TypeRef {
3534 fn from(node: PathType) -> TypeRef {
3535 TypeRef::PathType(node)
3538 impl From<PointerType> for TypeRef {
3539 fn from(node: PointerType) -> TypeRef {
3540 TypeRef::PointerType(node)
3543 impl From<ArrayType> for TypeRef {
3544 fn from(node: ArrayType) -> TypeRef {
3545 TypeRef::ArrayType(node)
3548 impl From<SliceType> for TypeRef {
3549 fn from(node: SliceType) -> TypeRef {
3550 TypeRef::SliceType(node)
3553 impl From<ReferenceType> for TypeRef {
3554 fn from(node: ReferenceType) -> TypeRef {
3555 TypeRef::ReferenceType(node)
3558 impl From<PlaceholderType> for TypeRef {
3559 fn from(node: PlaceholderType) -> TypeRef {
3560 TypeRef::PlaceholderType(node)
3563 impl From<FnPointerType> for TypeRef {
3564 fn from(node: FnPointerType) -> TypeRef {
3565 TypeRef::FnPointerType(node)
3568 impl From<ForType> for TypeRef {
3569 fn from(node: ForType) -> TypeRef {
3570 TypeRef::ForType(node)
3573 impl From<ImplTraitType> for TypeRef {
3574 fn from(node: ImplTraitType) -> TypeRef {
3575 TypeRef::ImplTraitType(node)
3578 impl From<DynTraitType> for TypeRef {
3579 fn from(node: DynTraitType) -> TypeRef {
3580 TypeRef::DynTraitType(node)
3583 impl AstNode for TypeRef {
3584 fn can_cast(kind: SyntaxKind) -> bool {
3586 PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
3587 | SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE
3588 | IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
3592 fn cast(syntax: SyntaxNode) -> Option<Self> {
3593 let res = match syntax.kind() {
3594 PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }),
3595 TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }),
3596 NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }),
3597 PATH_TYPE => TypeRef::PathType(PathType { syntax }),
3598 POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }),
3599 ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }),
3600 SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }),
3601 REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }),
3602 PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }),
3603 FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }),
3604 FOR_TYPE => TypeRef::ForType(ForType { syntax }),
3605 IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }),
3606 DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }),
3611 fn syntax(&self) -> &SyntaxNode {
3613 TypeRef::ParenType(it) => &it.syntax,
3614 TypeRef::TupleType(it) => &it.syntax,
3615 TypeRef::NeverType(it) => &it.syntax,
3616 TypeRef::PathType(it) => &it.syntax,
3617 TypeRef::PointerType(it) => &it.syntax,
3618 TypeRef::ArrayType(it) => &it.syntax,
3619 TypeRef::SliceType(it) => &it.syntax,
3620 TypeRef::ReferenceType(it) => &it.syntax,
3621 TypeRef::PlaceholderType(it) => &it.syntax,
3622 TypeRef::FnPointerType(it) => &it.syntax,
3623 TypeRef::ForType(it) => &it.syntax,
3624 TypeRef::ImplTraitType(it) => &it.syntax,
3625 TypeRef::DynTraitType(it) => &it.syntax,
3630 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3631 pub struct UseItem {
3632 pub(crate) syntax: SyntaxNode,
3634 impl AstNode for UseItem {
3635 fn can_cast(kind: SyntaxKind) -> bool {
3641 fn cast(syntax: SyntaxNode) -> Option<Self> {
3642 if Self::can_cast(syntax.kind()) {
3643 Some(Self { syntax })
3648 fn syntax(&self) -> &SyntaxNode {
3652 impl ast::AttrsOwner for UseItem {}
3654 pub fn use_tree(&self) -> Option<UseTree> {
3655 AstChildren::new(&self.syntax).next()
3658 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3659 pub struct UseTree {
3660 pub(crate) syntax: SyntaxNode,
3662 impl AstNode for UseTree {
3663 fn can_cast(kind: SyntaxKind) -> bool {
3669 fn cast(syntax: SyntaxNode) -> Option<Self> {
3670 if Self::can_cast(syntax.kind()) {
3671 Some(Self { syntax })
3676 fn syntax(&self) -> &SyntaxNode {
3681 pub fn path(&self) -> Option<Path> {
3682 AstChildren::new(&self.syntax).next()
3684 pub fn use_tree_list(&self) -> Option<UseTreeList> {
3685 AstChildren::new(&self.syntax).next()
3687 pub fn alias(&self) -> Option<Alias> {
3688 AstChildren::new(&self.syntax).next()
3691 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3692 pub struct UseTreeList {
3693 pub(crate) syntax: SyntaxNode,
3695 impl AstNode for UseTreeList {
3696 fn can_cast(kind: SyntaxKind) -> bool {
3698 USE_TREE_LIST => true,
3702 fn cast(syntax: SyntaxNode) -> Option<Self> {
3703 if Self::can_cast(syntax.kind()) {
3704 Some(Self { syntax })
3709 fn syntax(&self) -> &SyntaxNode {
3714 pub fn use_trees(&self) -> AstChildren<UseTree> {
3715 AstChildren::new(&self.syntax)
3718 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3719 pub struct Visibility {
3720 pub(crate) syntax: SyntaxNode,
3722 impl AstNode for Visibility {
3723 fn can_cast(kind: SyntaxKind) -> bool {
3729 fn cast(syntax: SyntaxNode) -> Option<Self> {
3730 if Self::can_cast(syntax.kind()) {
3731 Some(Self { syntax })
3736 fn syntax(&self) -> &SyntaxNode {
3741 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3742 pub struct WhereClause {
3743 pub(crate) syntax: SyntaxNode,
3745 impl AstNode for WhereClause {
3746 fn can_cast(kind: SyntaxKind) -> bool {
3748 WHERE_CLAUSE => true,
3752 fn cast(syntax: SyntaxNode) -> Option<Self> {
3753 if Self::can_cast(syntax.kind()) {
3754 Some(Self { syntax })
3759 fn syntax(&self) -> &SyntaxNode {
3764 pub fn predicates(&self) -> AstChildren<WherePred> {
3765 AstChildren::new(&self.syntax)
3768 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3769 pub struct WherePred {
3770 pub(crate) syntax: SyntaxNode,
3772 impl AstNode for WherePred {
3773 fn can_cast(kind: SyntaxKind) -> bool {
3779 fn cast(syntax: SyntaxNode) -> Option<Self> {
3780 if Self::can_cast(syntax.kind()) {
3781 Some(Self { syntax })
3786 fn syntax(&self) -> &SyntaxNode {
3790 impl ast::TypeBoundsOwner for WherePred {}
3792 pub fn type_ref(&self) -> Option<TypeRef> {
3793 AstChildren::new(&self.syntax).next()
3796 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3797 pub struct WhileExpr {
3798 pub(crate) syntax: SyntaxNode,
3800 impl AstNode for WhileExpr {
3801 fn can_cast(kind: SyntaxKind) -> bool {
3807 fn cast(syntax: SyntaxNode) -> Option<Self> {
3808 if Self::can_cast(syntax.kind()) {
3809 Some(Self { syntax })
3814 fn syntax(&self) -> &SyntaxNode {
3818 impl ast::LoopBodyOwner for WhileExpr {}
3820 pub fn condition(&self) -> Option<Condition> {
3821 AstChildren::new(&self.syntax).next()