1 // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run
2 // Do not edit manually
4 //! This module contains auto-generated Rust AST. Like `SyntaxNode`s, AST nodes
5 //! are generic over ownership: `X<'a>` things are `Copy` references, `XNode`
6 //! are Arc-based. You can switch between the two variants using `.owned` and
7 //! `.borrowed` functions. Most of the code works with borowed mode, and only
8 //! this mode has all AST accessors.
10 #![cfg_attr(rustfmt, rustfmt_skip)]
13 SyntaxNode, SyntaxKind::*,
18 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
20 pub(crate) syntax: SyntaxNode,
23 impl AstNode for Alias {
24 fn cast(syntax: SyntaxNode) -> Option<Self> {
26 ALIAS => Some(Alias { syntax }),
30 fn syntax(&self) -> &SyntaxNode { &self.syntax }
34 impl ast::NameOwner for Alias {}
38 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
40 pub(crate) syntax: SyntaxNode,
43 impl AstNode for ArgList {
44 fn cast(syntax: SyntaxNode) -> Option<Self> {
46 ARG_LIST => Some(ArgList { syntax }),
50 fn syntax(&self) -> &SyntaxNode { &self.syntax }
55 pub fn args(&self) -> impl Iterator<Item = Expr> {
61 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
62 pub struct ArrayExpr {
63 pub(crate) syntax: SyntaxNode,
66 impl AstNode for ArrayExpr {
67 fn cast(syntax: SyntaxNode) -> Option<Self> {
69 ARRAY_EXPR => Some(ArrayExpr { syntax }),
73 fn syntax(&self) -> &SyntaxNode { &self.syntax }
78 pub fn exprs(&self) -> impl Iterator<Item = Expr> {
84 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
85 pub struct ArrayType {
86 pub(crate) syntax: SyntaxNode,
89 impl AstNode for ArrayType {
90 fn cast(syntax: SyntaxNode) -> Option<Self> {
92 ARRAY_TYPE => Some(ArrayType { syntax }),
96 fn syntax(&self) -> &SyntaxNode { &self.syntax }
101 pub fn type_ref(&self) -> Option<TypeRef> {
102 super::child_opt(self)
105 pub fn expr(&self) -> Option<Expr> {
106 super::child_opt(self)
111 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
112 pub struct AssocTypeArg {
113 pub(crate) syntax: SyntaxNode,
116 impl AstNode for AssocTypeArg {
117 fn cast(syntax: SyntaxNode) -> Option<Self> {
118 match syntax.kind() {
119 ASSOC_TYPE_ARG => Some(AssocTypeArg { syntax }),
123 fn syntax(&self) -> &SyntaxNode { &self.syntax }
128 pub fn name_ref(&self) -> Option<NameRef> {
129 super::child_opt(self)
132 pub fn type_ref(&self) -> Option<TypeRef> {
133 super::child_opt(self)
138 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
140 pub(crate) syntax: SyntaxNode,
143 impl AstNode for Attr {
144 fn cast(syntax: SyntaxNode) -> Option<Self> {
145 match syntax.kind() {
146 ATTR => Some(Attr { syntax }),
150 fn syntax(&self) -> &SyntaxNode { &self.syntax }
155 pub fn value(&self) -> Option<TokenTree> {
156 super::child_opt(self)
161 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
163 pub(crate) syntax: SyntaxNode,
166 impl AstNode for BinExpr {
167 fn cast(syntax: SyntaxNode) -> Option<Self> {
168 match syntax.kind() {
169 BIN_EXPR => Some(BinExpr { syntax }),
173 fn syntax(&self) -> &SyntaxNode { &self.syntax }
180 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
182 pub(crate) syntax: SyntaxNode,
185 impl AstNode for BindPat {
186 fn cast(syntax: SyntaxNode) -> Option<Self> {
187 match syntax.kind() {
188 BIND_PAT => Some(BindPat { syntax }),
192 fn syntax(&self) -> &SyntaxNode { &self.syntax }
196 impl ast::NameOwner for BindPat {}
198 pub fn pat(&self) -> Option<Pat> {
199 super::child_opt(self)
204 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
206 pub(crate) syntax: SyntaxNode,
209 impl AstNode for Block {
210 fn cast(syntax: SyntaxNode) -> Option<Self> {
211 match syntax.kind() {
212 BLOCK => Some(Block { syntax }),
216 fn syntax(&self) -> &SyntaxNode { &self.syntax }
220 impl ast::AttrsOwner for Block {}
222 pub fn statements(&self) -> impl Iterator<Item = Stmt> {
223 super::children(self)
226 pub fn expr(&self) -> Option<Expr> {
227 super::child_opt(self)
232 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
233 pub struct BlockExpr {
234 pub(crate) syntax: SyntaxNode,
237 impl AstNode for BlockExpr {
238 fn cast(syntax: SyntaxNode) -> Option<Self> {
239 match syntax.kind() {
240 BLOCK_EXPR => Some(BlockExpr { syntax }),
244 fn syntax(&self) -> &SyntaxNode { &self.syntax }
249 pub fn block(&self) -> Option<Block> {
250 super::child_opt(self)
255 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
256 pub struct BreakExpr {
257 pub(crate) syntax: SyntaxNode,
260 impl AstNode for BreakExpr {
261 fn cast(syntax: SyntaxNode) -> Option<Self> {
262 match syntax.kind() {
263 BREAK_EXPR => Some(BreakExpr { syntax }),
267 fn syntax(&self) -> &SyntaxNode { &self.syntax }
272 pub fn expr(&self) -> Option<Expr> {
273 super::child_opt(self)
278 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
279 pub struct CallExpr {
280 pub(crate) syntax: SyntaxNode,
283 impl AstNode for CallExpr {
284 fn cast(syntax: SyntaxNode) -> Option<Self> {
285 match syntax.kind() {
286 CALL_EXPR => Some(CallExpr { syntax }),
290 fn syntax(&self) -> &SyntaxNode { &self.syntax }
294 impl ast::ArgListOwner for CallExpr {}
296 pub fn expr(&self) -> Option<Expr> {
297 super::child_opt(self)
302 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
303 pub struct CastExpr {
304 pub(crate) syntax: SyntaxNode,
307 impl AstNode for CastExpr {
308 fn cast(syntax: SyntaxNode) -> Option<Self> {
309 match syntax.kind() {
310 CAST_EXPR => Some(CastExpr { syntax }),
314 fn syntax(&self) -> &SyntaxNode { &self.syntax }
319 pub fn expr(&self) -> Option<Expr> {
320 super::child_opt(self)
323 pub fn type_ref(&self) -> Option<TypeRef> {
324 super::child_opt(self)
329 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
330 pub struct Condition {
331 pub(crate) syntax: SyntaxNode,
334 impl AstNode for Condition {
335 fn cast(syntax: SyntaxNode) -> Option<Self> {
336 match syntax.kind() {
337 CONDITION => Some(Condition { syntax }),
341 fn syntax(&self) -> &SyntaxNode { &self.syntax }
346 pub fn pat(&self) -> Option<Pat> {
347 super::child_opt(self)
350 pub fn expr(&self) -> Option<Expr> {
351 super::child_opt(self)
356 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
357 pub struct ConstDef {
358 pub(crate) syntax: SyntaxNode,
361 impl AstNode for ConstDef {
362 fn cast(syntax: SyntaxNode) -> Option<Self> {
363 match syntax.kind() {
364 CONST_DEF => Some(ConstDef { syntax }),
368 fn syntax(&self) -> &SyntaxNode { &self.syntax }
372 impl ast::VisibilityOwner for ConstDef {}
373 impl ast::NameOwner for ConstDef {}
374 impl ast::TypeParamsOwner for ConstDef {}
375 impl ast::AttrsOwner for ConstDef {}
376 impl ast::DocCommentsOwner for ConstDef {}
377 impl ast::TypeAscriptionOwner for ConstDef {}
379 pub fn body(&self) -> Option<Expr> {
380 super::child_opt(self)
385 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
386 pub struct ContinueExpr {
387 pub(crate) syntax: SyntaxNode,
390 impl AstNode for ContinueExpr {
391 fn cast(syntax: SyntaxNode) -> Option<Self> {
392 match syntax.kind() {
393 CONTINUE_EXPR => Some(ContinueExpr { syntax }),
397 fn syntax(&self) -> &SyntaxNode { &self.syntax }
404 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
405 pub struct DynTraitType {
406 pub(crate) syntax: SyntaxNode,
409 impl AstNode for DynTraitType {
410 fn cast(syntax: SyntaxNode) -> Option<Self> {
411 match syntax.kind() {
412 DYN_TRAIT_TYPE => Some(DynTraitType { syntax }),
416 fn syntax(&self) -> &SyntaxNode { &self.syntax }
420 impl ast::TypeBoundsOwner for DynTraitType {}
424 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
426 pub(crate) syntax: SyntaxNode,
429 impl AstNode for EnumDef {
430 fn cast(syntax: SyntaxNode) -> Option<Self> {
431 match syntax.kind() {
432 ENUM_DEF => Some(EnumDef { syntax }),
436 fn syntax(&self) -> &SyntaxNode { &self.syntax }
440 impl ast::VisibilityOwner for EnumDef {}
441 impl ast::NameOwner for EnumDef {}
442 impl ast::TypeParamsOwner for EnumDef {}
443 impl ast::AttrsOwner for EnumDef {}
444 impl ast::DocCommentsOwner for EnumDef {}
446 pub fn variant_list(&self) -> Option<EnumVariantList> {
447 super::child_opt(self)
452 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
453 pub struct EnumVariant {
454 pub(crate) syntax: SyntaxNode,
457 impl AstNode for EnumVariant {
458 fn cast(syntax: SyntaxNode) -> Option<Self> {
459 match syntax.kind() {
460 ENUM_VARIANT => Some(EnumVariant { syntax }),
464 fn syntax(&self) -> &SyntaxNode { &self.syntax }
468 impl ast::NameOwner for EnumVariant {}
469 impl ast::DocCommentsOwner for EnumVariant {}
470 impl ast::AttrsOwner for EnumVariant {}
472 pub fn expr(&self) -> Option<Expr> {
473 super::child_opt(self)
478 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
479 pub struct EnumVariantList {
480 pub(crate) syntax: SyntaxNode,
483 impl AstNode for EnumVariantList {
484 fn cast(syntax: SyntaxNode) -> Option<Self> {
485 match syntax.kind() {
486 ENUM_VARIANT_LIST => Some(EnumVariantList { syntax }),
490 fn syntax(&self) -> &SyntaxNode { &self.syntax }
494 impl EnumVariantList {
495 pub fn variants(&self) -> impl Iterator<Item = EnumVariant> {
496 super::children(self)
501 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
503 pub(crate) syntax: SyntaxNode,
506 #[derive(Debug, Clone, PartialEq, Eq)]
508 TupleExpr(TupleExpr),
509 ArrayExpr(ArrayExpr),
510 ParenExpr(ParenExpr),
512 LambdaExpr(LambdaExpr),
516 WhileExpr(WhileExpr),
517 ContinueExpr(ContinueExpr),
518 BreakExpr(BreakExpr),
520 BlockExpr(BlockExpr),
521 ReturnExpr(ReturnExpr),
522 MatchExpr(MatchExpr),
523 StructLit(StructLit),
525 IndexExpr(IndexExpr),
526 MethodCallExpr(MethodCallExpr),
527 FieldExpr(FieldExpr),
529 TryBlockExpr(TryBlockExpr),
532 PrefixExpr(PrefixExpr),
533 RangeExpr(RangeExpr),
536 MacroCall(MacroCall),
538 impl From<TupleExpr> for Expr {
539 fn from(n: TupleExpr) -> Expr {
540 Expr::cast(n.syntax).unwrap()
543 impl From<ArrayExpr> for Expr {
544 fn from(n: ArrayExpr) -> Expr {
545 Expr::cast(n.syntax).unwrap()
548 impl From<ParenExpr> for Expr {
549 fn from(n: ParenExpr) -> Expr {
550 Expr::cast(n.syntax).unwrap()
553 impl From<PathExpr> for Expr {
554 fn from(n: PathExpr) -> Expr {
555 Expr::cast(n.syntax).unwrap()
558 impl From<LambdaExpr> for Expr {
559 fn from(n: LambdaExpr) -> Expr {
560 Expr::cast(n.syntax).unwrap()
563 impl From<IfExpr> for Expr {
564 fn from(n: IfExpr) -> Expr {
565 Expr::cast(n.syntax).unwrap()
568 impl From<LoopExpr> for Expr {
569 fn from(n: LoopExpr) -> Expr {
570 Expr::cast(n.syntax).unwrap()
573 impl From<ForExpr> for Expr {
574 fn from(n: ForExpr) -> Expr {
575 Expr::cast(n.syntax).unwrap()
578 impl From<WhileExpr> for Expr {
579 fn from(n: WhileExpr) -> Expr {
580 Expr::cast(n.syntax).unwrap()
583 impl From<ContinueExpr> for Expr {
584 fn from(n: ContinueExpr) -> Expr {
585 Expr::cast(n.syntax).unwrap()
588 impl From<BreakExpr> for Expr {
589 fn from(n: BreakExpr) -> Expr {
590 Expr::cast(n.syntax).unwrap()
593 impl From<Label> for Expr {
594 fn from(n: Label) -> Expr {
595 Expr::cast(n.syntax).unwrap()
598 impl From<BlockExpr> for Expr {
599 fn from(n: BlockExpr) -> Expr {
600 Expr::cast(n.syntax).unwrap()
603 impl From<ReturnExpr> for Expr {
604 fn from(n: ReturnExpr) -> Expr {
605 Expr::cast(n.syntax).unwrap()
608 impl From<MatchExpr> for Expr {
609 fn from(n: MatchExpr) -> Expr {
610 Expr::cast(n.syntax).unwrap()
613 impl From<StructLit> for Expr {
614 fn from(n: StructLit) -> Expr {
615 Expr::cast(n.syntax).unwrap()
618 impl From<CallExpr> for Expr {
619 fn from(n: CallExpr) -> Expr {
620 Expr::cast(n.syntax).unwrap()
623 impl From<IndexExpr> for Expr {
624 fn from(n: IndexExpr) -> Expr {
625 Expr::cast(n.syntax).unwrap()
628 impl From<MethodCallExpr> for Expr {
629 fn from(n: MethodCallExpr) -> Expr {
630 Expr::cast(n.syntax).unwrap()
633 impl From<FieldExpr> for Expr {
634 fn from(n: FieldExpr) -> Expr {
635 Expr::cast(n.syntax).unwrap()
638 impl From<TryExpr> for Expr {
639 fn from(n: TryExpr) -> Expr {
640 Expr::cast(n.syntax).unwrap()
643 impl From<TryBlockExpr> for Expr {
644 fn from(n: TryBlockExpr) -> Expr {
645 Expr::cast(n.syntax).unwrap()
648 impl From<CastExpr> for Expr {
649 fn from(n: CastExpr) -> Expr {
650 Expr::cast(n.syntax).unwrap()
653 impl From<RefExpr> for Expr {
654 fn from(n: RefExpr) -> Expr {
655 Expr::cast(n.syntax).unwrap()
658 impl From<PrefixExpr> for Expr {
659 fn from(n: PrefixExpr) -> Expr {
660 Expr::cast(n.syntax).unwrap()
663 impl From<RangeExpr> for Expr {
664 fn from(n: RangeExpr) -> Expr {
665 Expr::cast(n.syntax).unwrap()
668 impl From<BinExpr> for Expr {
669 fn from(n: BinExpr) -> Expr {
670 Expr::cast(n.syntax).unwrap()
673 impl From<Literal> for Expr {
674 fn from(n: Literal) -> Expr {
675 Expr::cast(n.syntax).unwrap()
678 impl From<MacroCall> for Expr {
679 fn from(n: MacroCall) -> Expr {
680 Expr::cast(n.syntax).unwrap()
685 impl AstNode for Expr {
686 fn cast(syntax: SyntaxNode) -> Option<Self> {
687 match syntax.kind() {
716 | MACRO_CALL => Some(Expr { syntax }),
720 fn syntax(&self) -> &SyntaxNode { &self.syntax }
724 pub fn kind(&self) -> ExprKind {
725 match self.syntax.kind() {
726 TUPLE_EXPR => ExprKind::TupleExpr(TupleExpr::cast(self.syntax.clone()).unwrap()),
727 ARRAY_EXPR => ExprKind::ArrayExpr(ArrayExpr::cast(self.syntax.clone()).unwrap()),
728 PAREN_EXPR => ExprKind::ParenExpr(ParenExpr::cast(self.syntax.clone()).unwrap()),
729 PATH_EXPR => ExprKind::PathExpr(PathExpr::cast(self.syntax.clone()).unwrap()),
730 LAMBDA_EXPR => ExprKind::LambdaExpr(LambdaExpr::cast(self.syntax.clone()).unwrap()),
731 IF_EXPR => ExprKind::IfExpr(IfExpr::cast(self.syntax.clone()).unwrap()),
732 LOOP_EXPR => ExprKind::LoopExpr(LoopExpr::cast(self.syntax.clone()).unwrap()),
733 FOR_EXPR => ExprKind::ForExpr(ForExpr::cast(self.syntax.clone()).unwrap()),
734 WHILE_EXPR => ExprKind::WhileExpr(WhileExpr::cast(self.syntax.clone()).unwrap()),
735 CONTINUE_EXPR => ExprKind::ContinueExpr(ContinueExpr::cast(self.syntax.clone()).unwrap()),
736 BREAK_EXPR => ExprKind::BreakExpr(BreakExpr::cast(self.syntax.clone()).unwrap()),
737 LABEL => ExprKind::Label(Label::cast(self.syntax.clone()).unwrap()),
738 BLOCK_EXPR => ExprKind::BlockExpr(BlockExpr::cast(self.syntax.clone()).unwrap()),
739 RETURN_EXPR => ExprKind::ReturnExpr(ReturnExpr::cast(self.syntax.clone()).unwrap()),
740 MATCH_EXPR => ExprKind::MatchExpr(MatchExpr::cast(self.syntax.clone()).unwrap()),
741 STRUCT_LIT => ExprKind::StructLit(StructLit::cast(self.syntax.clone()).unwrap()),
742 CALL_EXPR => ExprKind::CallExpr(CallExpr::cast(self.syntax.clone()).unwrap()),
743 INDEX_EXPR => ExprKind::IndexExpr(IndexExpr::cast(self.syntax.clone()).unwrap()),
744 METHOD_CALL_EXPR => ExprKind::MethodCallExpr(MethodCallExpr::cast(self.syntax.clone()).unwrap()),
745 FIELD_EXPR => ExprKind::FieldExpr(FieldExpr::cast(self.syntax.clone()).unwrap()),
746 TRY_EXPR => ExprKind::TryExpr(TryExpr::cast(self.syntax.clone()).unwrap()),
747 TRY_BLOCK_EXPR => ExprKind::TryBlockExpr(TryBlockExpr::cast(self.syntax.clone()).unwrap()),
748 CAST_EXPR => ExprKind::CastExpr(CastExpr::cast(self.syntax.clone()).unwrap()),
749 REF_EXPR => ExprKind::RefExpr(RefExpr::cast(self.syntax.clone()).unwrap()),
750 PREFIX_EXPR => ExprKind::PrefixExpr(PrefixExpr::cast(self.syntax.clone()).unwrap()),
751 RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(self.syntax.clone()).unwrap()),
752 BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(self.syntax.clone()).unwrap()),
753 LITERAL => ExprKind::Literal(Literal::cast(self.syntax.clone()).unwrap()),
754 MACRO_CALL => ExprKind::MacroCall(MacroCall::cast(self.syntax.clone()).unwrap()),
763 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
764 pub struct ExprStmt {
765 pub(crate) syntax: SyntaxNode,
768 impl AstNode for ExprStmt {
769 fn cast(syntax: SyntaxNode) -> Option<Self> {
770 match syntax.kind() {
771 EXPR_STMT => Some(ExprStmt { syntax }),
775 fn syntax(&self) -> &SyntaxNode { &self.syntax }
780 pub fn expr(&self) -> Option<Expr> {
781 super::child_opt(self)
786 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
787 pub struct ExternCrateItem {
788 pub(crate) syntax: SyntaxNode,
791 impl AstNode for ExternCrateItem {
792 fn cast(syntax: SyntaxNode) -> Option<Self> {
793 match syntax.kind() {
794 EXTERN_CRATE_ITEM => Some(ExternCrateItem { syntax }),
798 fn syntax(&self) -> &SyntaxNode { &self.syntax }
802 impl ExternCrateItem {
803 pub fn name_ref(&self) -> Option<NameRef> {
804 super::child_opt(self)
807 pub fn alias(&self) -> Option<Alias> {
808 super::child_opt(self)
813 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
814 pub struct FieldExpr {
815 pub(crate) syntax: SyntaxNode,
818 impl AstNode for FieldExpr {
819 fn cast(syntax: SyntaxNode) -> Option<Self> {
820 match syntax.kind() {
821 FIELD_EXPR => Some(FieldExpr { syntax }),
825 fn syntax(&self) -> &SyntaxNode { &self.syntax }
830 pub fn expr(&self) -> Option<Expr> {
831 super::child_opt(self)
834 pub fn name_ref(&self) -> Option<NameRef> {
835 super::child_opt(self)
840 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
841 pub struct FieldPat {
842 pub(crate) syntax: SyntaxNode,
845 impl AstNode for FieldPat {
846 fn cast(syntax: SyntaxNode) -> Option<Self> {
847 match syntax.kind() {
848 FIELD_PAT => Some(FieldPat { syntax }),
852 fn syntax(&self) -> &SyntaxNode { &self.syntax }
856 impl ast::NameOwner for FieldPat {}
858 pub fn pat(&self) -> Option<Pat> {
859 super::child_opt(self)
864 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
865 pub struct FieldPatList {
866 pub(crate) syntax: SyntaxNode,
869 impl AstNode for FieldPatList {
870 fn cast(syntax: SyntaxNode) -> Option<Self> {
871 match syntax.kind() {
872 FIELD_PAT_LIST => Some(FieldPatList { syntax }),
876 fn syntax(&self) -> &SyntaxNode { &self.syntax }
881 pub fn field_pats(&self) -> impl Iterator<Item = FieldPat> {
882 super::children(self)
885 pub fn bind_pats(&self) -> impl Iterator<Item = BindPat> {
886 super::children(self)
891 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
893 pub(crate) syntax: SyntaxNode,
896 impl AstNode for FnDef {
897 fn cast(syntax: SyntaxNode) -> Option<Self> {
898 match syntax.kind() {
899 FN_DEF => Some(FnDef { syntax }),
903 fn syntax(&self) -> &SyntaxNode { &self.syntax }
907 impl ast::VisibilityOwner for FnDef {}
908 impl ast::NameOwner for FnDef {}
909 impl ast::TypeParamsOwner for FnDef {}
910 impl ast::AttrsOwner for FnDef {}
911 impl ast::DocCommentsOwner for FnDef {}
913 pub fn param_list(&self) -> Option<ParamList> {
914 super::child_opt(self)
917 pub fn body(&self) -> Option<Block> {
918 super::child_opt(self)
921 pub fn ret_type(&self) -> Option<RetType> {
922 super::child_opt(self)
927 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
928 pub struct FnPointerType {
929 pub(crate) syntax: SyntaxNode,
932 impl AstNode for FnPointerType {
933 fn cast(syntax: SyntaxNode) -> Option<Self> {
934 match syntax.kind() {
935 FN_POINTER_TYPE => Some(FnPointerType { syntax }),
939 fn syntax(&self) -> &SyntaxNode { &self.syntax }
944 pub fn param_list(&self) -> Option<ParamList> {
945 super::child_opt(self)
948 pub fn ret_type(&self) -> Option<RetType> {
949 super::child_opt(self)
954 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
956 pub(crate) syntax: SyntaxNode,
959 impl AstNode for ForExpr {
960 fn cast(syntax: SyntaxNode) -> Option<Self> {
961 match syntax.kind() {
962 FOR_EXPR => Some(ForExpr { syntax }),
966 fn syntax(&self) -> &SyntaxNode { &self.syntax }
970 impl ast::LoopBodyOwner for ForExpr {}
972 pub fn pat(&self) -> Option<Pat> {
973 super::child_opt(self)
976 pub fn iterable(&self) -> Option<Expr> {
977 super::child_opt(self)
982 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
984 pub(crate) syntax: SyntaxNode,
987 impl AstNode for ForType {
988 fn cast(syntax: SyntaxNode) -> Option<Self> {
989 match syntax.kind() {
990 FOR_TYPE => Some(ForType { syntax }),
994 fn syntax(&self) -> &SyntaxNode { &self.syntax }
999 pub fn type_ref(&self) -> Option<TypeRef> {
1000 super::child_opt(self)
1005 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1007 pub(crate) syntax: SyntaxNode,
1010 impl AstNode for IfExpr {
1011 fn cast(syntax: SyntaxNode) -> Option<Self> {
1012 match syntax.kind() {
1013 IF_EXPR => Some(IfExpr { syntax }),
1017 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1022 pub fn condition(&self) -> Option<Condition> {
1023 super::child_opt(self)
1028 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1029 pub struct ImplBlock {
1030 pub(crate) syntax: SyntaxNode,
1033 impl AstNode for ImplBlock {
1034 fn cast(syntax: SyntaxNode) -> Option<Self> {
1035 match syntax.kind() {
1036 IMPL_BLOCK => Some(ImplBlock { syntax }),
1040 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1044 impl ast::TypeParamsOwner for ImplBlock {}
1045 impl ast::AttrsOwner for ImplBlock {}
1047 pub fn item_list(&self) -> Option<ItemList> {
1048 super::child_opt(self)
1053 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1054 pub struct ImplItem {
1055 pub(crate) syntax: SyntaxNode,
1058 #[derive(Debug, Clone, PartialEq, Eq)]
1059 pub enum ImplItemKind {
1061 TypeAliasDef(TypeAliasDef),
1064 impl From<FnDef> for ImplItem {
1065 fn from(n: FnDef) -> ImplItem {
1066 ImplItem::cast(n.syntax).unwrap()
1069 impl From<TypeAliasDef> for ImplItem {
1070 fn from(n: TypeAliasDef) -> ImplItem {
1071 ImplItem::cast(n.syntax).unwrap()
1074 impl From<ConstDef> for ImplItem {
1075 fn from(n: ConstDef) -> ImplItem {
1076 ImplItem::cast(n.syntax).unwrap()
1081 impl AstNode for ImplItem {
1082 fn cast(syntax: SyntaxNode) -> Option<Self> {
1083 match syntax.kind() {
1086 | CONST_DEF => Some(ImplItem { syntax }),
1090 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1094 pub fn kind(&self) -> ImplItemKind {
1095 match self.syntax.kind() {
1096 FN_DEF => ImplItemKind::FnDef(FnDef::cast(self.syntax.clone()).unwrap()),
1097 TYPE_ALIAS_DEF => ImplItemKind::TypeAliasDef(TypeAliasDef::cast(self.syntax.clone()).unwrap()),
1098 CONST_DEF => ImplItemKind::ConstDef(ConstDef::cast(self.syntax.clone()).unwrap()),
1099 _ => unreachable!(),
1107 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1108 pub struct ImplTraitType {
1109 pub(crate) syntax: SyntaxNode,
1112 impl AstNode for ImplTraitType {
1113 fn cast(syntax: SyntaxNode) -> Option<Self> {
1114 match syntax.kind() {
1115 IMPL_TRAIT_TYPE => Some(ImplTraitType { syntax }),
1119 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1123 impl ast::TypeBoundsOwner for ImplTraitType {}
1124 impl ImplTraitType {}
1127 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1128 pub struct IndexExpr {
1129 pub(crate) syntax: SyntaxNode,
1132 impl AstNode for IndexExpr {
1133 fn cast(syntax: SyntaxNode) -> Option<Self> {
1134 match syntax.kind() {
1135 INDEX_EXPR => Some(IndexExpr { syntax }),
1139 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1146 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1147 pub struct ItemList {
1148 pub(crate) syntax: SyntaxNode,
1151 impl AstNode for ItemList {
1152 fn cast(syntax: SyntaxNode) -> Option<Self> {
1153 match syntax.kind() {
1154 ITEM_LIST => Some(ItemList { syntax }),
1158 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1162 impl ast::FnDefOwner for ItemList {}
1163 impl ast::ModuleItemOwner for ItemList {}
1165 pub fn impl_items(&self) -> impl Iterator<Item = ImplItem> {
1166 super::children(self)
1171 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1173 pub(crate) syntax: SyntaxNode,
1176 impl AstNode for Label {
1177 fn cast(syntax: SyntaxNode) -> Option<Self> {
1178 match syntax.kind() {
1179 LABEL => Some(Label { syntax }),
1183 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1190 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1191 pub struct LambdaExpr {
1192 pub(crate) syntax: SyntaxNode,
1195 impl AstNode for LambdaExpr {
1196 fn cast(syntax: SyntaxNode) -> Option<Self> {
1197 match syntax.kind() {
1198 LAMBDA_EXPR => Some(LambdaExpr { syntax }),
1202 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1207 pub fn param_list(&self) -> Option<ParamList> {
1208 super::child_opt(self)
1211 pub fn body(&self) -> Option<Expr> {
1212 super::child_opt(self)
1217 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1218 pub struct LetStmt {
1219 pub(crate) syntax: SyntaxNode,
1222 impl AstNode for LetStmt {
1223 fn cast(syntax: SyntaxNode) -> Option<Self> {
1224 match syntax.kind() {
1225 LET_STMT => Some(LetStmt { syntax }),
1229 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1233 impl ast::TypeAscriptionOwner for LetStmt {}
1235 pub fn pat(&self) -> Option<Pat> {
1236 super::child_opt(self)
1239 pub fn initializer(&self) -> Option<Expr> {
1240 super::child_opt(self)
1245 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1246 pub struct LifetimeArg {
1247 pub(crate) syntax: SyntaxNode,
1250 impl AstNode for LifetimeArg {
1251 fn cast(syntax: SyntaxNode) -> Option<Self> {
1252 match syntax.kind() {
1253 LIFETIME_ARG => Some(LifetimeArg { syntax }),
1257 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1264 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1265 pub struct LifetimeParam {
1266 pub(crate) syntax: SyntaxNode,
1269 impl AstNode for LifetimeParam {
1270 fn cast(syntax: SyntaxNode) -> Option<Self> {
1271 match syntax.kind() {
1272 LIFETIME_PARAM => Some(LifetimeParam { syntax }),
1276 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1280 impl ast::AttrsOwner for LifetimeParam {}
1281 impl LifetimeParam {}
1284 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1285 pub struct Literal {
1286 pub(crate) syntax: SyntaxNode,
1289 impl AstNode for Literal {
1290 fn cast(syntax: SyntaxNode) -> Option<Self> {
1291 match syntax.kind() {
1292 LITERAL => Some(Literal { syntax }),
1296 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1303 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1304 pub struct LiteralPat {
1305 pub(crate) syntax: SyntaxNode,
1308 impl AstNode for LiteralPat {
1309 fn cast(syntax: SyntaxNode) -> Option<Self> {
1310 match syntax.kind() {
1311 LITERAL_PAT => Some(LiteralPat { syntax }),
1315 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1320 pub fn literal(&self) -> Option<Literal> {
1321 super::child_opt(self)
1326 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1327 pub struct LoopExpr {
1328 pub(crate) syntax: SyntaxNode,
1331 impl AstNode for LoopExpr {
1332 fn cast(syntax: SyntaxNode) -> Option<Self> {
1333 match syntax.kind() {
1334 LOOP_EXPR => Some(LoopExpr { syntax }),
1338 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1342 impl ast::LoopBodyOwner for LoopExpr {}
1346 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1347 pub struct MacroCall {
1348 pub(crate) syntax: SyntaxNode,
1351 impl AstNode for MacroCall {
1352 fn cast(syntax: SyntaxNode) -> Option<Self> {
1353 match syntax.kind() {
1354 MACRO_CALL => Some(MacroCall { syntax }),
1358 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1362 impl ast::NameOwner for MacroCall {}
1363 impl ast::AttrsOwner for MacroCall {}
1364 impl ast::DocCommentsOwner for MacroCall {}
1366 pub fn token_tree(&self) -> Option<TokenTree> {
1367 super::child_opt(self)
1370 pub fn path(&self) -> Option<Path> {
1371 super::child_opt(self)
1376 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1377 pub struct MacroItems {
1378 pub(crate) syntax: SyntaxNode,
1381 impl AstNode for MacroItems {
1382 fn cast(syntax: SyntaxNode) -> Option<Self> {
1383 match syntax.kind() {
1384 MACRO_ITEMS => Some(MacroItems { syntax }),
1388 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1392 impl ast::ModuleItemOwner for MacroItems {}
1393 impl ast::FnDefOwner for MacroItems {}
1397 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1398 pub struct MacroStmts {
1399 pub(crate) syntax: SyntaxNode,
1402 impl AstNode for MacroStmts {
1403 fn cast(syntax: SyntaxNode) -> Option<Self> {
1404 match syntax.kind() {
1405 MACRO_STMTS => Some(MacroStmts { syntax }),
1409 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1414 pub fn statements(&self) -> impl Iterator<Item = Stmt> {
1415 super::children(self)
1418 pub fn expr(&self) -> Option<Expr> {
1419 super::child_opt(self)
1424 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1425 pub struct MatchArm {
1426 pub(crate) syntax: SyntaxNode,
1429 impl AstNode for MatchArm {
1430 fn cast(syntax: SyntaxNode) -> Option<Self> {
1431 match syntax.kind() {
1432 MATCH_ARM => Some(MatchArm { syntax }),
1436 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1440 impl ast::AttrsOwner for MatchArm {}
1442 pub fn pats(&self) -> impl Iterator<Item = Pat> {
1443 super::children(self)
1446 pub fn guard(&self) -> Option<MatchGuard> {
1447 super::child_opt(self)
1450 pub fn expr(&self) -> Option<Expr> {
1451 super::child_opt(self)
1456 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1457 pub struct MatchArmList {
1458 pub(crate) syntax: SyntaxNode,
1461 impl AstNode for MatchArmList {
1462 fn cast(syntax: SyntaxNode) -> Option<Self> {
1463 match syntax.kind() {
1464 MATCH_ARM_LIST => Some(MatchArmList { syntax }),
1468 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1472 impl ast::AttrsOwner for MatchArmList {}
1474 pub fn arms(&self) -> impl Iterator<Item = MatchArm> {
1475 super::children(self)
1480 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1481 pub struct MatchExpr {
1482 pub(crate) syntax: SyntaxNode,
1485 impl AstNode for MatchExpr {
1486 fn cast(syntax: SyntaxNode) -> Option<Self> {
1487 match syntax.kind() {
1488 MATCH_EXPR => Some(MatchExpr { syntax }),
1492 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1497 pub fn expr(&self) -> Option<Expr> {
1498 super::child_opt(self)
1501 pub fn match_arm_list(&self) -> Option<MatchArmList> {
1502 super::child_opt(self)
1507 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1508 pub struct MatchGuard {
1509 pub(crate) syntax: SyntaxNode,
1512 impl AstNode for MatchGuard {
1513 fn cast(syntax: SyntaxNode) -> Option<Self> {
1514 match syntax.kind() {
1515 MATCH_GUARD => Some(MatchGuard { syntax }),
1519 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1524 pub fn expr(&self) -> Option<Expr> {
1525 super::child_opt(self)
1530 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1531 pub struct MethodCallExpr {
1532 pub(crate) syntax: SyntaxNode,
1535 impl AstNode for MethodCallExpr {
1536 fn cast(syntax: SyntaxNode) -> Option<Self> {
1537 match syntax.kind() {
1538 METHOD_CALL_EXPR => Some(MethodCallExpr { syntax }),
1542 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1546 impl ast::ArgListOwner for MethodCallExpr {}
1547 impl MethodCallExpr {
1548 pub fn expr(&self) -> Option<Expr> {
1549 super::child_opt(self)
1552 pub fn name_ref(&self) -> Option<NameRef> {
1553 super::child_opt(self)
1556 pub fn type_arg_list(&self) -> Option<TypeArgList> {
1557 super::child_opt(self)
1562 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1564 pub(crate) syntax: SyntaxNode,
1567 impl AstNode for Module {
1568 fn cast(syntax: SyntaxNode) -> Option<Self> {
1569 match syntax.kind() {
1570 MODULE => Some(Module { syntax }),
1574 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1578 impl ast::VisibilityOwner for Module {}
1579 impl ast::NameOwner for Module {}
1580 impl ast::AttrsOwner for Module {}
1581 impl ast::DocCommentsOwner for Module {}
1583 pub fn item_list(&self) -> Option<ItemList> {
1584 super::child_opt(self)
1589 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1590 pub struct ModuleItem {
1591 pub(crate) syntax: SyntaxNode,
1594 #[derive(Debug, Clone, PartialEq, Eq)]
1595 pub enum ModuleItemKind {
1596 StructDef(StructDef),
1600 TypeAliasDef(TypeAliasDef),
1601 ImplBlock(ImplBlock),
1603 ExternCrateItem(ExternCrateItem),
1605 StaticDef(StaticDef),
1608 impl From<StructDef> for ModuleItem {
1609 fn from(n: StructDef) -> ModuleItem {
1610 ModuleItem::cast(n.syntax).unwrap()
1613 impl From<EnumDef> for ModuleItem {
1614 fn from(n: EnumDef) -> ModuleItem {
1615 ModuleItem::cast(n.syntax).unwrap()
1618 impl From<FnDef> for ModuleItem {
1619 fn from(n: FnDef) -> ModuleItem {
1620 ModuleItem::cast(n.syntax).unwrap()
1623 impl From<TraitDef> for ModuleItem {
1624 fn from(n: TraitDef) -> ModuleItem {
1625 ModuleItem::cast(n.syntax).unwrap()
1628 impl From<TypeAliasDef> for ModuleItem {
1629 fn from(n: TypeAliasDef) -> ModuleItem {
1630 ModuleItem::cast(n.syntax).unwrap()
1633 impl From<ImplBlock> for ModuleItem {
1634 fn from(n: ImplBlock) -> ModuleItem {
1635 ModuleItem::cast(n.syntax).unwrap()
1638 impl From<UseItem> for ModuleItem {
1639 fn from(n: UseItem) -> ModuleItem {
1640 ModuleItem::cast(n.syntax).unwrap()
1643 impl From<ExternCrateItem> for ModuleItem {
1644 fn from(n: ExternCrateItem) -> ModuleItem {
1645 ModuleItem::cast(n.syntax).unwrap()
1648 impl From<ConstDef> for ModuleItem {
1649 fn from(n: ConstDef) -> ModuleItem {
1650 ModuleItem::cast(n.syntax).unwrap()
1653 impl From<StaticDef> for ModuleItem {
1654 fn from(n: StaticDef) -> ModuleItem {
1655 ModuleItem::cast(n.syntax).unwrap()
1658 impl From<Module> for ModuleItem {
1659 fn from(n: Module) -> ModuleItem {
1660 ModuleItem::cast(n.syntax).unwrap()
1665 impl AstNode for ModuleItem {
1666 fn cast(syntax: SyntaxNode) -> Option<Self> {
1667 match syntax.kind() {
1678 | MODULE => Some(ModuleItem { syntax }),
1682 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1686 pub fn kind(&self) -> ModuleItemKind {
1687 match self.syntax.kind() {
1688 STRUCT_DEF => ModuleItemKind::StructDef(StructDef::cast(self.syntax.clone()).unwrap()),
1689 ENUM_DEF => ModuleItemKind::EnumDef(EnumDef::cast(self.syntax.clone()).unwrap()),
1690 FN_DEF => ModuleItemKind::FnDef(FnDef::cast(self.syntax.clone()).unwrap()),
1691 TRAIT_DEF => ModuleItemKind::TraitDef(TraitDef::cast(self.syntax.clone()).unwrap()),
1692 TYPE_ALIAS_DEF => ModuleItemKind::TypeAliasDef(TypeAliasDef::cast(self.syntax.clone()).unwrap()),
1693 IMPL_BLOCK => ModuleItemKind::ImplBlock(ImplBlock::cast(self.syntax.clone()).unwrap()),
1694 USE_ITEM => ModuleItemKind::UseItem(UseItem::cast(self.syntax.clone()).unwrap()),
1695 EXTERN_CRATE_ITEM => ModuleItemKind::ExternCrateItem(ExternCrateItem::cast(self.syntax.clone()).unwrap()),
1696 CONST_DEF => ModuleItemKind::ConstDef(ConstDef::cast(self.syntax.clone()).unwrap()),
1697 STATIC_DEF => ModuleItemKind::StaticDef(StaticDef::cast(self.syntax.clone()).unwrap()),
1698 MODULE => ModuleItemKind::Module(Module::cast(self.syntax.clone()).unwrap()),
1699 _ => unreachable!(),
1707 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1709 pub(crate) syntax: SyntaxNode,
1712 impl AstNode for Name {
1713 fn cast(syntax: SyntaxNode) -> Option<Self> {
1714 match syntax.kind() {
1715 NAME => Some(Name { syntax }),
1719 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1726 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1727 pub struct NameRef {
1728 pub(crate) syntax: SyntaxNode,
1731 impl AstNode for NameRef {
1732 fn cast(syntax: SyntaxNode) -> Option<Self> {
1733 match syntax.kind() {
1734 NAME_REF => Some(NameRef { syntax }),
1738 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1745 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1746 pub struct NamedField {
1747 pub(crate) syntax: SyntaxNode,
1750 impl AstNode for NamedField {
1751 fn cast(syntax: SyntaxNode) -> Option<Self> {
1752 match syntax.kind() {
1753 NAMED_FIELD => Some(NamedField { syntax }),
1757 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1762 pub fn name_ref(&self) -> Option<NameRef> {
1763 super::child_opt(self)
1766 pub fn expr(&self) -> Option<Expr> {
1767 super::child_opt(self)
1772 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1773 pub struct NamedFieldDef {
1774 pub(crate) syntax: SyntaxNode,
1777 impl AstNode for NamedFieldDef {
1778 fn cast(syntax: SyntaxNode) -> Option<Self> {
1779 match syntax.kind() {
1780 NAMED_FIELD_DEF => Some(NamedFieldDef { syntax }),
1784 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1788 impl ast::VisibilityOwner for NamedFieldDef {}
1789 impl ast::NameOwner for NamedFieldDef {}
1790 impl ast::AttrsOwner for NamedFieldDef {}
1791 impl ast::DocCommentsOwner for NamedFieldDef {}
1792 impl ast::TypeAscriptionOwner for NamedFieldDef {}
1793 impl NamedFieldDef {}
1795 // NamedFieldDefList
1796 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1797 pub struct NamedFieldDefList {
1798 pub(crate) syntax: SyntaxNode,
1801 impl AstNode for NamedFieldDefList {
1802 fn cast(syntax: SyntaxNode) -> Option<Self> {
1803 match syntax.kind() {
1804 NAMED_FIELD_DEF_LIST => Some(NamedFieldDefList { syntax }),
1808 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1812 impl NamedFieldDefList {
1813 pub fn fields(&self) -> impl Iterator<Item = NamedFieldDef> {
1814 super::children(self)
1819 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1820 pub struct NamedFieldList {
1821 pub(crate) syntax: SyntaxNode,
1824 impl AstNode for NamedFieldList {
1825 fn cast(syntax: SyntaxNode) -> Option<Self> {
1826 match syntax.kind() {
1827 NAMED_FIELD_LIST => Some(NamedFieldList { syntax }),
1831 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1835 impl NamedFieldList {
1836 pub fn fields(&self) -> impl Iterator<Item = NamedField> {
1837 super::children(self)
1840 pub fn spread(&self) -> Option<Expr> {
1841 super::child_opt(self)
1846 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1847 pub struct NeverType {
1848 pub(crate) syntax: SyntaxNode,
1851 impl AstNode for NeverType {
1852 fn cast(syntax: SyntaxNode) -> Option<Self> {
1853 match syntax.kind() {
1854 NEVER_TYPE => Some(NeverType { syntax }),
1858 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1865 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1866 pub struct NominalDef {
1867 pub(crate) syntax: SyntaxNode,
1870 #[derive(Debug, Clone, PartialEq, Eq)]
1871 pub enum NominalDefKind {
1872 StructDef(StructDef),
1875 impl From<StructDef> for NominalDef {
1876 fn from(n: StructDef) -> NominalDef {
1877 NominalDef::cast(n.syntax).unwrap()
1880 impl From<EnumDef> for NominalDef {
1881 fn from(n: EnumDef) -> NominalDef {
1882 NominalDef::cast(n.syntax).unwrap()
1887 impl AstNode for NominalDef {
1888 fn cast(syntax: SyntaxNode) -> Option<Self> {
1889 match syntax.kind() {
1891 | ENUM_DEF => Some(NominalDef { syntax }),
1895 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1899 pub fn kind(&self) -> NominalDefKind {
1900 match self.syntax.kind() {
1901 STRUCT_DEF => NominalDefKind::StructDef(StructDef::cast(self.syntax.clone()).unwrap()),
1902 ENUM_DEF => NominalDefKind::EnumDef(EnumDef::cast(self.syntax.clone()).unwrap()),
1903 _ => unreachable!(),
1908 impl ast::NameOwner for NominalDef {}
1909 impl ast::TypeParamsOwner for NominalDef {}
1910 impl ast::AttrsOwner for NominalDef {}
1914 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1916 pub(crate) syntax: SyntaxNode,
1919 impl AstNode for Param {
1920 fn cast(syntax: SyntaxNode) -> Option<Self> {
1921 match syntax.kind() {
1922 PARAM => Some(Param { syntax }),
1926 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1930 impl ast::TypeAscriptionOwner for Param {}
1932 pub fn pat(&self) -> Option<Pat> {
1933 super::child_opt(self)
1938 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1939 pub struct ParamList {
1940 pub(crate) syntax: SyntaxNode,
1943 impl AstNode for ParamList {
1944 fn cast(syntax: SyntaxNode) -> Option<Self> {
1945 match syntax.kind() {
1946 PARAM_LIST => Some(ParamList { syntax }),
1950 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1955 pub fn params(&self) -> impl Iterator<Item = Param> {
1956 super::children(self)
1959 pub fn self_param(&self) -> Option<SelfParam> {
1960 super::child_opt(self)
1965 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1966 pub struct ParenExpr {
1967 pub(crate) syntax: SyntaxNode,
1970 impl AstNode for ParenExpr {
1971 fn cast(syntax: SyntaxNode) -> Option<Self> {
1972 match syntax.kind() {
1973 PAREN_EXPR => Some(ParenExpr { syntax }),
1977 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1982 pub fn expr(&self) -> Option<Expr> {
1983 super::child_opt(self)
1988 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1989 pub struct ParenType {
1990 pub(crate) syntax: SyntaxNode,
1993 impl AstNode for ParenType {
1994 fn cast(syntax: SyntaxNode) -> Option<Self> {
1995 match syntax.kind() {
1996 PAREN_TYPE => Some(ParenType { syntax }),
2000 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2005 pub fn type_ref(&self) -> Option<TypeRef> {
2006 super::child_opt(self)
2011 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2013 pub(crate) syntax: SyntaxNode,
2016 #[derive(Debug, Clone, PartialEq, Eq)]
2020 PlaceholderPat(PlaceholderPat),
2022 StructPat(StructPat),
2023 TupleStructPat(TupleStructPat),
2027 LiteralPat(LiteralPat),
2029 impl From<RefPat> for Pat {
2030 fn from(n: RefPat) -> Pat {
2031 Pat::cast(n.syntax).unwrap()
2034 impl From<BindPat> for Pat {
2035 fn from(n: BindPat) -> Pat {
2036 Pat::cast(n.syntax).unwrap()
2039 impl From<PlaceholderPat> for Pat {
2040 fn from(n: PlaceholderPat) -> Pat {
2041 Pat::cast(n.syntax).unwrap()
2044 impl From<PathPat> for Pat {
2045 fn from(n: PathPat) -> Pat {
2046 Pat::cast(n.syntax).unwrap()
2049 impl From<StructPat> for Pat {
2050 fn from(n: StructPat) -> Pat {
2051 Pat::cast(n.syntax).unwrap()
2054 impl From<TupleStructPat> for Pat {
2055 fn from(n: TupleStructPat) -> Pat {
2056 Pat::cast(n.syntax).unwrap()
2059 impl From<TuplePat> for Pat {
2060 fn from(n: TuplePat) -> Pat {
2061 Pat::cast(n.syntax).unwrap()
2064 impl From<SlicePat> for Pat {
2065 fn from(n: SlicePat) -> Pat {
2066 Pat::cast(n.syntax).unwrap()
2069 impl From<RangePat> for Pat {
2070 fn from(n: RangePat) -> Pat {
2071 Pat::cast(n.syntax).unwrap()
2074 impl From<LiteralPat> for Pat {
2075 fn from(n: LiteralPat) -> Pat {
2076 Pat::cast(n.syntax).unwrap()
2081 impl AstNode for Pat {
2082 fn cast(syntax: SyntaxNode) -> Option<Self> {
2083 match syntax.kind() {
2093 | LITERAL_PAT => Some(Pat { syntax }),
2097 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2101 pub fn kind(&self) -> PatKind {
2102 match self.syntax.kind() {
2103 REF_PAT => PatKind::RefPat(RefPat::cast(self.syntax.clone()).unwrap()),
2104 BIND_PAT => PatKind::BindPat(BindPat::cast(self.syntax.clone()).unwrap()),
2105 PLACEHOLDER_PAT => PatKind::PlaceholderPat(PlaceholderPat::cast(self.syntax.clone()).unwrap()),
2106 PATH_PAT => PatKind::PathPat(PathPat::cast(self.syntax.clone()).unwrap()),
2107 STRUCT_PAT => PatKind::StructPat(StructPat::cast(self.syntax.clone()).unwrap()),
2108 TUPLE_STRUCT_PAT => PatKind::TupleStructPat(TupleStructPat::cast(self.syntax.clone()).unwrap()),
2109 TUPLE_PAT => PatKind::TuplePat(TuplePat::cast(self.syntax.clone()).unwrap()),
2110 SLICE_PAT => PatKind::SlicePat(SlicePat::cast(self.syntax.clone()).unwrap()),
2111 RANGE_PAT => PatKind::RangePat(RangePat::cast(self.syntax.clone()).unwrap()),
2112 LITERAL_PAT => PatKind::LiteralPat(LiteralPat::cast(self.syntax.clone()).unwrap()),
2113 _ => unreachable!(),
2121 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2123 pub(crate) syntax: SyntaxNode,
2126 impl AstNode for Path {
2127 fn cast(syntax: SyntaxNode) -> Option<Self> {
2128 match syntax.kind() {
2129 PATH => Some(Path { syntax }),
2133 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2138 pub fn segment(&self) -> Option<PathSegment> {
2139 super::child_opt(self)
2142 pub fn qualifier(&self) -> Option<Path> {
2143 super::child_opt(self)
2148 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2149 pub struct PathExpr {
2150 pub(crate) syntax: SyntaxNode,
2153 impl AstNode for PathExpr {
2154 fn cast(syntax: SyntaxNode) -> Option<Self> {
2155 match syntax.kind() {
2156 PATH_EXPR => Some(PathExpr { syntax }),
2160 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2165 pub fn path(&self) -> Option<Path> {
2166 super::child_opt(self)
2171 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2172 pub struct PathPat {
2173 pub(crate) syntax: SyntaxNode,
2176 impl AstNode for PathPat {
2177 fn cast(syntax: SyntaxNode) -> Option<Self> {
2178 match syntax.kind() {
2179 PATH_PAT => Some(PathPat { syntax }),
2183 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2188 pub fn path(&self) -> Option<Path> {
2189 super::child_opt(self)
2194 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2195 pub struct PathSegment {
2196 pub(crate) syntax: SyntaxNode,
2199 impl AstNode for PathSegment {
2200 fn cast(syntax: SyntaxNode) -> Option<Self> {
2201 match syntax.kind() {
2202 PATH_SEGMENT => Some(PathSegment { syntax }),
2206 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2211 pub fn name_ref(&self) -> Option<NameRef> {
2212 super::child_opt(self)
2215 pub fn type_arg_list(&self) -> Option<TypeArgList> {
2216 super::child_opt(self)
2221 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2222 pub struct PathType {
2223 pub(crate) syntax: SyntaxNode,
2226 impl AstNode for PathType {
2227 fn cast(syntax: SyntaxNode) -> Option<Self> {
2228 match syntax.kind() {
2229 PATH_TYPE => Some(PathType { syntax }),
2233 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2238 pub fn path(&self) -> Option<Path> {
2239 super::child_opt(self)
2244 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2245 pub struct PlaceholderPat {
2246 pub(crate) syntax: SyntaxNode,
2249 impl AstNode for PlaceholderPat {
2250 fn cast(syntax: SyntaxNode) -> Option<Self> {
2251 match syntax.kind() {
2252 PLACEHOLDER_PAT => Some(PlaceholderPat { syntax }),
2256 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2260 impl PlaceholderPat {}
2263 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2264 pub struct PlaceholderType {
2265 pub(crate) syntax: SyntaxNode,
2268 impl AstNode for PlaceholderType {
2269 fn cast(syntax: SyntaxNode) -> Option<Self> {
2270 match syntax.kind() {
2271 PLACEHOLDER_TYPE => Some(PlaceholderType { syntax }),
2275 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2279 impl PlaceholderType {}
2282 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2283 pub struct PointerType {
2284 pub(crate) syntax: SyntaxNode,
2287 impl AstNode for PointerType {
2288 fn cast(syntax: SyntaxNode) -> Option<Self> {
2289 match syntax.kind() {
2290 POINTER_TYPE => Some(PointerType { syntax }),
2294 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2299 pub fn type_ref(&self) -> Option<TypeRef> {
2300 super::child_opt(self)
2305 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2306 pub struct PosFieldDef {
2307 pub(crate) syntax: SyntaxNode,
2310 impl AstNode for PosFieldDef {
2311 fn cast(syntax: SyntaxNode) -> Option<Self> {
2312 match syntax.kind() {
2313 POS_FIELD_DEF => Some(PosFieldDef { syntax }),
2317 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2321 impl ast::VisibilityOwner for PosFieldDef {}
2322 impl ast::AttrsOwner for PosFieldDef {}
2324 pub fn type_ref(&self) -> Option<TypeRef> {
2325 super::child_opt(self)
2330 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2331 pub struct PosFieldDefList {
2332 pub(crate) syntax: SyntaxNode,
2335 impl AstNode for PosFieldDefList {
2336 fn cast(syntax: SyntaxNode) -> Option<Self> {
2337 match syntax.kind() {
2338 POS_FIELD_DEF_LIST => Some(PosFieldDefList { syntax }),
2342 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2346 impl PosFieldDefList {
2347 pub fn fields(&self) -> impl Iterator<Item = PosFieldDef> {
2348 super::children(self)
2353 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2354 pub struct PrefixExpr {
2355 pub(crate) syntax: SyntaxNode,
2358 impl AstNode for PrefixExpr {
2359 fn cast(syntax: SyntaxNode) -> Option<Self> {
2360 match syntax.kind() {
2361 PREFIX_EXPR => Some(PrefixExpr { syntax }),
2365 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2370 pub fn expr(&self) -> Option<Expr> {
2371 super::child_opt(self)
2376 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2377 pub struct RangeExpr {
2378 pub(crate) syntax: SyntaxNode,
2381 impl AstNode for RangeExpr {
2382 fn cast(syntax: SyntaxNode) -> Option<Self> {
2383 match syntax.kind() {
2384 RANGE_EXPR => Some(RangeExpr { syntax }),
2388 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2395 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2396 pub struct RangePat {
2397 pub(crate) syntax: SyntaxNode,
2400 impl AstNode for RangePat {
2401 fn cast(syntax: SyntaxNode) -> Option<Self> {
2402 match syntax.kind() {
2403 RANGE_PAT => Some(RangePat { syntax }),
2407 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2414 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2415 pub struct RefExpr {
2416 pub(crate) syntax: SyntaxNode,
2419 impl AstNode for RefExpr {
2420 fn cast(syntax: SyntaxNode) -> Option<Self> {
2421 match syntax.kind() {
2422 REF_EXPR => Some(RefExpr { syntax }),
2426 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2431 pub fn expr(&self) -> Option<Expr> {
2432 super::child_opt(self)
2437 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2439 pub(crate) syntax: SyntaxNode,
2442 impl AstNode for RefPat {
2443 fn cast(syntax: SyntaxNode) -> Option<Self> {
2444 match syntax.kind() {
2445 REF_PAT => Some(RefPat { syntax }),
2449 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2454 pub fn pat(&self) -> Option<Pat> {
2455 super::child_opt(self)
2460 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2461 pub struct ReferenceType {
2462 pub(crate) syntax: SyntaxNode,
2465 impl AstNode for ReferenceType {
2466 fn cast(syntax: SyntaxNode) -> Option<Self> {
2467 match syntax.kind() {
2468 REFERENCE_TYPE => Some(ReferenceType { syntax }),
2472 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2476 impl ReferenceType {
2477 pub fn type_ref(&self) -> Option<TypeRef> {
2478 super::child_opt(self)
2483 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2484 pub struct RetType {
2485 pub(crate) syntax: SyntaxNode,
2488 impl AstNode for RetType {
2489 fn cast(syntax: SyntaxNode) -> Option<Self> {
2490 match syntax.kind() {
2491 RET_TYPE => Some(RetType { syntax }),
2495 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2500 pub fn type_ref(&self) -> Option<TypeRef> {
2501 super::child_opt(self)
2506 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2507 pub struct ReturnExpr {
2508 pub(crate) syntax: SyntaxNode,
2511 impl AstNode for ReturnExpr {
2512 fn cast(syntax: SyntaxNode) -> Option<Self> {
2513 match syntax.kind() {
2514 RETURN_EXPR => Some(ReturnExpr { syntax }),
2518 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2523 pub fn expr(&self) -> Option<Expr> {
2524 super::child_opt(self)
2529 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2530 pub struct SelfParam {
2531 pub(crate) syntax: SyntaxNode,
2534 impl AstNode for SelfParam {
2535 fn cast(syntax: SyntaxNode) -> Option<Self> {
2536 match syntax.kind() {
2537 SELF_PARAM => Some(SelfParam { syntax }),
2541 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2545 impl ast::TypeAscriptionOwner for SelfParam {}
2549 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2550 pub struct SlicePat {
2551 pub(crate) syntax: SyntaxNode,
2554 impl AstNode for SlicePat {
2555 fn cast(syntax: SyntaxNode) -> Option<Self> {
2556 match syntax.kind() {
2557 SLICE_PAT => Some(SlicePat { syntax }),
2561 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2568 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2569 pub struct SliceType {
2570 pub(crate) syntax: SyntaxNode,
2573 impl AstNode for SliceType {
2574 fn cast(syntax: SyntaxNode) -> Option<Self> {
2575 match syntax.kind() {
2576 SLICE_TYPE => Some(SliceType { syntax }),
2580 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2585 pub fn type_ref(&self) -> Option<TypeRef> {
2586 super::child_opt(self)
2591 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2592 pub struct SourceFile {
2593 pub(crate) syntax: SyntaxNode,
2596 impl AstNode for SourceFile {
2597 fn cast(syntax: SyntaxNode) -> Option<Self> {
2598 match syntax.kind() {
2599 SOURCE_FILE => Some(SourceFile { syntax }),
2603 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2607 impl ast::ModuleItemOwner for SourceFile {}
2608 impl ast::FnDefOwner for SourceFile {}
2610 pub fn modules(&self) -> impl Iterator<Item = Module> {
2611 super::children(self)
2616 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2617 pub struct StaticDef {
2618 pub(crate) syntax: SyntaxNode,
2621 impl AstNode for StaticDef {
2622 fn cast(syntax: SyntaxNode) -> Option<Self> {
2623 match syntax.kind() {
2624 STATIC_DEF => Some(StaticDef { syntax }),
2628 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2632 impl ast::VisibilityOwner for StaticDef {}
2633 impl ast::NameOwner for StaticDef {}
2634 impl ast::TypeParamsOwner for StaticDef {}
2635 impl ast::AttrsOwner for StaticDef {}
2636 impl ast::DocCommentsOwner for StaticDef {}
2637 impl ast::TypeAscriptionOwner for StaticDef {}
2639 pub fn body(&self) -> Option<Expr> {
2640 super::child_opt(self)
2645 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2647 pub(crate) syntax: SyntaxNode,
2650 #[derive(Debug, Clone, PartialEq, Eq)]
2655 impl From<ExprStmt> for Stmt {
2656 fn from(n: ExprStmt) -> Stmt {
2657 Stmt::cast(n.syntax).unwrap()
2660 impl From<LetStmt> for Stmt {
2661 fn from(n: LetStmt) -> Stmt {
2662 Stmt::cast(n.syntax).unwrap()
2667 impl AstNode for Stmt {
2668 fn cast(syntax: SyntaxNode) -> Option<Self> {
2669 match syntax.kind() {
2671 | LET_STMT => Some(Stmt { syntax }),
2675 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2679 pub fn kind(&self) -> StmtKind {
2680 match self.syntax.kind() {
2681 EXPR_STMT => StmtKind::ExprStmt(ExprStmt::cast(self.syntax.clone()).unwrap()),
2682 LET_STMT => StmtKind::LetStmt(LetStmt::cast(self.syntax.clone()).unwrap()),
2683 _ => unreachable!(),
2691 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2692 pub struct StructDef {
2693 pub(crate) syntax: SyntaxNode,
2696 impl AstNode for StructDef {
2697 fn cast(syntax: SyntaxNode) -> Option<Self> {
2698 match syntax.kind() {
2699 STRUCT_DEF => Some(StructDef { syntax }),
2703 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2707 impl ast::VisibilityOwner for StructDef {}
2708 impl ast::NameOwner for StructDef {}
2709 impl ast::TypeParamsOwner for StructDef {}
2710 impl ast::AttrsOwner for StructDef {}
2711 impl ast::DocCommentsOwner for StructDef {}
2715 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2716 pub struct StructLit {
2717 pub(crate) syntax: SyntaxNode,
2720 impl AstNode for StructLit {
2721 fn cast(syntax: SyntaxNode) -> Option<Self> {
2722 match syntax.kind() {
2723 STRUCT_LIT => Some(StructLit { syntax }),
2727 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2732 pub fn path(&self) -> Option<Path> {
2733 super::child_opt(self)
2736 pub fn named_field_list(&self) -> Option<NamedFieldList> {
2737 super::child_opt(self)
2742 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2743 pub struct StructPat {
2744 pub(crate) syntax: SyntaxNode,
2747 impl AstNode for StructPat {
2748 fn cast(syntax: SyntaxNode) -> Option<Self> {
2749 match syntax.kind() {
2750 STRUCT_PAT => Some(StructPat { syntax }),
2754 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2759 pub fn field_pat_list(&self) -> Option<FieldPatList> {
2760 super::child_opt(self)
2763 pub fn path(&self) -> Option<Path> {
2764 super::child_opt(self)
2769 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2770 pub struct TokenTree {
2771 pub(crate) syntax: SyntaxNode,
2774 impl AstNode for TokenTree {
2775 fn cast(syntax: SyntaxNode) -> Option<Self> {
2776 match syntax.kind() {
2777 TOKEN_TREE => Some(TokenTree { syntax }),
2781 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2788 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2789 pub struct TraitDef {
2790 pub(crate) syntax: SyntaxNode,
2793 impl AstNode for TraitDef {
2794 fn cast(syntax: SyntaxNode) -> Option<Self> {
2795 match syntax.kind() {
2796 TRAIT_DEF => Some(TraitDef { syntax }),
2800 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2804 impl ast::VisibilityOwner for TraitDef {}
2805 impl ast::NameOwner for TraitDef {}
2806 impl ast::AttrsOwner for TraitDef {}
2807 impl ast::DocCommentsOwner for TraitDef {}
2808 impl ast::TypeParamsOwner for TraitDef {}
2809 impl ast::TypeBoundsOwner for TraitDef {}
2811 pub fn item_list(&self) -> Option<ItemList> {
2812 super::child_opt(self)
2817 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2818 pub struct TryBlockExpr {
2819 pub(crate) syntax: SyntaxNode,
2822 impl AstNode for TryBlockExpr {
2823 fn cast(syntax: SyntaxNode) -> Option<Self> {
2824 match syntax.kind() {
2825 TRY_BLOCK_EXPR => Some(TryBlockExpr { syntax }),
2829 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2833 impl ast::TryBlockBodyOwner for TryBlockExpr {}
2834 impl TryBlockExpr {}
2837 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2838 pub struct TryExpr {
2839 pub(crate) syntax: SyntaxNode,
2842 impl AstNode for TryExpr {
2843 fn cast(syntax: SyntaxNode) -> Option<Self> {
2844 match syntax.kind() {
2845 TRY_EXPR => Some(TryExpr { syntax }),
2849 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2854 pub fn expr(&self) -> Option<Expr> {
2855 super::child_opt(self)
2860 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2861 pub struct TupleExpr {
2862 pub(crate) syntax: SyntaxNode,
2865 impl AstNode for TupleExpr {
2866 fn cast(syntax: SyntaxNode) -> Option<Self> {
2867 match syntax.kind() {
2868 TUPLE_EXPR => Some(TupleExpr { syntax }),
2872 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2877 pub fn exprs(&self) -> impl Iterator<Item = Expr> {
2878 super::children(self)
2883 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2884 pub struct TuplePat {
2885 pub(crate) syntax: SyntaxNode,
2888 impl AstNode for TuplePat {
2889 fn cast(syntax: SyntaxNode) -> Option<Self> {
2890 match syntax.kind() {
2891 TUPLE_PAT => Some(TuplePat { syntax }),
2895 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2900 pub fn args(&self) -> impl Iterator<Item = Pat> {
2901 super::children(self)
2906 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2907 pub struct TupleStructPat {
2908 pub(crate) syntax: SyntaxNode,
2911 impl AstNode for TupleStructPat {
2912 fn cast(syntax: SyntaxNode) -> Option<Self> {
2913 match syntax.kind() {
2914 TUPLE_STRUCT_PAT => Some(TupleStructPat { syntax }),
2918 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2922 impl TupleStructPat {
2923 pub fn args(&self) -> impl Iterator<Item = Pat> {
2924 super::children(self)
2927 pub fn path(&self) -> Option<Path> {
2928 super::child_opt(self)
2933 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2934 pub struct TupleType {
2935 pub(crate) syntax: SyntaxNode,
2938 impl AstNode for TupleType {
2939 fn cast(syntax: SyntaxNode) -> Option<Self> {
2940 match syntax.kind() {
2941 TUPLE_TYPE => Some(TupleType { syntax }),
2945 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2950 pub fn fields(&self) -> impl Iterator<Item = TypeRef> {
2951 super::children(self)
2956 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2957 pub struct TypeAliasDef {
2958 pub(crate) syntax: SyntaxNode,
2961 impl AstNode for TypeAliasDef {
2962 fn cast(syntax: SyntaxNode) -> Option<Self> {
2963 match syntax.kind() {
2964 TYPE_ALIAS_DEF => Some(TypeAliasDef { syntax }),
2968 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2972 impl ast::VisibilityOwner for TypeAliasDef {}
2973 impl ast::NameOwner for TypeAliasDef {}
2974 impl ast::TypeParamsOwner for TypeAliasDef {}
2975 impl ast::AttrsOwner for TypeAliasDef {}
2976 impl ast::DocCommentsOwner for TypeAliasDef {}
2977 impl ast::TypeBoundsOwner for TypeAliasDef {}
2979 pub fn type_ref(&self) -> Option<TypeRef> {
2980 super::child_opt(self)
2985 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2986 pub struct TypeArg {
2987 pub(crate) syntax: SyntaxNode,
2990 impl AstNode for TypeArg {
2991 fn cast(syntax: SyntaxNode) -> Option<Self> {
2992 match syntax.kind() {
2993 TYPE_ARG => Some(TypeArg { syntax }),
2997 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3002 pub fn type_ref(&self) -> Option<TypeRef> {
3003 super::child_opt(self)
3008 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3009 pub struct TypeArgList {
3010 pub(crate) syntax: SyntaxNode,
3013 impl AstNode for TypeArgList {
3014 fn cast(syntax: SyntaxNode) -> Option<Self> {
3015 match syntax.kind() {
3016 TYPE_ARG_LIST => Some(TypeArgList { syntax }),
3020 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3025 pub fn type_args(&self) -> impl Iterator<Item = TypeArg> {
3026 super::children(self)
3029 pub fn lifetime_args(&self) -> impl Iterator<Item = LifetimeArg> {
3030 super::children(self)
3033 pub fn assoc_type_args(&self) -> impl Iterator<Item = AssocTypeArg> {
3034 super::children(self)
3039 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3040 pub struct TypeBound {
3041 pub(crate) syntax: SyntaxNode,
3044 impl AstNode for TypeBound {
3045 fn cast(syntax: SyntaxNode) -> Option<Self> {
3046 match syntax.kind() {
3047 TYPE_BOUND => Some(TypeBound { syntax }),
3051 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3056 pub fn type_ref(&self) -> Option<TypeRef> {
3057 super::child_opt(self)
3062 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3063 pub struct TypeBoundList {
3064 pub(crate) syntax: SyntaxNode,
3067 impl AstNode for TypeBoundList {
3068 fn cast(syntax: SyntaxNode) -> Option<Self> {
3069 match syntax.kind() {
3070 TYPE_BOUND_LIST => Some(TypeBoundList { syntax }),
3074 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3078 impl TypeBoundList {
3079 pub fn bounds(&self) -> impl Iterator<Item = TypeBound> {
3080 super::children(self)
3085 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3086 pub struct TypeParam {
3087 pub(crate) syntax: SyntaxNode,
3090 impl AstNode for TypeParam {
3091 fn cast(syntax: SyntaxNode) -> Option<Self> {
3092 match syntax.kind() {
3093 TYPE_PARAM => Some(TypeParam { syntax }),
3097 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3101 impl ast::NameOwner for TypeParam {}
3102 impl ast::AttrsOwner for TypeParam {}
3103 impl ast::TypeBoundsOwner for TypeParam {}
3104 impl ast::DefaultTypeParamOwner for TypeParam {}
3108 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3109 pub struct TypeParamList {
3110 pub(crate) syntax: SyntaxNode,
3113 impl AstNode for TypeParamList {
3114 fn cast(syntax: SyntaxNode) -> Option<Self> {
3115 match syntax.kind() {
3116 TYPE_PARAM_LIST => Some(TypeParamList { syntax }),
3120 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3124 impl TypeParamList {
3125 pub fn type_params(&self) -> impl Iterator<Item = TypeParam> {
3126 super::children(self)
3129 pub fn lifetime_params(&self) -> impl Iterator<Item = LifetimeParam> {
3130 super::children(self)
3135 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3136 pub struct TypeRef {
3137 pub(crate) syntax: SyntaxNode,
3140 #[derive(Debug, Clone, PartialEq, Eq)]
3141 pub enum TypeRefKind {
3142 ParenType(ParenType),
3143 TupleType(TupleType),
3144 NeverType(NeverType),
3146 PointerType(PointerType),
3147 ArrayType(ArrayType),
3148 SliceType(SliceType),
3149 ReferenceType(ReferenceType),
3150 PlaceholderType(PlaceholderType),
3151 FnPointerType(FnPointerType),
3153 ImplTraitType(ImplTraitType),
3154 DynTraitType(DynTraitType),
3156 impl From<ParenType> for TypeRef {
3157 fn from(n: ParenType) -> TypeRef {
3158 TypeRef::cast(n.syntax).unwrap()
3161 impl From<TupleType> for TypeRef {
3162 fn from(n: TupleType) -> TypeRef {
3163 TypeRef::cast(n.syntax).unwrap()
3166 impl From<NeverType> for TypeRef {
3167 fn from(n: NeverType) -> TypeRef {
3168 TypeRef::cast(n.syntax).unwrap()
3171 impl From<PathType> for TypeRef {
3172 fn from(n: PathType) -> TypeRef {
3173 TypeRef::cast(n.syntax).unwrap()
3176 impl From<PointerType> for TypeRef {
3177 fn from(n: PointerType) -> TypeRef {
3178 TypeRef::cast(n.syntax).unwrap()
3181 impl From<ArrayType> for TypeRef {
3182 fn from(n: ArrayType) -> TypeRef {
3183 TypeRef::cast(n.syntax).unwrap()
3186 impl From<SliceType> for TypeRef {
3187 fn from(n: SliceType) -> TypeRef {
3188 TypeRef::cast(n.syntax).unwrap()
3191 impl From<ReferenceType> for TypeRef {
3192 fn from(n: ReferenceType) -> TypeRef {
3193 TypeRef::cast(n.syntax).unwrap()
3196 impl From<PlaceholderType> for TypeRef {
3197 fn from(n: PlaceholderType) -> TypeRef {
3198 TypeRef::cast(n.syntax).unwrap()
3201 impl From<FnPointerType> for TypeRef {
3202 fn from(n: FnPointerType) -> TypeRef {
3203 TypeRef::cast(n.syntax).unwrap()
3206 impl From<ForType> for TypeRef {
3207 fn from(n: ForType) -> TypeRef {
3208 TypeRef::cast(n.syntax).unwrap()
3211 impl From<ImplTraitType> for TypeRef {
3212 fn from(n: ImplTraitType) -> TypeRef {
3213 TypeRef::cast(n.syntax).unwrap()
3216 impl From<DynTraitType> for TypeRef {
3217 fn from(n: DynTraitType) -> TypeRef {
3218 TypeRef::cast(n.syntax).unwrap()
3223 impl AstNode for TypeRef {
3224 fn cast(syntax: SyntaxNode) -> Option<Self> {
3225 match syntax.kind() {
3238 | DYN_TRAIT_TYPE => Some(TypeRef { syntax }),
3242 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3246 pub fn kind(&self) -> TypeRefKind {
3247 match self.syntax.kind() {
3248 PAREN_TYPE => TypeRefKind::ParenType(ParenType::cast(self.syntax.clone()).unwrap()),
3249 TUPLE_TYPE => TypeRefKind::TupleType(TupleType::cast(self.syntax.clone()).unwrap()),
3250 NEVER_TYPE => TypeRefKind::NeverType(NeverType::cast(self.syntax.clone()).unwrap()),
3251 PATH_TYPE => TypeRefKind::PathType(PathType::cast(self.syntax.clone()).unwrap()),
3252 POINTER_TYPE => TypeRefKind::PointerType(PointerType::cast(self.syntax.clone()).unwrap()),
3253 ARRAY_TYPE => TypeRefKind::ArrayType(ArrayType::cast(self.syntax.clone()).unwrap()),
3254 SLICE_TYPE => TypeRefKind::SliceType(SliceType::cast(self.syntax.clone()).unwrap()),
3255 REFERENCE_TYPE => TypeRefKind::ReferenceType(ReferenceType::cast(self.syntax.clone()).unwrap()),
3256 PLACEHOLDER_TYPE => TypeRefKind::PlaceholderType(PlaceholderType::cast(self.syntax.clone()).unwrap()),
3257 FN_POINTER_TYPE => TypeRefKind::FnPointerType(FnPointerType::cast(self.syntax.clone()).unwrap()),
3258 FOR_TYPE => TypeRefKind::ForType(ForType::cast(self.syntax.clone()).unwrap()),
3259 IMPL_TRAIT_TYPE => TypeRefKind::ImplTraitType(ImplTraitType::cast(self.syntax.clone()).unwrap()),
3260 DYN_TRAIT_TYPE => TypeRefKind::DynTraitType(DynTraitType::cast(self.syntax.clone()).unwrap()),
3261 _ => unreachable!(),
3269 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3270 pub struct UseItem {
3271 pub(crate) syntax: SyntaxNode,
3274 impl AstNode for UseItem {
3275 fn cast(syntax: SyntaxNode) -> Option<Self> {
3276 match syntax.kind() {
3277 USE_ITEM => Some(UseItem { syntax }),
3281 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3285 impl ast::AttrsOwner for UseItem {}
3287 pub fn use_tree(&self) -> Option<UseTree> {
3288 super::child_opt(self)
3293 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3294 pub struct UseTree {
3295 pub(crate) syntax: SyntaxNode,
3298 impl AstNode for UseTree {
3299 fn cast(syntax: SyntaxNode) -> Option<Self> {
3300 match syntax.kind() {
3301 USE_TREE => Some(UseTree { syntax }),
3305 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3310 pub fn path(&self) -> Option<Path> {
3311 super::child_opt(self)
3314 pub fn use_tree_list(&self) -> Option<UseTreeList> {
3315 super::child_opt(self)
3318 pub fn alias(&self) -> Option<Alias> {
3319 super::child_opt(self)
3324 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3325 pub struct UseTreeList {
3326 pub(crate) syntax: SyntaxNode,
3329 impl AstNode for UseTreeList {
3330 fn cast(syntax: SyntaxNode) -> Option<Self> {
3331 match syntax.kind() {
3332 USE_TREE_LIST => Some(UseTreeList { syntax }),
3336 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3341 pub fn use_trees(&self) -> impl Iterator<Item = UseTree> {
3342 super::children(self)
3347 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3348 pub struct Visibility {
3349 pub(crate) syntax: SyntaxNode,
3352 impl AstNode for Visibility {
3353 fn cast(syntax: SyntaxNode) -> Option<Self> {
3354 match syntax.kind() {
3355 VISIBILITY => Some(Visibility { syntax }),
3359 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3366 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3367 pub struct WhereClause {
3368 pub(crate) syntax: SyntaxNode,
3371 impl AstNode for WhereClause {
3372 fn cast(syntax: SyntaxNode) -> Option<Self> {
3373 match syntax.kind() {
3374 WHERE_CLAUSE => Some(WhereClause { syntax }),
3378 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3383 pub fn predicates(&self) -> impl Iterator<Item = WherePred> {
3384 super::children(self)
3389 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3390 pub struct WherePred {
3391 pub(crate) syntax: SyntaxNode,
3394 impl AstNode for WherePred {
3395 fn cast(syntax: SyntaxNode) -> Option<Self> {
3396 match syntax.kind() {
3397 WHERE_PRED => Some(WherePred { syntax }),
3401 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3405 impl ast::TypeBoundsOwner for WherePred {}
3407 pub fn type_ref(&self) -> Option<TypeRef> {
3408 super::child_opt(self)
3413 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3414 pub struct WhileExpr {
3415 pub(crate) syntax: SyntaxNode,
3418 impl AstNode for WhileExpr {
3419 fn cast(syntax: SyntaxNode) -> Option<Self> {
3420 match syntax.kind() {
3421 WHILE_EXPR => Some(WhileExpr { syntax }),
3425 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3429 impl ast::LoopBodyOwner for WhileExpr {}
3431 pub fn condition(&self) -> Option<Condition> {
3432 super::child_opt(self)