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)]
12 use rowan::TransparentNewType;
15 SyntaxNode, SyntaxKind::*,
16 syntax_node::{TreeArc},
21 #[derive(Debug, PartialEq, Eq, Hash)]
24 pub(crate) syntax: SyntaxNode,
26 unsafe impl TransparentNewType for Alias {
27 type Repr = rowan::SyntaxNode;
30 impl AstNode for Alias {
31 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
33 ALIAS => Some(Alias::from_repr(syntax.into_repr())),
37 fn syntax(&self) -> &SyntaxNode { &self.syntax }
40 impl ToOwned for Alias {
41 type Owned = TreeArc<Alias>;
42 fn to_owned(&self) -> TreeArc<Alias> { TreeArc::cast(self.syntax.to_owned()) }
46 impl ast::NameOwner for Alias {}
50 #[derive(Debug, PartialEq, Eq, Hash)]
53 pub(crate) syntax: SyntaxNode,
55 unsafe impl TransparentNewType for ArgList {
56 type Repr = rowan::SyntaxNode;
59 impl AstNode for ArgList {
60 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
62 ARG_LIST => Some(ArgList::from_repr(syntax.into_repr())),
66 fn syntax(&self) -> &SyntaxNode { &self.syntax }
69 impl ToOwned for ArgList {
70 type Owned = TreeArc<ArgList>;
71 fn to_owned(&self) -> TreeArc<ArgList> { TreeArc::cast(self.syntax.to_owned()) }
76 pub fn args(&self) -> impl Iterator<Item = &Expr> {
82 #[derive(Debug, PartialEq, Eq, Hash)]
84 pub struct ArrayExpr {
85 pub(crate) syntax: SyntaxNode,
87 unsafe impl TransparentNewType for ArrayExpr {
88 type Repr = rowan::SyntaxNode;
91 impl AstNode for ArrayExpr {
92 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
94 ARRAY_EXPR => Some(ArrayExpr::from_repr(syntax.into_repr())),
98 fn syntax(&self) -> &SyntaxNode { &self.syntax }
101 impl ToOwned for ArrayExpr {
102 type Owned = TreeArc<ArrayExpr>;
103 fn to_owned(&self) -> TreeArc<ArrayExpr> { TreeArc::cast(self.syntax.to_owned()) }
108 pub fn exprs(&self) -> impl Iterator<Item = &Expr> {
109 super::children(self)
114 #[derive(Debug, PartialEq, Eq, Hash)]
116 pub struct ArrayType {
117 pub(crate) syntax: SyntaxNode,
119 unsafe impl TransparentNewType for ArrayType {
120 type Repr = rowan::SyntaxNode;
123 impl AstNode for ArrayType {
124 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
125 match syntax.kind() {
126 ARRAY_TYPE => Some(ArrayType::from_repr(syntax.into_repr())),
130 fn syntax(&self) -> &SyntaxNode { &self.syntax }
133 impl ToOwned for ArrayType {
134 type Owned = TreeArc<ArrayType>;
135 fn to_owned(&self) -> TreeArc<ArrayType> { TreeArc::cast(self.syntax.to_owned()) }
140 pub fn type_ref(&self) -> Option<&TypeRef> {
141 super::child_opt(self)
144 pub fn expr(&self) -> Option<&Expr> {
145 super::child_opt(self)
150 #[derive(Debug, PartialEq, Eq, Hash)]
152 pub struct AssocTypeArg {
153 pub(crate) syntax: SyntaxNode,
155 unsafe impl TransparentNewType for AssocTypeArg {
156 type Repr = rowan::SyntaxNode;
159 impl AstNode for AssocTypeArg {
160 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
161 match syntax.kind() {
162 ASSOC_TYPE_ARG => Some(AssocTypeArg::from_repr(syntax.into_repr())),
166 fn syntax(&self) -> &SyntaxNode { &self.syntax }
169 impl ToOwned for AssocTypeArg {
170 type Owned = TreeArc<AssocTypeArg>;
171 fn to_owned(&self) -> TreeArc<AssocTypeArg> { TreeArc::cast(self.syntax.to_owned()) }
176 pub fn name_ref(&self) -> Option<&NameRef> {
177 super::child_opt(self)
180 pub fn type_ref(&self) -> Option<&TypeRef> {
181 super::child_opt(self)
186 #[derive(Debug, PartialEq, Eq, Hash)]
189 pub(crate) syntax: SyntaxNode,
191 unsafe impl TransparentNewType for Attr {
192 type Repr = rowan::SyntaxNode;
195 impl AstNode for Attr {
196 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
197 match syntax.kind() {
198 ATTR => Some(Attr::from_repr(syntax.into_repr())),
202 fn syntax(&self) -> &SyntaxNode { &self.syntax }
205 impl ToOwned for Attr {
206 type Owned = TreeArc<Attr>;
207 fn to_owned(&self) -> TreeArc<Attr> { TreeArc::cast(self.syntax.to_owned()) }
212 pub fn value(&self) -> Option<&TokenTree> {
213 super::child_opt(self)
218 #[derive(Debug, PartialEq, Eq, Hash)]
221 pub(crate) syntax: SyntaxNode,
223 unsafe impl TransparentNewType for BinExpr {
224 type Repr = rowan::SyntaxNode;
227 impl AstNode for BinExpr {
228 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
229 match syntax.kind() {
230 BIN_EXPR => Some(BinExpr::from_repr(syntax.into_repr())),
234 fn syntax(&self) -> &SyntaxNode { &self.syntax }
237 impl ToOwned for BinExpr {
238 type Owned = TreeArc<BinExpr>;
239 fn to_owned(&self) -> TreeArc<BinExpr> { TreeArc::cast(self.syntax.to_owned()) }
246 #[derive(Debug, PartialEq, Eq, Hash)]
249 pub(crate) syntax: SyntaxNode,
251 unsafe impl TransparentNewType for BindPat {
252 type Repr = rowan::SyntaxNode;
255 impl AstNode for BindPat {
256 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
257 match syntax.kind() {
258 BIND_PAT => Some(BindPat::from_repr(syntax.into_repr())),
262 fn syntax(&self) -> &SyntaxNode { &self.syntax }
265 impl ToOwned for BindPat {
266 type Owned = TreeArc<BindPat>;
267 fn to_owned(&self) -> TreeArc<BindPat> { TreeArc::cast(self.syntax.to_owned()) }
271 impl ast::NameOwner for BindPat {}
273 pub fn pat(&self) -> Option<&Pat> {
274 super::child_opt(self)
279 #[derive(Debug, PartialEq, Eq, Hash)]
282 pub(crate) syntax: SyntaxNode,
284 unsafe impl TransparentNewType for Block {
285 type Repr = rowan::SyntaxNode;
288 impl AstNode for Block {
289 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
290 match syntax.kind() {
291 BLOCK => Some(Block::from_repr(syntax.into_repr())),
295 fn syntax(&self) -> &SyntaxNode { &self.syntax }
298 impl ToOwned for Block {
299 type Owned = TreeArc<Block>;
300 fn to_owned(&self) -> TreeArc<Block> { TreeArc::cast(self.syntax.to_owned()) }
304 impl ast::AttrsOwner for Block {}
306 pub fn statements(&self) -> impl Iterator<Item = &Stmt> {
307 super::children(self)
310 pub fn expr(&self) -> Option<&Expr> {
311 super::child_opt(self)
316 #[derive(Debug, PartialEq, Eq, Hash)]
318 pub struct BlockExpr {
319 pub(crate) syntax: SyntaxNode,
321 unsafe impl TransparentNewType for BlockExpr {
322 type Repr = rowan::SyntaxNode;
325 impl AstNode for BlockExpr {
326 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
327 match syntax.kind() {
328 BLOCK_EXPR => Some(BlockExpr::from_repr(syntax.into_repr())),
332 fn syntax(&self) -> &SyntaxNode { &self.syntax }
335 impl ToOwned for BlockExpr {
336 type Owned = TreeArc<BlockExpr>;
337 fn to_owned(&self) -> TreeArc<BlockExpr> { TreeArc::cast(self.syntax.to_owned()) }
342 pub fn block(&self) -> Option<&Block> {
343 super::child_opt(self)
348 #[derive(Debug, PartialEq, Eq, Hash)]
350 pub struct BreakExpr {
351 pub(crate) syntax: SyntaxNode,
353 unsafe impl TransparentNewType for BreakExpr {
354 type Repr = rowan::SyntaxNode;
357 impl AstNode for BreakExpr {
358 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
359 match syntax.kind() {
360 BREAK_EXPR => Some(BreakExpr::from_repr(syntax.into_repr())),
364 fn syntax(&self) -> &SyntaxNode { &self.syntax }
367 impl ToOwned for BreakExpr {
368 type Owned = TreeArc<BreakExpr>;
369 fn to_owned(&self) -> TreeArc<BreakExpr> { TreeArc::cast(self.syntax.to_owned()) }
374 pub fn expr(&self) -> Option<&Expr> {
375 super::child_opt(self)
380 #[derive(Debug, PartialEq, Eq, Hash)]
382 pub struct CallExpr {
383 pub(crate) syntax: SyntaxNode,
385 unsafe impl TransparentNewType for CallExpr {
386 type Repr = rowan::SyntaxNode;
389 impl AstNode for CallExpr {
390 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
391 match syntax.kind() {
392 CALL_EXPR => Some(CallExpr::from_repr(syntax.into_repr())),
396 fn syntax(&self) -> &SyntaxNode { &self.syntax }
399 impl ToOwned for CallExpr {
400 type Owned = TreeArc<CallExpr>;
401 fn to_owned(&self) -> TreeArc<CallExpr> { TreeArc::cast(self.syntax.to_owned()) }
405 impl ast::ArgListOwner for CallExpr {}
407 pub fn expr(&self) -> Option<&Expr> {
408 super::child_opt(self)
413 #[derive(Debug, PartialEq, Eq, Hash)]
415 pub struct CastExpr {
416 pub(crate) syntax: SyntaxNode,
418 unsafe impl TransparentNewType for CastExpr {
419 type Repr = rowan::SyntaxNode;
422 impl AstNode for CastExpr {
423 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
424 match syntax.kind() {
425 CAST_EXPR => Some(CastExpr::from_repr(syntax.into_repr())),
429 fn syntax(&self) -> &SyntaxNode { &self.syntax }
432 impl ToOwned for CastExpr {
433 type Owned = TreeArc<CastExpr>;
434 fn to_owned(&self) -> TreeArc<CastExpr> { TreeArc::cast(self.syntax.to_owned()) }
439 pub fn expr(&self) -> Option<&Expr> {
440 super::child_opt(self)
443 pub fn type_ref(&self) -> Option<&TypeRef> {
444 super::child_opt(self)
449 #[derive(Debug, PartialEq, Eq, Hash)]
451 pub struct Condition {
452 pub(crate) syntax: SyntaxNode,
454 unsafe impl TransparentNewType for Condition {
455 type Repr = rowan::SyntaxNode;
458 impl AstNode for Condition {
459 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
460 match syntax.kind() {
461 CONDITION => Some(Condition::from_repr(syntax.into_repr())),
465 fn syntax(&self) -> &SyntaxNode { &self.syntax }
468 impl ToOwned for Condition {
469 type Owned = TreeArc<Condition>;
470 fn to_owned(&self) -> TreeArc<Condition> { TreeArc::cast(self.syntax.to_owned()) }
475 pub fn pat(&self) -> Option<&Pat> {
476 super::child_opt(self)
479 pub fn expr(&self) -> Option<&Expr> {
480 super::child_opt(self)
485 #[derive(Debug, PartialEq, Eq, Hash)]
487 pub struct ConstDef {
488 pub(crate) syntax: SyntaxNode,
490 unsafe impl TransparentNewType for ConstDef {
491 type Repr = rowan::SyntaxNode;
494 impl AstNode for ConstDef {
495 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
496 match syntax.kind() {
497 CONST_DEF => Some(ConstDef::from_repr(syntax.into_repr())),
501 fn syntax(&self) -> &SyntaxNode { &self.syntax }
504 impl ToOwned for ConstDef {
505 type Owned = TreeArc<ConstDef>;
506 fn to_owned(&self) -> TreeArc<ConstDef> { TreeArc::cast(self.syntax.to_owned()) }
510 impl ast::VisibilityOwner for ConstDef {}
511 impl ast::NameOwner for ConstDef {}
512 impl ast::TypeParamsOwner for ConstDef {}
513 impl ast::AttrsOwner for ConstDef {}
514 impl ast::DocCommentsOwner for ConstDef {}
515 impl ast::TypeAscriptionOwner for ConstDef {}
517 pub fn body(&self) -> Option<&Expr> {
518 super::child_opt(self)
523 #[derive(Debug, PartialEq, Eq, Hash)]
525 pub struct ContinueExpr {
526 pub(crate) syntax: SyntaxNode,
528 unsafe impl TransparentNewType for ContinueExpr {
529 type Repr = rowan::SyntaxNode;
532 impl AstNode for ContinueExpr {
533 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
534 match syntax.kind() {
535 CONTINUE_EXPR => Some(ContinueExpr::from_repr(syntax.into_repr())),
539 fn syntax(&self) -> &SyntaxNode { &self.syntax }
542 impl ToOwned for ContinueExpr {
543 type Owned = TreeArc<ContinueExpr>;
544 fn to_owned(&self) -> TreeArc<ContinueExpr> { TreeArc::cast(self.syntax.to_owned()) }
551 #[derive(Debug, PartialEq, Eq, Hash)]
553 pub struct DynTraitType {
554 pub(crate) syntax: SyntaxNode,
556 unsafe impl TransparentNewType for DynTraitType {
557 type Repr = rowan::SyntaxNode;
560 impl AstNode for DynTraitType {
561 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
562 match syntax.kind() {
563 DYN_TRAIT_TYPE => Some(DynTraitType::from_repr(syntax.into_repr())),
567 fn syntax(&self) -> &SyntaxNode { &self.syntax }
570 impl ToOwned for DynTraitType {
571 type Owned = TreeArc<DynTraitType>;
572 fn to_owned(&self) -> TreeArc<DynTraitType> { TreeArc::cast(self.syntax.to_owned()) }
576 impl ast::TypeBoundsOwner for DynTraitType {}
580 #[derive(Debug, PartialEq, Eq, Hash)]
583 pub(crate) syntax: SyntaxNode,
585 unsafe impl TransparentNewType for EnumDef {
586 type Repr = rowan::SyntaxNode;
589 impl AstNode for EnumDef {
590 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
591 match syntax.kind() {
592 ENUM_DEF => Some(EnumDef::from_repr(syntax.into_repr())),
596 fn syntax(&self) -> &SyntaxNode { &self.syntax }
599 impl ToOwned for EnumDef {
600 type Owned = TreeArc<EnumDef>;
601 fn to_owned(&self) -> TreeArc<EnumDef> { TreeArc::cast(self.syntax.to_owned()) }
605 impl ast::VisibilityOwner for EnumDef {}
606 impl ast::NameOwner for EnumDef {}
607 impl ast::TypeParamsOwner for EnumDef {}
608 impl ast::AttrsOwner for EnumDef {}
609 impl ast::DocCommentsOwner for EnumDef {}
611 pub fn variant_list(&self) -> Option<&EnumVariantList> {
612 super::child_opt(self)
617 #[derive(Debug, PartialEq, Eq, Hash)]
619 pub struct EnumVariant {
620 pub(crate) syntax: SyntaxNode,
622 unsafe impl TransparentNewType for EnumVariant {
623 type Repr = rowan::SyntaxNode;
626 impl AstNode for EnumVariant {
627 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
628 match syntax.kind() {
629 ENUM_VARIANT => Some(EnumVariant::from_repr(syntax.into_repr())),
633 fn syntax(&self) -> &SyntaxNode { &self.syntax }
636 impl ToOwned for EnumVariant {
637 type Owned = TreeArc<EnumVariant>;
638 fn to_owned(&self) -> TreeArc<EnumVariant> { TreeArc::cast(self.syntax.to_owned()) }
642 impl ast::NameOwner for EnumVariant {}
643 impl ast::DocCommentsOwner for EnumVariant {}
644 impl ast::AttrsOwner for EnumVariant {}
646 pub fn expr(&self) -> Option<&Expr> {
647 super::child_opt(self)
652 #[derive(Debug, PartialEq, Eq, Hash)]
654 pub struct EnumVariantList {
655 pub(crate) syntax: SyntaxNode,
657 unsafe impl TransparentNewType for EnumVariantList {
658 type Repr = rowan::SyntaxNode;
661 impl AstNode for EnumVariantList {
662 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
663 match syntax.kind() {
664 ENUM_VARIANT_LIST => Some(EnumVariantList::from_repr(syntax.into_repr())),
668 fn syntax(&self) -> &SyntaxNode { &self.syntax }
671 impl ToOwned for EnumVariantList {
672 type Owned = TreeArc<EnumVariantList>;
673 fn to_owned(&self) -> TreeArc<EnumVariantList> { TreeArc::cast(self.syntax.to_owned()) }
677 impl EnumVariantList {
678 pub fn variants(&self) -> impl Iterator<Item = &EnumVariant> {
679 super::children(self)
684 #[derive(Debug, PartialEq, Eq, Hash)]
687 pub(crate) syntax: SyntaxNode,
689 unsafe impl TransparentNewType for Expr {
690 type Repr = rowan::SyntaxNode;
693 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
694 pub enum ExprKind<'a> {
695 TupleExpr(&'a TupleExpr),
696 ArrayExpr(&'a ArrayExpr),
697 ParenExpr(&'a ParenExpr),
698 PathExpr(&'a PathExpr),
699 LambdaExpr(&'a LambdaExpr),
701 LoopExpr(&'a LoopExpr),
702 ForExpr(&'a ForExpr),
703 WhileExpr(&'a WhileExpr),
704 ContinueExpr(&'a ContinueExpr),
705 BreakExpr(&'a BreakExpr),
707 BlockExpr(&'a BlockExpr),
708 ReturnExpr(&'a ReturnExpr),
709 MatchExpr(&'a MatchExpr),
710 StructLit(&'a StructLit),
711 CallExpr(&'a CallExpr),
712 IndexExpr(&'a IndexExpr),
713 MethodCallExpr(&'a MethodCallExpr),
714 FieldExpr(&'a FieldExpr),
715 TryExpr(&'a TryExpr),
716 CastExpr(&'a CastExpr),
717 RefExpr(&'a RefExpr),
718 PrefixExpr(&'a PrefixExpr),
719 RangeExpr(&'a RangeExpr),
720 BinExpr(&'a BinExpr),
721 Literal(&'a Literal),
722 MacroCall(&'a MacroCall),
724 impl<'a> From<&'a TupleExpr> for &'a Expr {
725 fn from(n: &'a TupleExpr) -> &'a Expr {
726 Expr::cast(&n.syntax).unwrap()
729 impl<'a> From<&'a ArrayExpr> for &'a Expr {
730 fn from(n: &'a ArrayExpr) -> &'a Expr {
731 Expr::cast(&n.syntax).unwrap()
734 impl<'a> From<&'a ParenExpr> for &'a Expr {
735 fn from(n: &'a ParenExpr) -> &'a Expr {
736 Expr::cast(&n.syntax).unwrap()
739 impl<'a> From<&'a PathExpr> for &'a Expr {
740 fn from(n: &'a PathExpr) -> &'a Expr {
741 Expr::cast(&n.syntax).unwrap()
744 impl<'a> From<&'a LambdaExpr> for &'a Expr {
745 fn from(n: &'a LambdaExpr) -> &'a Expr {
746 Expr::cast(&n.syntax).unwrap()
749 impl<'a> From<&'a IfExpr> for &'a Expr {
750 fn from(n: &'a IfExpr) -> &'a Expr {
751 Expr::cast(&n.syntax).unwrap()
754 impl<'a> From<&'a LoopExpr> for &'a Expr {
755 fn from(n: &'a LoopExpr) -> &'a Expr {
756 Expr::cast(&n.syntax).unwrap()
759 impl<'a> From<&'a ForExpr> for &'a Expr {
760 fn from(n: &'a ForExpr) -> &'a Expr {
761 Expr::cast(&n.syntax).unwrap()
764 impl<'a> From<&'a WhileExpr> for &'a Expr {
765 fn from(n: &'a WhileExpr) -> &'a Expr {
766 Expr::cast(&n.syntax).unwrap()
769 impl<'a> From<&'a ContinueExpr> for &'a Expr {
770 fn from(n: &'a ContinueExpr) -> &'a Expr {
771 Expr::cast(&n.syntax).unwrap()
774 impl<'a> From<&'a BreakExpr> for &'a Expr {
775 fn from(n: &'a BreakExpr) -> &'a Expr {
776 Expr::cast(&n.syntax).unwrap()
779 impl<'a> From<&'a Label> for &'a Expr {
780 fn from(n: &'a Label) -> &'a Expr {
781 Expr::cast(&n.syntax).unwrap()
784 impl<'a> From<&'a BlockExpr> for &'a Expr {
785 fn from(n: &'a BlockExpr) -> &'a Expr {
786 Expr::cast(&n.syntax).unwrap()
789 impl<'a> From<&'a ReturnExpr> for &'a Expr {
790 fn from(n: &'a ReturnExpr) -> &'a Expr {
791 Expr::cast(&n.syntax).unwrap()
794 impl<'a> From<&'a MatchExpr> for &'a Expr {
795 fn from(n: &'a MatchExpr) -> &'a Expr {
796 Expr::cast(&n.syntax).unwrap()
799 impl<'a> From<&'a StructLit> for &'a Expr {
800 fn from(n: &'a StructLit) -> &'a Expr {
801 Expr::cast(&n.syntax).unwrap()
804 impl<'a> From<&'a CallExpr> for &'a Expr {
805 fn from(n: &'a CallExpr) -> &'a Expr {
806 Expr::cast(&n.syntax).unwrap()
809 impl<'a> From<&'a IndexExpr> for &'a Expr {
810 fn from(n: &'a IndexExpr) -> &'a Expr {
811 Expr::cast(&n.syntax).unwrap()
814 impl<'a> From<&'a MethodCallExpr> for &'a Expr {
815 fn from(n: &'a MethodCallExpr) -> &'a Expr {
816 Expr::cast(&n.syntax).unwrap()
819 impl<'a> From<&'a FieldExpr> for &'a Expr {
820 fn from(n: &'a FieldExpr) -> &'a Expr {
821 Expr::cast(&n.syntax).unwrap()
824 impl<'a> From<&'a TryExpr> for &'a Expr {
825 fn from(n: &'a TryExpr) -> &'a Expr {
826 Expr::cast(&n.syntax).unwrap()
829 impl<'a> From<&'a CastExpr> for &'a Expr {
830 fn from(n: &'a CastExpr) -> &'a Expr {
831 Expr::cast(&n.syntax).unwrap()
834 impl<'a> From<&'a RefExpr> for &'a Expr {
835 fn from(n: &'a RefExpr) -> &'a Expr {
836 Expr::cast(&n.syntax).unwrap()
839 impl<'a> From<&'a PrefixExpr> for &'a Expr {
840 fn from(n: &'a PrefixExpr) -> &'a Expr {
841 Expr::cast(&n.syntax).unwrap()
844 impl<'a> From<&'a RangeExpr> for &'a Expr {
845 fn from(n: &'a RangeExpr) -> &'a Expr {
846 Expr::cast(&n.syntax).unwrap()
849 impl<'a> From<&'a BinExpr> for &'a Expr {
850 fn from(n: &'a BinExpr) -> &'a Expr {
851 Expr::cast(&n.syntax).unwrap()
854 impl<'a> From<&'a Literal> for &'a Expr {
855 fn from(n: &'a Literal) -> &'a Expr {
856 Expr::cast(&n.syntax).unwrap()
859 impl<'a> From<&'a MacroCall> for &'a Expr {
860 fn from(n: &'a MacroCall) -> &'a Expr {
861 Expr::cast(&n.syntax).unwrap()
866 impl AstNode for Expr {
867 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
868 match syntax.kind() {
896 | MACRO_CALL => Some(Expr::from_repr(syntax.into_repr())),
900 fn syntax(&self) -> &SyntaxNode { &self.syntax }
903 impl ToOwned for Expr {
904 type Owned = TreeArc<Expr>;
905 fn to_owned(&self) -> TreeArc<Expr> { TreeArc::cast(self.syntax.to_owned()) }
909 pub fn kind(&self) -> ExprKind {
910 match self.syntax.kind() {
911 TUPLE_EXPR => ExprKind::TupleExpr(TupleExpr::cast(&self.syntax).unwrap()),
912 ARRAY_EXPR => ExprKind::ArrayExpr(ArrayExpr::cast(&self.syntax).unwrap()),
913 PAREN_EXPR => ExprKind::ParenExpr(ParenExpr::cast(&self.syntax).unwrap()),
914 PATH_EXPR => ExprKind::PathExpr(PathExpr::cast(&self.syntax).unwrap()),
915 LAMBDA_EXPR => ExprKind::LambdaExpr(LambdaExpr::cast(&self.syntax).unwrap()),
916 IF_EXPR => ExprKind::IfExpr(IfExpr::cast(&self.syntax).unwrap()),
917 LOOP_EXPR => ExprKind::LoopExpr(LoopExpr::cast(&self.syntax).unwrap()),
918 FOR_EXPR => ExprKind::ForExpr(ForExpr::cast(&self.syntax).unwrap()),
919 WHILE_EXPR => ExprKind::WhileExpr(WhileExpr::cast(&self.syntax).unwrap()),
920 CONTINUE_EXPR => ExprKind::ContinueExpr(ContinueExpr::cast(&self.syntax).unwrap()),
921 BREAK_EXPR => ExprKind::BreakExpr(BreakExpr::cast(&self.syntax).unwrap()),
922 LABEL => ExprKind::Label(Label::cast(&self.syntax).unwrap()),
923 BLOCK_EXPR => ExprKind::BlockExpr(BlockExpr::cast(&self.syntax).unwrap()),
924 RETURN_EXPR => ExprKind::ReturnExpr(ReturnExpr::cast(&self.syntax).unwrap()),
925 MATCH_EXPR => ExprKind::MatchExpr(MatchExpr::cast(&self.syntax).unwrap()),
926 STRUCT_LIT => ExprKind::StructLit(StructLit::cast(&self.syntax).unwrap()),
927 CALL_EXPR => ExprKind::CallExpr(CallExpr::cast(&self.syntax).unwrap()),
928 INDEX_EXPR => ExprKind::IndexExpr(IndexExpr::cast(&self.syntax).unwrap()),
929 METHOD_CALL_EXPR => ExprKind::MethodCallExpr(MethodCallExpr::cast(&self.syntax).unwrap()),
930 FIELD_EXPR => ExprKind::FieldExpr(FieldExpr::cast(&self.syntax).unwrap()),
931 TRY_EXPR => ExprKind::TryExpr(TryExpr::cast(&self.syntax).unwrap()),
932 CAST_EXPR => ExprKind::CastExpr(CastExpr::cast(&self.syntax).unwrap()),
933 REF_EXPR => ExprKind::RefExpr(RefExpr::cast(&self.syntax).unwrap()),
934 PREFIX_EXPR => ExprKind::PrefixExpr(PrefixExpr::cast(&self.syntax).unwrap()),
935 RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(&self.syntax).unwrap()),
936 BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(&self.syntax).unwrap()),
937 LITERAL => ExprKind::Literal(Literal::cast(&self.syntax).unwrap()),
938 MACRO_CALL => ExprKind::MacroCall(MacroCall::cast(&self.syntax).unwrap()),
947 #[derive(Debug, PartialEq, Eq, Hash)]
949 pub struct ExprStmt {
950 pub(crate) syntax: SyntaxNode,
952 unsafe impl TransparentNewType for ExprStmt {
953 type Repr = rowan::SyntaxNode;
956 impl AstNode for ExprStmt {
957 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
958 match syntax.kind() {
959 EXPR_STMT => Some(ExprStmt::from_repr(syntax.into_repr())),
963 fn syntax(&self) -> &SyntaxNode { &self.syntax }
966 impl ToOwned for ExprStmt {
967 type Owned = TreeArc<ExprStmt>;
968 fn to_owned(&self) -> TreeArc<ExprStmt> { TreeArc::cast(self.syntax.to_owned()) }
973 pub fn expr(&self) -> Option<&Expr> {
974 super::child_opt(self)
979 #[derive(Debug, PartialEq, Eq, Hash)]
981 pub struct ExternCrateItem {
982 pub(crate) syntax: SyntaxNode,
984 unsafe impl TransparentNewType for ExternCrateItem {
985 type Repr = rowan::SyntaxNode;
988 impl AstNode for ExternCrateItem {
989 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
990 match syntax.kind() {
991 EXTERN_CRATE_ITEM => Some(ExternCrateItem::from_repr(syntax.into_repr())),
995 fn syntax(&self) -> &SyntaxNode { &self.syntax }
998 impl ToOwned for ExternCrateItem {
999 type Owned = TreeArc<ExternCrateItem>;
1000 fn to_owned(&self) -> TreeArc<ExternCrateItem> { TreeArc::cast(self.syntax.to_owned()) }
1004 impl ExternCrateItem {
1005 pub fn name_ref(&self) -> Option<&NameRef> {
1006 super::child_opt(self)
1009 pub fn alias(&self) -> Option<&Alias> {
1010 super::child_opt(self)
1015 #[derive(Debug, PartialEq, Eq, Hash)]
1016 #[repr(transparent)]
1017 pub struct FieldExpr {
1018 pub(crate) syntax: SyntaxNode,
1020 unsafe impl TransparentNewType for FieldExpr {
1021 type Repr = rowan::SyntaxNode;
1024 impl AstNode for FieldExpr {
1025 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1026 match syntax.kind() {
1027 FIELD_EXPR => Some(FieldExpr::from_repr(syntax.into_repr())),
1031 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1034 impl ToOwned for FieldExpr {
1035 type Owned = TreeArc<FieldExpr>;
1036 fn to_owned(&self) -> TreeArc<FieldExpr> { TreeArc::cast(self.syntax.to_owned()) }
1041 pub fn expr(&self) -> Option<&Expr> {
1042 super::child_opt(self)
1045 pub fn name_ref(&self) -> Option<&NameRef> {
1046 super::child_opt(self)
1051 #[derive(Debug, PartialEq, Eq, Hash)]
1052 #[repr(transparent)]
1053 pub struct FieldPat {
1054 pub(crate) syntax: SyntaxNode,
1056 unsafe impl TransparentNewType for FieldPat {
1057 type Repr = rowan::SyntaxNode;
1060 impl AstNode for FieldPat {
1061 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1062 match syntax.kind() {
1063 FIELD_PAT => Some(FieldPat::from_repr(syntax.into_repr())),
1067 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1070 impl ToOwned for FieldPat {
1071 type Owned = TreeArc<FieldPat>;
1072 fn to_owned(&self) -> TreeArc<FieldPat> { TreeArc::cast(self.syntax.to_owned()) }
1076 impl ast::NameOwner for FieldPat {}
1078 pub fn pat(&self) -> Option<&Pat> {
1079 super::child_opt(self)
1084 #[derive(Debug, PartialEq, Eq, Hash)]
1085 #[repr(transparent)]
1086 pub struct FieldPatList {
1087 pub(crate) syntax: SyntaxNode,
1089 unsafe impl TransparentNewType for FieldPatList {
1090 type Repr = rowan::SyntaxNode;
1093 impl AstNode for FieldPatList {
1094 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1095 match syntax.kind() {
1096 FIELD_PAT_LIST => Some(FieldPatList::from_repr(syntax.into_repr())),
1100 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1103 impl ToOwned for FieldPatList {
1104 type Owned = TreeArc<FieldPatList>;
1105 fn to_owned(&self) -> TreeArc<FieldPatList> { TreeArc::cast(self.syntax.to_owned()) }
1110 pub fn field_pats(&self) -> impl Iterator<Item = &FieldPat> {
1111 super::children(self)
1114 pub fn bind_pats(&self) -> impl Iterator<Item = &BindPat> {
1115 super::children(self)
1120 #[derive(Debug, PartialEq, Eq, Hash)]
1121 #[repr(transparent)]
1123 pub(crate) syntax: SyntaxNode,
1125 unsafe impl TransparentNewType for FnDef {
1126 type Repr = rowan::SyntaxNode;
1129 impl AstNode for FnDef {
1130 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1131 match syntax.kind() {
1132 FN_DEF => Some(FnDef::from_repr(syntax.into_repr())),
1136 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1139 impl ToOwned for FnDef {
1140 type Owned = TreeArc<FnDef>;
1141 fn to_owned(&self) -> TreeArc<FnDef> { TreeArc::cast(self.syntax.to_owned()) }
1145 impl ast::VisibilityOwner for FnDef {}
1146 impl ast::NameOwner for FnDef {}
1147 impl ast::TypeParamsOwner for FnDef {}
1148 impl ast::AttrsOwner for FnDef {}
1149 impl ast::DocCommentsOwner for FnDef {}
1151 pub fn param_list(&self) -> Option<&ParamList> {
1152 super::child_opt(self)
1155 pub fn body(&self) -> Option<&Block> {
1156 super::child_opt(self)
1159 pub fn ret_type(&self) -> Option<&RetType> {
1160 super::child_opt(self)
1165 #[derive(Debug, PartialEq, Eq, Hash)]
1166 #[repr(transparent)]
1167 pub struct FnPointerType {
1168 pub(crate) syntax: SyntaxNode,
1170 unsafe impl TransparentNewType for FnPointerType {
1171 type Repr = rowan::SyntaxNode;
1174 impl AstNode for FnPointerType {
1175 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1176 match syntax.kind() {
1177 FN_POINTER_TYPE => Some(FnPointerType::from_repr(syntax.into_repr())),
1181 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1184 impl ToOwned for FnPointerType {
1185 type Owned = TreeArc<FnPointerType>;
1186 fn to_owned(&self) -> TreeArc<FnPointerType> { TreeArc::cast(self.syntax.to_owned()) }
1190 impl FnPointerType {
1191 pub fn param_list(&self) -> Option<&ParamList> {
1192 super::child_opt(self)
1195 pub fn ret_type(&self) -> Option<&RetType> {
1196 super::child_opt(self)
1201 #[derive(Debug, PartialEq, Eq, Hash)]
1202 #[repr(transparent)]
1203 pub struct ForExpr {
1204 pub(crate) syntax: SyntaxNode,
1206 unsafe impl TransparentNewType for ForExpr {
1207 type Repr = rowan::SyntaxNode;
1210 impl AstNode for ForExpr {
1211 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1212 match syntax.kind() {
1213 FOR_EXPR => Some(ForExpr::from_repr(syntax.into_repr())),
1217 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1220 impl ToOwned for ForExpr {
1221 type Owned = TreeArc<ForExpr>;
1222 fn to_owned(&self) -> TreeArc<ForExpr> { TreeArc::cast(self.syntax.to_owned()) }
1226 impl ast::LoopBodyOwner for ForExpr {}
1228 pub fn pat(&self) -> Option<&Pat> {
1229 super::child_opt(self)
1232 pub fn iterable(&self) -> Option<&Expr> {
1233 super::child_opt(self)
1238 #[derive(Debug, PartialEq, Eq, Hash)]
1239 #[repr(transparent)]
1240 pub struct ForType {
1241 pub(crate) syntax: SyntaxNode,
1243 unsafe impl TransparentNewType for ForType {
1244 type Repr = rowan::SyntaxNode;
1247 impl AstNode for ForType {
1248 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1249 match syntax.kind() {
1250 FOR_TYPE => Some(ForType::from_repr(syntax.into_repr())),
1254 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1257 impl ToOwned for ForType {
1258 type Owned = TreeArc<ForType>;
1259 fn to_owned(&self) -> TreeArc<ForType> { TreeArc::cast(self.syntax.to_owned()) }
1264 pub fn type_ref(&self) -> Option<&TypeRef> {
1265 super::child_opt(self)
1270 #[derive(Debug, PartialEq, Eq, Hash)]
1271 #[repr(transparent)]
1273 pub(crate) syntax: SyntaxNode,
1275 unsafe impl TransparentNewType for IfExpr {
1276 type Repr = rowan::SyntaxNode;
1279 impl AstNode for IfExpr {
1280 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1281 match syntax.kind() {
1282 IF_EXPR => Some(IfExpr::from_repr(syntax.into_repr())),
1286 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1289 impl ToOwned for IfExpr {
1290 type Owned = TreeArc<IfExpr>;
1291 fn to_owned(&self) -> TreeArc<IfExpr> { TreeArc::cast(self.syntax.to_owned()) }
1296 pub fn condition(&self) -> Option<&Condition> {
1297 super::child_opt(self)
1302 #[derive(Debug, PartialEq, Eq, Hash)]
1303 #[repr(transparent)]
1304 pub struct ImplBlock {
1305 pub(crate) syntax: SyntaxNode,
1307 unsafe impl TransparentNewType for ImplBlock {
1308 type Repr = rowan::SyntaxNode;
1311 impl AstNode for ImplBlock {
1312 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1313 match syntax.kind() {
1314 IMPL_BLOCK => Some(ImplBlock::from_repr(syntax.into_repr())),
1318 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1321 impl ToOwned for ImplBlock {
1322 type Owned = TreeArc<ImplBlock>;
1323 fn to_owned(&self) -> TreeArc<ImplBlock> { TreeArc::cast(self.syntax.to_owned()) }
1327 impl ast::TypeParamsOwner for ImplBlock {}
1328 impl ast::AttrsOwner for ImplBlock {}
1330 pub fn item_list(&self) -> Option<&ItemList> {
1331 super::child_opt(self)
1336 #[derive(Debug, PartialEq, Eq, Hash)]
1337 #[repr(transparent)]
1338 pub struct ImplItem {
1339 pub(crate) syntax: SyntaxNode,
1341 unsafe impl TransparentNewType for ImplItem {
1342 type Repr = rowan::SyntaxNode;
1345 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1346 pub enum ImplItemKind<'a> {
1348 TypeAliasDef(&'a TypeAliasDef),
1349 ConstDef(&'a ConstDef),
1351 impl<'a> From<&'a FnDef> for &'a ImplItem {
1352 fn from(n: &'a FnDef) -> &'a ImplItem {
1353 ImplItem::cast(&n.syntax).unwrap()
1356 impl<'a> From<&'a TypeAliasDef> for &'a ImplItem {
1357 fn from(n: &'a TypeAliasDef) -> &'a ImplItem {
1358 ImplItem::cast(&n.syntax).unwrap()
1361 impl<'a> From<&'a ConstDef> for &'a ImplItem {
1362 fn from(n: &'a ConstDef) -> &'a ImplItem {
1363 ImplItem::cast(&n.syntax).unwrap()
1368 impl AstNode for ImplItem {
1369 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1370 match syntax.kind() {
1373 | CONST_DEF => Some(ImplItem::from_repr(syntax.into_repr())),
1377 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1380 impl ToOwned for ImplItem {
1381 type Owned = TreeArc<ImplItem>;
1382 fn to_owned(&self) -> TreeArc<ImplItem> { TreeArc::cast(self.syntax.to_owned()) }
1386 pub fn kind(&self) -> ImplItemKind {
1387 match self.syntax.kind() {
1388 FN_DEF => ImplItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
1389 TYPE_ALIAS_DEF => ImplItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
1390 CONST_DEF => ImplItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
1391 _ => unreachable!(),
1399 #[derive(Debug, PartialEq, Eq, Hash)]
1400 #[repr(transparent)]
1401 pub struct ImplTraitType {
1402 pub(crate) syntax: SyntaxNode,
1404 unsafe impl TransparentNewType for ImplTraitType {
1405 type Repr = rowan::SyntaxNode;
1408 impl AstNode for ImplTraitType {
1409 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1410 match syntax.kind() {
1411 IMPL_TRAIT_TYPE => Some(ImplTraitType::from_repr(syntax.into_repr())),
1415 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1418 impl ToOwned for ImplTraitType {
1419 type Owned = TreeArc<ImplTraitType>;
1420 fn to_owned(&self) -> TreeArc<ImplTraitType> { TreeArc::cast(self.syntax.to_owned()) }
1424 impl ast::TypeBoundsOwner for ImplTraitType {}
1425 impl ImplTraitType {}
1428 #[derive(Debug, PartialEq, Eq, Hash)]
1429 #[repr(transparent)]
1430 pub struct IndexExpr {
1431 pub(crate) syntax: SyntaxNode,
1433 unsafe impl TransparentNewType for IndexExpr {
1434 type Repr = rowan::SyntaxNode;
1437 impl AstNode for IndexExpr {
1438 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1439 match syntax.kind() {
1440 INDEX_EXPR => Some(IndexExpr::from_repr(syntax.into_repr())),
1444 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1447 impl ToOwned for IndexExpr {
1448 type Owned = TreeArc<IndexExpr>;
1449 fn to_owned(&self) -> TreeArc<IndexExpr> { TreeArc::cast(self.syntax.to_owned()) }
1456 #[derive(Debug, PartialEq, Eq, Hash)]
1457 #[repr(transparent)]
1458 pub struct ItemList {
1459 pub(crate) syntax: SyntaxNode,
1461 unsafe impl TransparentNewType for ItemList {
1462 type Repr = rowan::SyntaxNode;
1465 impl AstNode for ItemList {
1466 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1467 match syntax.kind() {
1468 ITEM_LIST => Some(ItemList::from_repr(syntax.into_repr())),
1472 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1475 impl ToOwned for ItemList {
1476 type Owned = TreeArc<ItemList>;
1477 fn to_owned(&self) -> TreeArc<ItemList> { TreeArc::cast(self.syntax.to_owned()) }
1481 impl ast::FnDefOwner for ItemList {}
1482 impl ast::ModuleItemOwner for ItemList {}
1484 pub fn impl_items(&self) -> impl Iterator<Item = &ImplItem> {
1485 super::children(self)
1490 #[derive(Debug, PartialEq, Eq, Hash)]
1491 #[repr(transparent)]
1493 pub(crate) syntax: SyntaxNode,
1495 unsafe impl TransparentNewType for Label {
1496 type Repr = rowan::SyntaxNode;
1499 impl AstNode for Label {
1500 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1501 match syntax.kind() {
1502 LABEL => Some(Label::from_repr(syntax.into_repr())),
1506 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1509 impl ToOwned for Label {
1510 type Owned = TreeArc<Label>;
1511 fn to_owned(&self) -> TreeArc<Label> { TreeArc::cast(self.syntax.to_owned()) }
1518 #[derive(Debug, PartialEq, Eq, Hash)]
1519 #[repr(transparent)]
1520 pub struct LambdaExpr {
1521 pub(crate) syntax: SyntaxNode,
1523 unsafe impl TransparentNewType for LambdaExpr {
1524 type Repr = rowan::SyntaxNode;
1527 impl AstNode for LambdaExpr {
1528 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1529 match syntax.kind() {
1530 LAMBDA_EXPR => Some(LambdaExpr::from_repr(syntax.into_repr())),
1534 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1537 impl ToOwned for LambdaExpr {
1538 type Owned = TreeArc<LambdaExpr>;
1539 fn to_owned(&self) -> TreeArc<LambdaExpr> { TreeArc::cast(self.syntax.to_owned()) }
1544 pub fn param_list(&self) -> Option<&ParamList> {
1545 super::child_opt(self)
1548 pub fn body(&self) -> Option<&Expr> {
1549 super::child_opt(self)
1554 #[derive(Debug, PartialEq, Eq, Hash)]
1555 #[repr(transparent)]
1556 pub struct LetStmt {
1557 pub(crate) syntax: SyntaxNode,
1559 unsafe impl TransparentNewType for LetStmt {
1560 type Repr = rowan::SyntaxNode;
1563 impl AstNode for LetStmt {
1564 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1565 match syntax.kind() {
1566 LET_STMT => Some(LetStmt::from_repr(syntax.into_repr())),
1570 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1573 impl ToOwned for LetStmt {
1574 type Owned = TreeArc<LetStmt>;
1575 fn to_owned(&self) -> TreeArc<LetStmt> { TreeArc::cast(self.syntax.to_owned()) }
1579 impl ast::TypeAscriptionOwner for LetStmt {}
1581 pub fn pat(&self) -> Option<&Pat> {
1582 super::child_opt(self)
1585 pub fn initializer(&self) -> Option<&Expr> {
1586 super::child_opt(self)
1591 #[derive(Debug, PartialEq, Eq, Hash)]
1592 #[repr(transparent)]
1593 pub struct LifetimeArg {
1594 pub(crate) syntax: SyntaxNode,
1596 unsafe impl TransparentNewType for LifetimeArg {
1597 type Repr = rowan::SyntaxNode;
1600 impl AstNode for LifetimeArg {
1601 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1602 match syntax.kind() {
1603 LIFETIME_ARG => Some(LifetimeArg::from_repr(syntax.into_repr())),
1607 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1610 impl ToOwned for LifetimeArg {
1611 type Owned = TreeArc<LifetimeArg>;
1612 fn to_owned(&self) -> TreeArc<LifetimeArg> { TreeArc::cast(self.syntax.to_owned()) }
1619 #[derive(Debug, PartialEq, Eq, Hash)]
1620 #[repr(transparent)]
1621 pub struct LifetimeParam {
1622 pub(crate) syntax: SyntaxNode,
1624 unsafe impl TransparentNewType for LifetimeParam {
1625 type Repr = rowan::SyntaxNode;
1628 impl AstNode for LifetimeParam {
1629 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1630 match syntax.kind() {
1631 LIFETIME_PARAM => Some(LifetimeParam::from_repr(syntax.into_repr())),
1635 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1638 impl ToOwned for LifetimeParam {
1639 type Owned = TreeArc<LifetimeParam>;
1640 fn to_owned(&self) -> TreeArc<LifetimeParam> { TreeArc::cast(self.syntax.to_owned()) }
1644 impl ast::AttrsOwner for LifetimeParam {}
1645 impl LifetimeParam {}
1648 #[derive(Debug, PartialEq, Eq, Hash)]
1649 #[repr(transparent)]
1650 pub struct Literal {
1651 pub(crate) syntax: SyntaxNode,
1653 unsafe impl TransparentNewType for Literal {
1654 type Repr = rowan::SyntaxNode;
1657 impl AstNode for Literal {
1658 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1659 match syntax.kind() {
1660 LITERAL => Some(Literal::from_repr(syntax.into_repr())),
1664 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1667 impl ToOwned for Literal {
1668 type Owned = TreeArc<Literal>;
1669 fn to_owned(&self) -> TreeArc<Literal> { TreeArc::cast(self.syntax.to_owned()) }
1676 #[derive(Debug, PartialEq, Eq, Hash)]
1677 #[repr(transparent)]
1678 pub struct LiteralPat {
1679 pub(crate) syntax: SyntaxNode,
1681 unsafe impl TransparentNewType for LiteralPat {
1682 type Repr = rowan::SyntaxNode;
1685 impl AstNode for LiteralPat {
1686 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1687 match syntax.kind() {
1688 LITERAL_PAT => Some(LiteralPat::from_repr(syntax.into_repr())),
1692 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1695 impl ToOwned for LiteralPat {
1696 type Owned = TreeArc<LiteralPat>;
1697 fn to_owned(&self) -> TreeArc<LiteralPat> { TreeArc::cast(self.syntax.to_owned()) }
1702 pub fn literal(&self) -> Option<&Literal> {
1703 super::child_opt(self)
1708 #[derive(Debug, PartialEq, Eq, Hash)]
1709 #[repr(transparent)]
1710 pub struct LoopExpr {
1711 pub(crate) syntax: SyntaxNode,
1713 unsafe impl TransparentNewType for LoopExpr {
1714 type Repr = rowan::SyntaxNode;
1717 impl AstNode for LoopExpr {
1718 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1719 match syntax.kind() {
1720 LOOP_EXPR => Some(LoopExpr::from_repr(syntax.into_repr())),
1724 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1727 impl ToOwned for LoopExpr {
1728 type Owned = TreeArc<LoopExpr>;
1729 fn to_owned(&self) -> TreeArc<LoopExpr> { TreeArc::cast(self.syntax.to_owned()) }
1733 impl ast::LoopBodyOwner for LoopExpr {}
1737 #[derive(Debug, PartialEq, Eq, Hash)]
1738 #[repr(transparent)]
1739 pub struct MacroCall {
1740 pub(crate) syntax: SyntaxNode,
1742 unsafe impl TransparentNewType for MacroCall {
1743 type Repr = rowan::SyntaxNode;
1746 impl AstNode for MacroCall {
1747 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1748 match syntax.kind() {
1749 MACRO_CALL => Some(MacroCall::from_repr(syntax.into_repr())),
1753 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1756 impl ToOwned for MacroCall {
1757 type Owned = TreeArc<MacroCall>;
1758 fn to_owned(&self) -> TreeArc<MacroCall> { TreeArc::cast(self.syntax.to_owned()) }
1762 impl ast::NameOwner for MacroCall {}
1763 impl ast::AttrsOwner for MacroCall {}
1764 impl ast::DocCommentsOwner for MacroCall {}
1766 pub fn token_tree(&self) -> Option<&TokenTree> {
1767 super::child_opt(self)
1770 pub fn path(&self) -> Option<&Path> {
1771 super::child_opt(self)
1776 #[derive(Debug, PartialEq, Eq, Hash)]
1777 #[repr(transparent)]
1778 pub struct MacroItems {
1779 pub(crate) syntax: SyntaxNode,
1781 unsafe impl TransparentNewType for MacroItems {
1782 type Repr = rowan::SyntaxNode;
1785 impl AstNode for MacroItems {
1786 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1787 match syntax.kind() {
1788 MACRO_ITEMS => Some(MacroItems::from_repr(syntax.into_repr())),
1792 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1795 impl ToOwned for MacroItems {
1796 type Owned = TreeArc<MacroItems>;
1797 fn to_owned(&self) -> TreeArc<MacroItems> { TreeArc::cast(self.syntax.to_owned()) }
1801 impl ast::ModuleItemOwner for MacroItems {}
1802 impl ast::FnDefOwner for MacroItems {}
1806 #[derive(Debug, PartialEq, Eq, Hash)]
1807 #[repr(transparent)]
1808 pub struct MacroStmts {
1809 pub(crate) syntax: SyntaxNode,
1811 unsafe impl TransparentNewType for MacroStmts {
1812 type Repr = rowan::SyntaxNode;
1815 impl AstNode for MacroStmts {
1816 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1817 match syntax.kind() {
1818 MACRO_STMTS => Some(MacroStmts::from_repr(syntax.into_repr())),
1822 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1825 impl ToOwned for MacroStmts {
1826 type Owned = TreeArc<MacroStmts>;
1827 fn to_owned(&self) -> TreeArc<MacroStmts> { TreeArc::cast(self.syntax.to_owned()) }
1832 pub fn statements(&self) -> impl Iterator<Item = &Stmt> {
1833 super::children(self)
1836 pub fn expr(&self) -> Option<&Expr> {
1837 super::child_opt(self)
1842 #[derive(Debug, PartialEq, Eq, Hash)]
1843 #[repr(transparent)]
1844 pub struct MatchArm {
1845 pub(crate) syntax: SyntaxNode,
1847 unsafe impl TransparentNewType for MatchArm {
1848 type Repr = rowan::SyntaxNode;
1851 impl AstNode for MatchArm {
1852 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1853 match syntax.kind() {
1854 MATCH_ARM => Some(MatchArm::from_repr(syntax.into_repr())),
1858 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1861 impl ToOwned for MatchArm {
1862 type Owned = TreeArc<MatchArm>;
1863 fn to_owned(&self) -> TreeArc<MatchArm> { TreeArc::cast(self.syntax.to_owned()) }
1867 impl ast::AttrsOwner for MatchArm {}
1869 pub fn pats(&self) -> impl Iterator<Item = &Pat> {
1870 super::children(self)
1873 pub fn guard(&self) -> Option<&MatchGuard> {
1874 super::child_opt(self)
1877 pub fn expr(&self) -> Option<&Expr> {
1878 super::child_opt(self)
1883 #[derive(Debug, PartialEq, Eq, Hash)]
1884 #[repr(transparent)]
1885 pub struct MatchArmList {
1886 pub(crate) syntax: SyntaxNode,
1888 unsafe impl TransparentNewType for MatchArmList {
1889 type Repr = rowan::SyntaxNode;
1892 impl AstNode for MatchArmList {
1893 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1894 match syntax.kind() {
1895 MATCH_ARM_LIST => Some(MatchArmList::from_repr(syntax.into_repr())),
1899 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1902 impl ToOwned for MatchArmList {
1903 type Owned = TreeArc<MatchArmList>;
1904 fn to_owned(&self) -> TreeArc<MatchArmList> { TreeArc::cast(self.syntax.to_owned()) }
1908 impl ast::AttrsOwner for MatchArmList {}
1910 pub fn arms(&self) -> impl Iterator<Item = &MatchArm> {
1911 super::children(self)
1916 #[derive(Debug, PartialEq, Eq, Hash)]
1917 #[repr(transparent)]
1918 pub struct MatchExpr {
1919 pub(crate) syntax: SyntaxNode,
1921 unsafe impl TransparentNewType for MatchExpr {
1922 type Repr = rowan::SyntaxNode;
1925 impl AstNode for MatchExpr {
1926 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1927 match syntax.kind() {
1928 MATCH_EXPR => Some(MatchExpr::from_repr(syntax.into_repr())),
1932 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1935 impl ToOwned for MatchExpr {
1936 type Owned = TreeArc<MatchExpr>;
1937 fn to_owned(&self) -> TreeArc<MatchExpr> { TreeArc::cast(self.syntax.to_owned()) }
1942 pub fn expr(&self) -> Option<&Expr> {
1943 super::child_opt(self)
1946 pub fn match_arm_list(&self) -> Option<&MatchArmList> {
1947 super::child_opt(self)
1952 #[derive(Debug, PartialEq, Eq, Hash)]
1953 #[repr(transparent)]
1954 pub struct MatchGuard {
1955 pub(crate) syntax: SyntaxNode,
1957 unsafe impl TransparentNewType for MatchGuard {
1958 type Repr = rowan::SyntaxNode;
1961 impl AstNode for MatchGuard {
1962 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1963 match syntax.kind() {
1964 MATCH_GUARD => Some(MatchGuard::from_repr(syntax.into_repr())),
1968 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1971 impl ToOwned for MatchGuard {
1972 type Owned = TreeArc<MatchGuard>;
1973 fn to_owned(&self) -> TreeArc<MatchGuard> { TreeArc::cast(self.syntax.to_owned()) }
1978 pub fn expr(&self) -> Option<&Expr> {
1979 super::child_opt(self)
1984 #[derive(Debug, PartialEq, Eq, Hash)]
1985 #[repr(transparent)]
1986 pub struct MethodCallExpr {
1987 pub(crate) syntax: SyntaxNode,
1989 unsafe impl TransparentNewType for MethodCallExpr {
1990 type Repr = rowan::SyntaxNode;
1993 impl AstNode for MethodCallExpr {
1994 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1995 match syntax.kind() {
1996 METHOD_CALL_EXPR => Some(MethodCallExpr::from_repr(syntax.into_repr())),
2000 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2003 impl ToOwned for MethodCallExpr {
2004 type Owned = TreeArc<MethodCallExpr>;
2005 fn to_owned(&self) -> TreeArc<MethodCallExpr> { TreeArc::cast(self.syntax.to_owned()) }
2009 impl ast::ArgListOwner for MethodCallExpr {}
2010 impl MethodCallExpr {
2011 pub fn expr(&self) -> Option<&Expr> {
2012 super::child_opt(self)
2015 pub fn name_ref(&self) -> Option<&NameRef> {
2016 super::child_opt(self)
2019 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
2020 super::child_opt(self)
2025 #[derive(Debug, PartialEq, Eq, Hash)]
2026 #[repr(transparent)]
2028 pub(crate) syntax: SyntaxNode,
2030 unsafe impl TransparentNewType for Module {
2031 type Repr = rowan::SyntaxNode;
2034 impl AstNode for Module {
2035 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2036 match syntax.kind() {
2037 MODULE => Some(Module::from_repr(syntax.into_repr())),
2041 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2044 impl ToOwned for Module {
2045 type Owned = TreeArc<Module>;
2046 fn to_owned(&self) -> TreeArc<Module> { TreeArc::cast(self.syntax.to_owned()) }
2050 impl ast::VisibilityOwner for Module {}
2051 impl ast::NameOwner for Module {}
2052 impl ast::AttrsOwner for Module {}
2053 impl ast::DocCommentsOwner for Module {}
2055 pub fn item_list(&self) -> Option<&ItemList> {
2056 super::child_opt(self)
2061 #[derive(Debug, PartialEq, Eq, Hash)]
2062 #[repr(transparent)]
2063 pub struct ModuleItem {
2064 pub(crate) syntax: SyntaxNode,
2066 unsafe impl TransparentNewType for ModuleItem {
2067 type Repr = rowan::SyntaxNode;
2070 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2071 pub enum ModuleItemKind<'a> {
2072 StructDef(&'a StructDef),
2073 EnumDef(&'a EnumDef),
2075 TraitDef(&'a TraitDef),
2076 TypeAliasDef(&'a TypeAliasDef),
2077 ImplBlock(&'a ImplBlock),
2078 UseItem(&'a UseItem),
2079 ExternCrateItem(&'a ExternCrateItem),
2080 ConstDef(&'a ConstDef),
2081 StaticDef(&'a StaticDef),
2084 impl<'a> From<&'a StructDef> for &'a ModuleItem {
2085 fn from(n: &'a StructDef) -> &'a ModuleItem {
2086 ModuleItem::cast(&n.syntax).unwrap()
2089 impl<'a> From<&'a EnumDef> for &'a ModuleItem {
2090 fn from(n: &'a EnumDef) -> &'a ModuleItem {
2091 ModuleItem::cast(&n.syntax).unwrap()
2094 impl<'a> From<&'a FnDef> for &'a ModuleItem {
2095 fn from(n: &'a FnDef) -> &'a ModuleItem {
2096 ModuleItem::cast(&n.syntax).unwrap()
2099 impl<'a> From<&'a TraitDef> for &'a ModuleItem {
2100 fn from(n: &'a TraitDef) -> &'a ModuleItem {
2101 ModuleItem::cast(&n.syntax).unwrap()
2104 impl<'a> From<&'a TypeAliasDef> for &'a ModuleItem {
2105 fn from(n: &'a TypeAliasDef) -> &'a ModuleItem {
2106 ModuleItem::cast(&n.syntax).unwrap()
2109 impl<'a> From<&'a ImplBlock> for &'a ModuleItem {
2110 fn from(n: &'a ImplBlock) -> &'a ModuleItem {
2111 ModuleItem::cast(&n.syntax).unwrap()
2114 impl<'a> From<&'a UseItem> for &'a ModuleItem {
2115 fn from(n: &'a UseItem) -> &'a ModuleItem {
2116 ModuleItem::cast(&n.syntax).unwrap()
2119 impl<'a> From<&'a ExternCrateItem> for &'a ModuleItem {
2120 fn from(n: &'a ExternCrateItem) -> &'a ModuleItem {
2121 ModuleItem::cast(&n.syntax).unwrap()
2124 impl<'a> From<&'a ConstDef> for &'a ModuleItem {
2125 fn from(n: &'a ConstDef) -> &'a ModuleItem {
2126 ModuleItem::cast(&n.syntax).unwrap()
2129 impl<'a> From<&'a StaticDef> for &'a ModuleItem {
2130 fn from(n: &'a StaticDef) -> &'a ModuleItem {
2131 ModuleItem::cast(&n.syntax).unwrap()
2134 impl<'a> From<&'a Module> for &'a ModuleItem {
2135 fn from(n: &'a Module) -> &'a ModuleItem {
2136 ModuleItem::cast(&n.syntax).unwrap()
2141 impl AstNode for ModuleItem {
2142 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2143 match syntax.kind() {
2154 | MODULE => Some(ModuleItem::from_repr(syntax.into_repr())),
2158 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2161 impl ToOwned for ModuleItem {
2162 type Owned = TreeArc<ModuleItem>;
2163 fn to_owned(&self) -> TreeArc<ModuleItem> { TreeArc::cast(self.syntax.to_owned()) }
2167 pub fn kind(&self) -> ModuleItemKind {
2168 match self.syntax.kind() {
2169 STRUCT_DEF => ModuleItemKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2170 ENUM_DEF => ModuleItemKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2171 FN_DEF => ModuleItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
2172 TRAIT_DEF => ModuleItemKind::TraitDef(TraitDef::cast(&self.syntax).unwrap()),
2173 TYPE_ALIAS_DEF => ModuleItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
2174 IMPL_BLOCK => ModuleItemKind::ImplBlock(ImplBlock::cast(&self.syntax).unwrap()),
2175 USE_ITEM => ModuleItemKind::UseItem(UseItem::cast(&self.syntax).unwrap()),
2176 EXTERN_CRATE_ITEM => ModuleItemKind::ExternCrateItem(ExternCrateItem::cast(&self.syntax).unwrap()),
2177 CONST_DEF => ModuleItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
2178 STATIC_DEF => ModuleItemKind::StaticDef(StaticDef::cast(&self.syntax).unwrap()),
2179 MODULE => ModuleItemKind::Module(Module::cast(&self.syntax).unwrap()),
2180 _ => unreachable!(),
2188 #[derive(Debug, PartialEq, Eq, Hash)]
2189 #[repr(transparent)]
2191 pub(crate) syntax: SyntaxNode,
2193 unsafe impl TransparentNewType for Name {
2194 type Repr = rowan::SyntaxNode;
2197 impl AstNode for Name {
2198 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2199 match syntax.kind() {
2200 NAME => Some(Name::from_repr(syntax.into_repr())),
2204 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2207 impl ToOwned for Name {
2208 type Owned = TreeArc<Name>;
2209 fn to_owned(&self) -> TreeArc<Name> { TreeArc::cast(self.syntax.to_owned()) }
2216 #[derive(Debug, PartialEq, Eq, Hash)]
2217 #[repr(transparent)]
2218 pub struct NameRef {
2219 pub(crate) syntax: SyntaxNode,
2221 unsafe impl TransparentNewType for NameRef {
2222 type Repr = rowan::SyntaxNode;
2225 impl AstNode for NameRef {
2226 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2227 match syntax.kind() {
2228 NAME_REF => Some(NameRef::from_repr(syntax.into_repr())),
2232 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2235 impl ToOwned for NameRef {
2236 type Owned = TreeArc<NameRef>;
2237 fn to_owned(&self) -> TreeArc<NameRef> { TreeArc::cast(self.syntax.to_owned()) }
2244 #[derive(Debug, PartialEq, Eq, Hash)]
2245 #[repr(transparent)]
2246 pub struct NamedField {
2247 pub(crate) syntax: SyntaxNode,
2249 unsafe impl TransparentNewType for NamedField {
2250 type Repr = rowan::SyntaxNode;
2253 impl AstNode for NamedField {
2254 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2255 match syntax.kind() {
2256 NAMED_FIELD => Some(NamedField::from_repr(syntax.into_repr())),
2260 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2263 impl ToOwned for NamedField {
2264 type Owned = TreeArc<NamedField>;
2265 fn to_owned(&self) -> TreeArc<NamedField> { TreeArc::cast(self.syntax.to_owned()) }
2270 pub fn name_ref(&self) -> Option<&NameRef> {
2271 super::child_opt(self)
2274 pub fn expr(&self) -> Option<&Expr> {
2275 super::child_opt(self)
2280 #[derive(Debug, PartialEq, Eq, Hash)]
2281 #[repr(transparent)]
2282 pub struct NamedFieldDef {
2283 pub(crate) syntax: SyntaxNode,
2285 unsafe impl TransparentNewType for NamedFieldDef {
2286 type Repr = rowan::SyntaxNode;
2289 impl AstNode for NamedFieldDef {
2290 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2291 match syntax.kind() {
2292 NAMED_FIELD_DEF => Some(NamedFieldDef::from_repr(syntax.into_repr())),
2296 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2299 impl ToOwned for NamedFieldDef {
2300 type Owned = TreeArc<NamedFieldDef>;
2301 fn to_owned(&self) -> TreeArc<NamedFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2305 impl ast::VisibilityOwner for NamedFieldDef {}
2306 impl ast::NameOwner for NamedFieldDef {}
2307 impl ast::AttrsOwner for NamedFieldDef {}
2308 impl ast::DocCommentsOwner for NamedFieldDef {}
2309 impl ast::TypeAscriptionOwner for NamedFieldDef {}
2310 impl NamedFieldDef {}
2312 // NamedFieldDefList
2313 #[derive(Debug, PartialEq, Eq, Hash)]
2314 #[repr(transparent)]
2315 pub struct NamedFieldDefList {
2316 pub(crate) syntax: SyntaxNode,
2318 unsafe impl TransparentNewType for NamedFieldDefList {
2319 type Repr = rowan::SyntaxNode;
2322 impl AstNode for NamedFieldDefList {
2323 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2324 match syntax.kind() {
2325 NAMED_FIELD_DEF_LIST => Some(NamedFieldDefList::from_repr(syntax.into_repr())),
2329 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2332 impl ToOwned for NamedFieldDefList {
2333 type Owned = TreeArc<NamedFieldDefList>;
2334 fn to_owned(&self) -> TreeArc<NamedFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
2338 impl NamedFieldDefList {
2339 pub fn fields(&self) -> impl Iterator<Item = &NamedFieldDef> {
2340 super::children(self)
2345 #[derive(Debug, PartialEq, Eq, Hash)]
2346 #[repr(transparent)]
2347 pub struct NamedFieldList {
2348 pub(crate) syntax: SyntaxNode,
2350 unsafe impl TransparentNewType for NamedFieldList {
2351 type Repr = rowan::SyntaxNode;
2354 impl AstNode for NamedFieldList {
2355 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2356 match syntax.kind() {
2357 NAMED_FIELD_LIST => Some(NamedFieldList::from_repr(syntax.into_repr())),
2361 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2364 impl ToOwned for NamedFieldList {
2365 type Owned = TreeArc<NamedFieldList>;
2366 fn to_owned(&self) -> TreeArc<NamedFieldList> { TreeArc::cast(self.syntax.to_owned()) }
2370 impl NamedFieldList {
2371 pub fn fields(&self) -> impl Iterator<Item = &NamedField> {
2372 super::children(self)
2375 pub fn spread(&self) -> Option<&Expr> {
2376 super::child_opt(self)
2381 #[derive(Debug, PartialEq, Eq, Hash)]
2382 #[repr(transparent)]
2383 pub struct NeverType {
2384 pub(crate) syntax: SyntaxNode,
2386 unsafe impl TransparentNewType for NeverType {
2387 type Repr = rowan::SyntaxNode;
2390 impl AstNode for NeverType {
2391 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2392 match syntax.kind() {
2393 NEVER_TYPE => Some(NeverType::from_repr(syntax.into_repr())),
2397 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2400 impl ToOwned for NeverType {
2401 type Owned = TreeArc<NeverType>;
2402 fn to_owned(&self) -> TreeArc<NeverType> { TreeArc::cast(self.syntax.to_owned()) }
2409 #[derive(Debug, PartialEq, Eq, Hash)]
2410 #[repr(transparent)]
2411 pub struct NominalDef {
2412 pub(crate) syntax: SyntaxNode,
2414 unsafe impl TransparentNewType for NominalDef {
2415 type Repr = rowan::SyntaxNode;
2418 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2419 pub enum NominalDefKind<'a> {
2420 StructDef(&'a StructDef),
2421 EnumDef(&'a EnumDef),
2423 impl<'a> From<&'a StructDef> for &'a NominalDef {
2424 fn from(n: &'a StructDef) -> &'a NominalDef {
2425 NominalDef::cast(&n.syntax).unwrap()
2428 impl<'a> From<&'a EnumDef> for &'a NominalDef {
2429 fn from(n: &'a EnumDef) -> &'a NominalDef {
2430 NominalDef::cast(&n.syntax).unwrap()
2435 impl AstNode for NominalDef {
2436 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2437 match syntax.kind() {
2439 | ENUM_DEF => Some(NominalDef::from_repr(syntax.into_repr())),
2443 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2446 impl ToOwned for NominalDef {
2447 type Owned = TreeArc<NominalDef>;
2448 fn to_owned(&self) -> TreeArc<NominalDef> { TreeArc::cast(self.syntax.to_owned()) }
2452 pub fn kind(&self) -> NominalDefKind {
2453 match self.syntax.kind() {
2454 STRUCT_DEF => NominalDefKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2455 ENUM_DEF => NominalDefKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2456 _ => unreachable!(),
2461 impl ast::NameOwner for NominalDef {}
2462 impl ast::TypeParamsOwner for NominalDef {}
2463 impl ast::AttrsOwner for NominalDef {}
2467 #[derive(Debug, PartialEq, Eq, Hash)]
2468 #[repr(transparent)]
2470 pub(crate) syntax: SyntaxNode,
2472 unsafe impl TransparentNewType for Param {
2473 type Repr = rowan::SyntaxNode;
2476 impl AstNode for Param {
2477 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2478 match syntax.kind() {
2479 PARAM => Some(Param::from_repr(syntax.into_repr())),
2483 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2486 impl ToOwned for Param {
2487 type Owned = TreeArc<Param>;
2488 fn to_owned(&self) -> TreeArc<Param> { TreeArc::cast(self.syntax.to_owned()) }
2492 impl ast::TypeAscriptionOwner for Param {}
2494 pub fn pat(&self) -> Option<&Pat> {
2495 super::child_opt(self)
2500 #[derive(Debug, PartialEq, Eq, Hash)]
2501 #[repr(transparent)]
2502 pub struct ParamList {
2503 pub(crate) syntax: SyntaxNode,
2505 unsafe impl TransparentNewType for ParamList {
2506 type Repr = rowan::SyntaxNode;
2509 impl AstNode for ParamList {
2510 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2511 match syntax.kind() {
2512 PARAM_LIST => Some(ParamList::from_repr(syntax.into_repr())),
2516 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2519 impl ToOwned for ParamList {
2520 type Owned = TreeArc<ParamList>;
2521 fn to_owned(&self) -> TreeArc<ParamList> { TreeArc::cast(self.syntax.to_owned()) }
2526 pub fn params(&self) -> impl Iterator<Item = &Param> {
2527 super::children(self)
2530 pub fn self_param(&self) -> Option<&SelfParam> {
2531 super::child_opt(self)
2536 #[derive(Debug, PartialEq, Eq, Hash)]
2537 #[repr(transparent)]
2538 pub struct ParenExpr {
2539 pub(crate) syntax: SyntaxNode,
2541 unsafe impl TransparentNewType for ParenExpr {
2542 type Repr = rowan::SyntaxNode;
2545 impl AstNode for ParenExpr {
2546 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2547 match syntax.kind() {
2548 PAREN_EXPR => Some(ParenExpr::from_repr(syntax.into_repr())),
2552 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2555 impl ToOwned for ParenExpr {
2556 type Owned = TreeArc<ParenExpr>;
2557 fn to_owned(&self) -> TreeArc<ParenExpr> { TreeArc::cast(self.syntax.to_owned()) }
2562 pub fn expr(&self) -> Option<&Expr> {
2563 super::child_opt(self)
2568 #[derive(Debug, PartialEq, Eq, Hash)]
2569 #[repr(transparent)]
2570 pub struct ParenType {
2571 pub(crate) syntax: SyntaxNode,
2573 unsafe impl TransparentNewType for ParenType {
2574 type Repr = rowan::SyntaxNode;
2577 impl AstNode for ParenType {
2578 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2579 match syntax.kind() {
2580 PAREN_TYPE => Some(ParenType::from_repr(syntax.into_repr())),
2584 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2587 impl ToOwned for ParenType {
2588 type Owned = TreeArc<ParenType>;
2589 fn to_owned(&self) -> TreeArc<ParenType> { TreeArc::cast(self.syntax.to_owned()) }
2594 pub fn type_ref(&self) -> Option<&TypeRef> {
2595 super::child_opt(self)
2600 #[derive(Debug, PartialEq, Eq, Hash)]
2601 #[repr(transparent)]
2603 pub(crate) syntax: SyntaxNode,
2605 unsafe impl TransparentNewType for Pat {
2606 type Repr = rowan::SyntaxNode;
2609 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2610 pub enum PatKind<'a> {
2612 BindPat(&'a BindPat),
2613 PlaceholderPat(&'a PlaceholderPat),
2614 PathPat(&'a PathPat),
2615 StructPat(&'a StructPat),
2616 TupleStructPat(&'a TupleStructPat),
2617 TuplePat(&'a TuplePat),
2618 SlicePat(&'a SlicePat),
2619 RangePat(&'a RangePat),
2620 LiteralPat(&'a LiteralPat),
2622 impl<'a> From<&'a RefPat> for &'a Pat {
2623 fn from(n: &'a RefPat) -> &'a Pat {
2624 Pat::cast(&n.syntax).unwrap()
2627 impl<'a> From<&'a BindPat> for &'a Pat {
2628 fn from(n: &'a BindPat) -> &'a Pat {
2629 Pat::cast(&n.syntax).unwrap()
2632 impl<'a> From<&'a PlaceholderPat> for &'a Pat {
2633 fn from(n: &'a PlaceholderPat) -> &'a Pat {
2634 Pat::cast(&n.syntax).unwrap()
2637 impl<'a> From<&'a PathPat> for &'a Pat {
2638 fn from(n: &'a PathPat) -> &'a Pat {
2639 Pat::cast(&n.syntax).unwrap()
2642 impl<'a> From<&'a StructPat> for &'a Pat {
2643 fn from(n: &'a StructPat) -> &'a Pat {
2644 Pat::cast(&n.syntax).unwrap()
2647 impl<'a> From<&'a TupleStructPat> for &'a Pat {
2648 fn from(n: &'a TupleStructPat) -> &'a Pat {
2649 Pat::cast(&n.syntax).unwrap()
2652 impl<'a> From<&'a TuplePat> for &'a Pat {
2653 fn from(n: &'a TuplePat) -> &'a Pat {
2654 Pat::cast(&n.syntax).unwrap()
2657 impl<'a> From<&'a SlicePat> for &'a Pat {
2658 fn from(n: &'a SlicePat) -> &'a Pat {
2659 Pat::cast(&n.syntax).unwrap()
2662 impl<'a> From<&'a RangePat> for &'a Pat {
2663 fn from(n: &'a RangePat) -> &'a Pat {
2664 Pat::cast(&n.syntax).unwrap()
2667 impl<'a> From<&'a LiteralPat> for &'a Pat {
2668 fn from(n: &'a LiteralPat) -> &'a Pat {
2669 Pat::cast(&n.syntax).unwrap()
2674 impl AstNode for Pat {
2675 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2676 match syntax.kind() {
2686 | LITERAL_PAT => Some(Pat::from_repr(syntax.into_repr())),
2690 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2693 impl ToOwned for Pat {
2694 type Owned = TreeArc<Pat>;
2695 fn to_owned(&self) -> TreeArc<Pat> { TreeArc::cast(self.syntax.to_owned()) }
2699 pub fn kind(&self) -> PatKind {
2700 match self.syntax.kind() {
2701 REF_PAT => PatKind::RefPat(RefPat::cast(&self.syntax).unwrap()),
2702 BIND_PAT => PatKind::BindPat(BindPat::cast(&self.syntax).unwrap()),
2703 PLACEHOLDER_PAT => PatKind::PlaceholderPat(PlaceholderPat::cast(&self.syntax).unwrap()),
2704 PATH_PAT => PatKind::PathPat(PathPat::cast(&self.syntax).unwrap()),
2705 STRUCT_PAT => PatKind::StructPat(StructPat::cast(&self.syntax).unwrap()),
2706 TUPLE_STRUCT_PAT => PatKind::TupleStructPat(TupleStructPat::cast(&self.syntax).unwrap()),
2707 TUPLE_PAT => PatKind::TuplePat(TuplePat::cast(&self.syntax).unwrap()),
2708 SLICE_PAT => PatKind::SlicePat(SlicePat::cast(&self.syntax).unwrap()),
2709 RANGE_PAT => PatKind::RangePat(RangePat::cast(&self.syntax).unwrap()),
2710 LITERAL_PAT => PatKind::LiteralPat(LiteralPat::cast(&self.syntax).unwrap()),
2711 _ => unreachable!(),
2719 #[derive(Debug, PartialEq, Eq, Hash)]
2720 #[repr(transparent)]
2722 pub(crate) syntax: SyntaxNode,
2724 unsafe impl TransparentNewType for Path {
2725 type Repr = rowan::SyntaxNode;
2728 impl AstNode for Path {
2729 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2730 match syntax.kind() {
2731 PATH => Some(Path::from_repr(syntax.into_repr())),
2735 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2738 impl ToOwned for Path {
2739 type Owned = TreeArc<Path>;
2740 fn to_owned(&self) -> TreeArc<Path> { TreeArc::cast(self.syntax.to_owned()) }
2745 pub fn segment(&self) -> Option<&PathSegment> {
2746 super::child_opt(self)
2749 pub fn qualifier(&self) -> Option<&Path> {
2750 super::child_opt(self)
2755 #[derive(Debug, PartialEq, Eq, Hash)]
2756 #[repr(transparent)]
2757 pub struct PathExpr {
2758 pub(crate) syntax: SyntaxNode,
2760 unsafe impl TransparentNewType for PathExpr {
2761 type Repr = rowan::SyntaxNode;
2764 impl AstNode for PathExpr {
2765 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2766 match syntax.kind() {
2767 PATH_EXPR => Some(PathExpr::from_repr(syntax.into_repr())),
2771 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2774 impl ToOwned for PathExpr {
2775 type Owned = TreeArc<PathExpr>;
2776 fn to_owned(&self) -> TreeArc<PathExpr> { TreeArc::cast(self.syntax.to_owned()) }
2781 pub fn path(&self) -> Option<&Path> {
2782 super::child_opt(self)
2787 #[derive(Debug, PartialEq, Eq, Hash)]
2788 #[repr(transparent)]
2789 pub struct PathPat {
2790 pub(crate) syntax: SyntaxNode,
2792 unsafe impl TransparentNewType for PathPat {
2793 type Repr = rowan::SyntaxNode;
2796 impl AstNode for PathPat {
2797 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2798 match syntax.kind() {
2799 PATH_PAT => Some(PathPat::from_repr(syntax.into_repr())),
2803 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2806 impl ToOwned for PathPat {
2807 type Owned = TreeArc<PathPat>;
2808 fn to_owned(&self) -> TreeArc<PathPat> { TreeArc::cast(self.syntax.to_owned()) }
2813 pub fn path(&self) -> Option<&Path> {
2814 super::child_opt(self)
2819 #[derive(Debug, PartialEq, Eq, Hash)]
2820 #[repr(transparent)]
2821 pub struct PathSegment {
2822 pub(crate) syntax: SyntaxNode,
2824 unsafe impl TransparentNewType for PathSegment {
2825 type Repr = rowan::SyntaxNode;
2828 impl AstNode for PathSegment {
2829 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2830 match syntax.kind() {
2831 PATH_SEGMENT => Some(PathSegment::from_repr(syntax.into_repr())),
2835 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2838 impl ToOwned for PathSegment {
2839 type Owned = TreeArc<PathSegment>;
2840 fn to_owned(&self) -> TreeArc<PathSegment> { TreeArc::cast(self.syntax.to_owned()) }
2845 pub fn name_ref(&self) -> Option<&NameRef> {
2846 super::child_opt(self)
2849 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
2850 super::child_opt(self)
2855 #[derive(Debug, PartialEq, Eq, Hash)]
2856 #[repr(transparent)]
2857 pub struct PathType {
2858 pub(crate) syntax: SyntaxNode,
2860 unsafe impl TransparentNewType for PathType {
2861 type Repr = rowan::SyntaxNode;
2864 impl AstNode for PathType {
2865 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2866 match syntax.kind() {
2867 PATH_TYPE => Some(PathType::from_repr(syntax.into_repr())),
2871 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2874 impl ToOwned for PathType {
2875 type Owned = TreeArc<PathType>;
2876 fn to_owned(&self) -> TreeArc<PathType> { TreeArc::cast(self.syntax.to_owned()) }
2881 pub fn path(&self) -> Option<&Path> {
2882 super::child_opt(self)
2887 #[derive(Debug, PartialEq, Eq, Hash)]
2888 #[repr(transparent)]
2889 pub struct PlaceholderPat {
2890 pub(crate) syntax: SyntaxNode,
2892 unsafe impl TransparentNewType for PlaceholderPat {
2893 type Repr = rowan::SyntaxNode;
2896 impl AstNode for PlaceholderPat {
2897 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2898 match syntax.kind() {
2899 PLACEHOLDER_PAT => Some(PlaceholderPat::from_repr(syntax.into_repr())),
2903 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2906 impl ToOwned for PlaceholderPat {
2907 type Owned = TreeArc<PlaceholderPat>;
2908 fn to_owned(&self) -> TreeArc<PlaceholderPat> { TreeArc::cast(self.syntax.to_owned()) }
2912 impl PlaceholderPat {}
2915 #[derive(Debug, PartialEq, Eq, Hash)]
2916 #[repr(transparent)]
2917 pub struct PlaceholderType {
2918 pub(crate) syntax: SyntaxNode,
2920 unsafe impl TransparentNewType for PlaceholderType {
2921 type Repr = rowan::SyntaxNode;
2924 impl AstNode for PlaceholderType {
2925 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2926 match syntax.kind() {
2927 PLACEHOLDER_TYPE => Some(PlaceholderType::from_repr(syntax.into_repr())),
2931 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2934 impl ToOwned for PlaceholderType {
2935 type Owned = TreeArc<PlaceholderType>;
2936 fn to_owned(&self) -> TreeArc<PlaceholderType> { TreeArc::cast(self.syntax.to_owned()) }
2940 impl PlaceholderType {}
2943 #[derive(Debug, PartialEq, Eq, Hash)]
2944 #[repr(transparent)]
2945 pub struct PointerType {
2946 pub(crate) syntax: SyntaxNode,
2948 unsafe impl TransparentNewType for PointerType {
2949 type Repr = rowan::SyntaxNode;
2952 impl AstNode for PointerType {
2953 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2954 match syntax.kind() {
2955 POINTER_TYPE => Some(PointerType::from_repr(syntax.into_repr())),
2959 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2962 impl ToOwned for PointerType {
2963 type Owned = TreeArc<PointerType>;
2964 fn to_owned(&self) -> TreeArc<PointerType> { TreeArc::cast(self.syntax.to_owned()) }
2969 pub fn type_ref(&self) -> Option<&TypeRef> {
2970 super::child_opt(self)
2975 #[derive(Debug, PartialEq, Eq, Hash)]
2976 #[repr(transparent)]
2977 pub struct PosFieldDef {
2978 pub(crate) syntax: SyntaxNode,
2980 unsafe impl TransparentNewType for PosFieldDef {
2981 type Repr = rowan::SyntaxNode;
2984 impl AstNode for PosFieldDef {
2985 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2986 match syntax.kind() {
2987 POS_FIELD_DEF => Some(PosFieldDef::from_repr(syntax.into_repr())),
2991 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2994 impl ToOwned for PosFieldDef {
2995 type Owned = TreeArc<PosFieldDef>;
2996 fn to_owned(&self) -> TreeArc<PosFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
3000 impl ast::VisibilityOwner for PosFieldDef {}
3001 impl ast::AttrsOwner for PosFieldDef {}
3003 pub fn type_ref(&self) -> Option<&TypeRef> {
3004 super::child_opt(self)
3009 #[derive(Debug, PartialEq, Eq, Hash)]
3010 #[repr(transparent)]
3011 pub struct PosFieldDefList {
3012 pub(crate) syntax: SyntaxNode,
3014 unsafe impl TransparentNewType for PosFieldDefList {
3015 type Repr = rowan::SyntaxNode;
3018 impl AstNode for PosFieldDefList {
3019 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3020 match syntax.kind() {
3021 POS_FIELD_DEF_LIST => Some(PosFieldDefList::from_repr(syntax.into_repr())),
3025 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3028 impl ToOwned for PosFieldDefList {
3029 type Owned = TreeArc<PosFieldDefList>;
3030 fn to_owned(&self) -> TreeArc<PosFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
3034 impl PosFieldDefList {
3035 pub fn fields(&self) -> impl Iterator<Item = &PosFieldDef> {
3036 super::children(self)
3041 #[derive(Debug, PartialEq, Eq, Hash)]
3042 #[repr(transparent)]
3043 pub struct PrefixExpr {
3044 pub(crate) syntax: SyntaxNode,
3046 unsafe impl TransparentNewType for PrefixExpr {
3047 type Repr = rowan::SyntaxNode;
3050 impl AstNode for PrefixExpr {
3051 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3052 match syntax.kind() {
3053 PREFIX_EXPR => Some(PrefixExpr::from_repr(syntax.into_repr())),
3057 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3060 impl ToOwned for PrefixExpr {
3061 type Owned = TreeArc<PrefixExpr>;
3062 fn to_owned(&self) -> TreeArc<PrefixExpr> { TreeArc::cast(self.syntax.to_owned()) }
3067 pub fn expr(&self) -> Option<&Expr> {
3068 super::child_opt(self)
3073 #[derive(Debug, PartialEq, Eq, Hash)]
3074 #[repr(transparent)]
3075 pub struct RangeExpr {
3076 pub(crate) syntax: SyntaxNode,
3078 unsafe impl TransparentNewType for RangeExpr {
3079 type Repr = rowan::SyntaxNode;
3082 impl AstNode for RangeExpr {
3083 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3084 match syntax.kind() {
3085 RANGE_EXPR => Some(RangeExpr::from_repr(syntax.into_repr())),
3089 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3092 impl ToOwned for RangeExpr {
3093 type Owned = TreeArc<RangeExpr>;
3094 fn to_owned(&self) -> TreeArc<RangeExpr> { TreeArc::cast(self.syntax.to_owned()) }
3101 #[derive(Debug, PartialEq, Eq, Hash)]
3102 #[repr(transparent)]
3103 pub struct RangePat {
3104 pub(crate) syntax: SyntaxNode,
3106 unsafe impl TransparentNewType for RangePat {
3107 type Repr = rowan::SyntaxNode;
3110 impl AstNode for RangePat {
3111 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3112 match syntax.kind() {
3113 RANGE_PAT => Some(RangePat::from_repr(syntax.into_repr())),
3117 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3120 impl ToOwned for RangePat {
3121 type Owned = TreeArc<RangePat>;
3122 fn to_owned(&self) -> TreeArc<RangePat> { TreeArc::cast(self.syntax.to_owned()) }
3129 #[derive(Debug, PartialEq, Eq, Hash)]
3130 #[repr(transparent)]
3131 pub struct RefExpr {
3132 pub(crate) syntax: SyntaxNode,
3134 unsafe impl TransparentNewType for RefExpr {
3135 type Repr = rowan::SyntaxNode;
3138 impl AstNode for RefExpr {
3139 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3140 match syntax.kind() {
3141 REF_EXPR => Some(RefExpr::from_repr(syntax.into_repr())),
3145 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3148 impl ToOwned for RefExpr {
3149 type Owned = TreeArc<RefExpr>;
3150 fn to_owned(&self) -> TreeArc<RefExpr> { TreeArc::cast(self.syntax.to_owned()) }
3155 pub fn expr(&self) -> Option<&Expr> {
3156 super::child_opt(self)
3161 #[derive(Debug, PartialEq, Eq, Hash)]
3162 #[repr(transparent)]
3164 pub(crate) syntax: SyntaxNode,
3166 unsafe impl TransparentNewType for RefPat {
3167 type Repr = rowan::SyntaxNode;
3170 impl AstNode for RefPat {
3171 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3172 match syntax.kind() {
3173 REF_PAT => Some(RefPat::from_repr(syntax.into_repr())),
3177 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3180 impl ToOwned for RefPat {
3181 type Owned = TreeArc<RefPat>;
3182 fn to_owned(&self) -> TreeArc<RefPat> { TreeArc::cast(self.syntax.to_owned()) }
3187 pub fn pat(&self) -> Option<&Pat> {
3188 super::child_opt(self)
3193 #[derive(Debug, PartialEq, Eq, Hash)]
3194 #[repr(transparent)]
3195 pub struct ReferenceType {
3196 pub(crate) syntax: SyntaxNode,
3198 unsafe impl TransparentNewType for ReferenceType {
3199 type Repr = rowan::SyntaxNode;
3202 impl AstNode for ReferenceType {
3203 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3204 match syntax.kind() {
3205 REFERENCE_TYPE => Some(ReferenceType::from_repr(syntax.into_repr())),
3209 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3212 impl ToOwned for ReferenceType {
3213 type Owned = TreeArc<ReferenceType>;
3214 fn to_owned(&self) -> TreeArc<ReferenceType> { TreeArc::cast(self.syntax.to_owned()) }
3218 impl ReferenceType {
3219 pub fn type_ref(&self) -> Option<&TypeRef> {
3220 super::child_opt(self)
3225 #[derive(Debug, PartialEq, Eq, Hash)]
3226 #[repr(transparent)]
3227 pub struct RetType {
3228 pub(crate) syntax: SyntaxNode,
3230 unsafe impl TransparentNewType for RetType {
3231 type Repr = rowan::SyntaxNode;
3234 impl AstNode for RetType {
3235 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3236 match syntax.kind() {
3237 RET_TYPE => Some(RetType::from_repr(syntax.into_repr())),
3241 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3244 impl ToOwned for RetType {
3245 type Owned = TreeArc<RetType>;
3246 fn to_owned(&self) -> TreeArc<RetType> { TreeArc::cast(self.syntax.to_owned()) }
3251 pub fn type_ref(&self) -> Option<&TypeRef> {
3252 super::child_opt(self)
3257 #[derive(Debug, PartialEq, Eq, Hash)]
3258 #[repr(transparent)]
3259 pub struct ReturnExpr {
3260 pub(crate) syntax: SyntaxNode,
3262 unsafe impl TransparentNewType for ReturnExpr {
3263 type Repr = rowan::SyntaxNode;
3266 impl AstNode for ReturnExpr {
3267 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3268 match syntax.kind() {
3269 RETURN_EXPR => Some(ReturnExpr::from_repr(syntax.into_repr())),
3273 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3276 impl ToOwned for ReturnExpr {
3277 type Owned = TreeArc<ReturnExpr>;
3278 fn to_owned(&self) -> TreeArc<ReturnExpr> { TreeArc::cast(self.syntax.to_owned()) }
3283 pub fn expr(&self) -> Option<&Expr> {
3284 super::child_opt(self)
3289 #[derive(Debug, PartialEq, Eq, Hash)]
3290 #[repr(transparent)]
3291 pub struct SelfParam {
3292 pub(crate) syntax: SyntaxNode,
3294 unsafe impl TransparentNewType for SelfParam {
3295 type Repr = rowan::SyntaxNode;
3298 impl AstNode for SelfParam {
3299 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3300 match syntax.kind() {
3301 SELF_PARAM => Some(SelfParam::from_repr(syntax.into_repr())),
3305 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3308 impl ToOwned for SelfParam {
3309 type Owned = TreeArc<SelfParam>;
3310 fn to_owned(&self) -> TreeArc<SelfParam> { TreeArc::cast(self.syntax.to_owned()) }
3314 impl ast::TypeAscriptionOwner for SelfParam {}
3318 #[derive(Debug, PartialEq, Eq, Hash)]
3319 #[repr(transparent)]
3320 pub struct SlicePat {
3321 pub(crate) syntax: SyntaxNode,
3323 unsafe impl TransparentNewType for SlicePat {
3324 type Repr = rowan::SyntaxNode;
3327 impl AstNode for SlicePat {
3328 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3329 match syntax.kind() {
3330 SLICE_PAT => Some(SlicePat::from_repr(syntax.into_repr())),
3334 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3337 impl ToOwned for SlicePat {
3338 type Owned = TreeArc<SlicePat>;
3339 fn to_owned(&self) -> TreeArc<SlicePat> { TreeArc::cast(self.syntax.to_owned()) }
3346 #[derive(Debug, PartialEq, Eq, Hash)]
3347 #[repr(transparent)]
3348 pub struct SliceType {
3349 pub(crate) syntax: SyntaxNode,
3351 unsafe impl TransparentNewType for SliceType {
3352 type Repr = rowan::SyntaxNode;
3355 impl AstNode for SliceType {
3356 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3357 match syntax.kind() {
3358 SLICE_TYPE => Some(SliceType::from_repr(syntax.into_repr())),
3362 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3365 impl ToOwned for SliceType {
3366 type Owned = TreeArc<SliceType>;
3367 fn to_owned(&self) -> TreeArc<SliceType> { TreeArc::cast(self.syntax.to_owned()) }
3372 pub fn type_ref(&self) -> Option<&TypeRef> {
3373 super::child_opt(self)
3378 #[derive(Debug, PartialEq, Eq, Hash)]
3379 #[repr(transparent)]
3380 pub struct SourceFile {
3381 pub(crate) syntax: SyntaxNode,
3383 unsafe impl TransparentNewType for SourceFile {
3384 type Repr = rowan::SyntaxNode;
3387 impl AstNode for SourceFile {
3388 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3389 match syntax.kind() {
3390 SOURCE_FILE => Some(SourceFile::from_repr(syntax.into_repr())),
3394 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3397 impl ToOwned for SourceFile {
3398 type Owned = TreeArc<SourceFile>;
3399 fn to_owned(&self) -> TreeArc<SourceFile> { TreeArc::cast(self.syntax.to_owned()) }
3403 impl ast::ModuleItemOwner for SourceFile {}
3404 impl ast::FnDefOwner for SourceFile {}
3406 pub fn modules(&self) -> impl Iterator<Item = &Module> {
3407 super::children(self)
3412 #[derive(Debug, PartialEq, Eq, Hash)]
3413 #[repr(transparent)]
3414 pub struct StaticDef {
3415 pub(crate) syntax: SyntaxNode,
3417 unsafe impl TransparentNewType for StaticDef {
3418 type Repr = rowan::SyntaxNode;
3421 impl AstNode for StaticDef {
3422 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3423 match syntax.kind() {
3424 STATIC_DEF => Some(StaticDef::from_repr(syntax.into_repr())),
3428 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3431 impl ToOwned for StaticDef {
3432 type Owned = TreeArc<StaticDef>;
3433 fn to_owned(&self) -> TreeArc<StaticDef> { TreeArc::cast(self.syntax.to_owned()) }
3437 impl ast::VisibilityOwner for StaticDef {}
3438 impl ast::NameOwner for StaticDef {}
3439 impl ast::TypeParamsOwner for StaticDef {}
3440 impl ast::AttrsOwner for StaticDef {}
3441 impl ast::DocCommentsOwner for StaticDef {}
3442 impl ast::TypeAscriptionOwner for StaticDef {}
3444 pub fn body(&self) -> Option<&Expr> {
3445 super::child_opt(self)
3450 #[derive(Debug, PartialEq, Eq, Hash)]
3451 #[repr(transparent)]
3453 pub(crate) syntax: SyntaxNode,
3455 unsafe impl TransparentNewType for Stmt {
3456 type Repr = rowan::SyntaxNode;
3459 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3460 pub enum StmtKind<'a> {
3461 ExprStmt(&'a ExprStmt),
3462 LetStmt(&'a LetStmt),
3464 impl<'a> From<&'a ExprStmt> for &'a Stmt {
3465 fn from(n: &'a ExprStmt) -> &'a Stmt {
3466 Stmt::cast(&n.syntax).unwrap()
3469 impl<'a> From<&'a LetStmt> for &'a Stmt {
3470 fn from(n: &'a LetStmt) -> &'a Stmt {
3471 Stmt::cast(&n.syntax).unwrap()
3476 impl AstNode for Stmt {
3477 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3478 match syntax.kind() {
3480 | LET_STMT => Some(Stmt::from_repr(syntax.into_repr())),
3484 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3487 impl ToOwned for Stmt {
3488 type Owned = TreeArc<Stmt>;
3489 fn to_owned(&self) -> TreeArc<Stmt> { TreeArc::cast(self.syntax.to_owned()) }
3493 pub fn kind(&self) -> StmtKind {
3494 match self.syntax.kind() {
3495 EXPR_STMT => StmtKind::ExprStmt(ExprStmt::cast(&self.syntax).unwrap()),
3496 LET_STMT => StmtKind::LetStmt(LetStmt::cast(&self.syntax).unwrap()),
3497 _ => unreachable!(),
3505 #[derive(Debug, PartialEq, Eq, Hash)]
3506 #[repr(transparent)]
3507 pub struct StructDef {
3508 pub(crate) syntax: SyntaxNode,
3510 unsafe impl TransparentNewType for StructDef {
3511 type Repr = rowan::SyntaxNode;
3514 impl AstNode for StructDef {
3515 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3516 match syntax.kind() {
3517 STRUCT_DEF => Some(StructDef::from_repr(syntax.into_repr())),
3521 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3524 impl ToOwned for StructDef {
3525 type Owned = TreeArc<StructDef>;
3526 fn to_owned(&self) -> TreeArc<StructDef> { TreeArc::cast(self.syntax.to_owned()) }
3530 impl ast::VisibilityOwner for StructDef {}
3531 impl ast::NameOwner for StructDef {}
3532 impl ast::TypeParamsOwner for StructDef {}
3533 impl ast::AttrsOwner for StructDef {}
3534 impl ast::DocCommentsOwner for StructDef {}
3538 #[derive(Debug, PartialEq, Eq, Hash)]
3539 #[repr(transparent)]
3540 pub struct StructLit {
3541 pub(crate) syntax: SyntaxNode,
3543 unsafe impl TransparentNewType for StructLit {
3544 type Repr = rowan::SyntaxNode;
3547 impl AstNode for StructLit {
3548 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3549 match syntax.kind() {
3550 STRUCT_LIT => Some(StructLit::from_repr(syntax.into_repr())),
3554 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3557 impl ToOwned for StructLit {
3558 type Owned = TreeArc<StructLit>;
3559 fn to_owned(&self) -> TreeArc<StructLit> { TreeArc::cast(self.syntax.to_owned()) }
3564 pub fn path(&self) -> Option<&Path> {
3565 super::child_opt(self)
3568 pub fn named_field_list(&self) -> Option<&NamedFieldList> {
3569 super::child_opt(self)
3574 #[derive(Debug, PartialEq, Eq, Hash)]
3575 #[repr(transparent)]
3576 pub struct StructPat {
3577 pub(crate) syntax: SyntaxNode,
3579 unsafe impl TransparentNewType for StructPat {
3580 type Repr = rowan::SyntaxNode;
3583 impl AstNode for StructPat {
3584 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3585 match syntax.kind() {
3586 STRUCT_PAT => Some(StructPat::from_repr(syntax.into_repr())),
3590 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3593 impl ToOwned for StructPat {
3594 type Owned = TreeArc<StructPat>;
3595 fn to_owned(&self) -> TreeArc<StructPat> { TreeArc::cast(self.syntax.to_owned()) }
3600 pub fn field_pat_list(&self) -> Option<&FieldPatList> {
3601 super::child_opt(self)
3604 pub fn path(&self) -> Option<&Path> {
3605 super::child_opt(self)
3610 #[derive(Debug, PartialEq, Eq, Hash)]
3611 #[repr(transparent)]
3612 pub struct TokenTree {
3613 pub(crate) syntax: SyntaxNode,
3615 unsafe impl TransparentNewType for TokenTree {
3616 type Repr = rowan::SyntaxNode;
3619 impl AstNode for TokenTree {
3620 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3621 match syntax.kind() {
3622 TOKEN_TREE => Some(TokenTree::from_repr(syntax.into_repr())),
3626 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3629 impl ToOwned for TokenTree {
3630 type Owned = TreeArc<TokenTree>;
3631 fn to_owned(&self) -> TreeArc<TokenTree> { TreeArc::cast(self.syntax.to_owned()) }
3638 #[derive(Debug, PartialEq, Eq, Hash)]
3639 #[repr(transparent)]
3640 pub struct TraitDef {
3641 pub(crate) syntax: SyntaxNode,
3643 unsafe impl TransparentNewType for TraitDef {
3644 type Repr = rowan::SyntaxNode;
3647 impl AstNode for TraitDef {
3648 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3649 match syntax.kind() {
3650 TRAIT_DEF => Some(TraitDef::from_repr(syntax.into_repr())),
3654 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3657 impl ToOwned for TraitDef {
3658 type Owned = TreeArc<TraitDef>;
3659 fn to_owned(&self) -> TreeArc<TraitDef> { TreeArc::cast(self.syntax.to_owned()) }
3663 impl ast::VisibilityOwner for TraitDef {}
3664 impl ast::NameOwner for TraitDef {}
3665 impl ast::AttrsOwner for TraitDef {}
3666 impl ast::DocCommentsOwner for TraitDef {}
3667 impl ast::TypeParamsOwner for TraitDef {}
3668 impl ast::TypeBoundsOwner for TraitDef {}
3670 pub fn item_list(&self) -> Option<&ItemList> {
3671 super::child_opt(self)
3676 #[derive(Debug, PartialEq, Eq, Hash)]
3677 #[repr(transparent)]
3678 pub struct TryExpr {
3679 pub(crate) syntax: SyntaxNode,
3681 unsafe impl TransparentNewType for TryExpr {
3682 type Repr = rowan::SyntaxNode;
3685 impl AstNode for TryExpr {
3686 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3687 match syntax.kind() {
3688 TRY_EXPR => Some(TryExpr::from_repr(syntax.into_repr())),
3692 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3695 impl ToOwned for TryExpr {
3696 type Owned = TreeArc<TryExpr>;
3697 fn to_owned(&self) -> TreeArc<TryExpr> { TreeArc::cast(self.syntax.to_owned()) }
3702 pub fn expr(&self) -> Option<&Expr> {
3703 super::child_opt(self)
3708 #[derive(Debug, PartialEq, Eq, Hash)]
3709 #[repr(transparent)]
3710 pub struct TupleExpr {
3711 pub(crate) syntax: SyntaxNode,
3713 unsafe impl TransparentNewType for TupleExpr {
3714 type Repr = rowan::SyntaxNode;
3717 impl AstNode for TupleExpr {
3718 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3719 match syntax.kind() {
3720 TUPLE_EXPR => Some(TupleExpr::from_repr(syntax.into_repr())),
3724 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3727 impl ToOwned for TupleExpr {
3728 type Owned = TreeArc<TupleExpr>;
3729 fn to_owned(&self) -> TreeArc<TupleExpr> { TreeArc::cast(self.syntax.to_owned()) }
3734 pub fn exprs(&self) -> impl Iterator<Item = &Expr> {
3735 super::children(self)
3740 #[derive(Debug, PartialEq, Eq, Hash)]
3741 #[repr(transparent)]
3742 pub struct TuplePat {
3743 pub(crate) syntax: SyntaxNode,
3745 unsafe impl TransparentNewType for TuplePat {
3746 type Repr = rowan::SyntaxNode;
3749 impl AstNode for TuplePat {
3750 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3751 match syntax.kind() {
3752 TUPLE_PAT => Some(TuplePat::from_repr(syntax.into_repr())),
3756 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3759 impl ToOwned for TuplePat {
3760 type Owned = TreeArc<TuplePat>;
3761 fn to_owned(&self) -> TreeArc<TuplePat> { TreeArc::cast(self.syntax.to_owned()) }
3766 pub fn args(&self) -> impl Iterator<Item = &Pat> {
3767 super::children(self)
3772 #[derive(Debug, PartialEq, Eq, Hash)]
3773 #[repr(transparent)]
3774 pub struct TupleStructPat {
3775 pub(crate) syntax: SyntaxNode,
3777 unsafe impl TransparentNewType for TupleStructPat {
3778 type Repr = rowan::SyntaxNode;
3781 impl AstNode for TupleStructPat {
3782 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3783 match syntax.kind() {
3784 TUPLE_STRUCT_PAT => Some(TupleStructPat::from_repr(syntax.into_repr())),
3788 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3791 impl ToOwned for TupleStructPat {
3792 type Owned = TreeArc<TupleStructPat>;
3793 fn to_owned(&self) -> TreeArc<TupleStructPat> { TreeArc::cast(self.syntax.to_owned()) }
3797 impl TupleStructPat {
3798 pub fn args(&self) -> impl Iterator<Item = &Pat> {
3799 super::children(self)
3802 pub fn path(&self) -> Option<&Path> {
3803 super::child_opt(self)
3808 #[derive(Debug, PartialEq, Eq, Hash)]
3809 #[repr(transparent)]
3810 pub struct TupleType {
3811 pub(crate) syntax: SyntaxNode,
3813 unsafe impl TransparentNewType for TupleType {
3814 type Repr = rowan::SyntaxNode;
3817 impl AstNode for TupleType {
3818 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3819 match syntax.kind() {
3820 TUPLE_TYPE => Some(TupleType::from_repr(syntax.into_repr())),
3824 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3827 impl ToOwned for TupleType {
3828 type Owned = TreeArc<TupleType>;
3829 fn to_owned(&self) -> TreeArc<TupleType> { TreeArc::cast(self.syntax.to_owned()) }
3834 pub fn fields(&self) -> impl Iterator<Item = &TypeRef> {
3835 super::children(self)
3840 #[derive(Debug, PartialEq, Eq, Hash)]
3841 #[repr(transparent)]
3842 pub struct TypeAliasDef {
3843 pub(crate) syntax: SyntaxNode,
3845 unsafe impl TransparentNewType for TypeAliasDef {
3846 type Repr = rowan::SyntaxNode;
3849 impl AstNode for TypeAliasDef {
3850 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3851 match syntax.kind() {
3852 TYPE_ALIAS_DEF => Some(TypeAliasDef::from_repr(syntax.into_repr())),
3856 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3859 impl ToOwned for TypeAliasDef {
3860 type Owned = TreeArc<TypeAliasDef>;
3861 fn to_owned(&self) -> TreeArc<TypeAliasDef> { TreeArc::cast(self.syntax.to_owned()) }
3865 impl ast::VisibilityOwner for TypeAliasDef {}
3866 impl ast::NameOwner for TypeAliasDef {}
3867 impl ast::TypeParamsOwner for TypeAliasDef {}
3868 impl ast::AttrsOwner for TypeAliasDef {}
3869 impl ast::DocCommentsOwner for TypeAliasDef {}
3870 impl ast::TypeBoundsOwner for TypeAliasDef {}
3872 pub fn type_ref(&self) -> Option<&TypeRef> {
3873 super::child_opt(self)
3878 #[derive(Debug, PartialEq, Eq, Hash)]
3879 #[repr(transparent)]
3880 pub struct TypeArg {
3881 pub(crate) syntax: SyntaxNode,
3883 unsafe impl TransparentNewType for TypeArg {
3884 type Repr = rowan::SyntaxNode;
3887 impl AstNode for TypeArg {
3888 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3889 match syntax.kind() {
3890 TYPE_ARG => Some(TypeArg::from_repr(syntax.into_repr())),
3894 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3897 impl ToOwned for TypeArg {
3898 type Owned = TreeArc<TypeArg>;
3899 fn to_owned(&self) -> TreeArc<TypeArg> { TreeArc::cast(self.syntax.to_owned()) }
3904 pub fn type_ref(&self) -> Option<&TypeRef> {
3905 super::child_opt(self)
3910 #[derive(Debug, PartialEq, Eq, Hash)]
3911 #[repr(transparent)]
3912 pub struct TypeArgList {
3913 pub(crate) syntax: SyntaxNode,
3915 unsafe impl TransparentNewType for TypeArgList {
3916 type Repr = rowan::SyntaxNode;
3919 impl AstNode for TypeArgList {
3920 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3921 match syntax.kind() {
3922 TYPE_ARG_LIST => Some(TypeArgList::from_repr(syntax.into_repr())),
3926 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3929 impl ToOwned for TypeArgList {
3930 type Owned = TreeArc<TypeArgList>;
3931 fn to_owned(&self) -> TreeArc<TypeArgList> { TreeArc::cast(self.syntax.to_owned()) }
3936 pub fn type_args(&self) -> impl Iterator<Item = &TypeArg> {
3937 super::children(self)
3940 pub fn lifetime_args(&self) -> impl Iterator<Item = &LifetimeArg> {
3941 super::children(self)
3944 pub fn assoc_type_args(&self) -> impl Iterator<Item = &AssocTypeArg> {
3945 super::children(self)
3950 #[derive(Debug, PartialEq, Eq, Hash)]
3951 #[repr(transparent)]
3952 pub struct TypeBound {
3953 pub(crate) syntax: SyntaxNode,
3955 unsafe impl TransparentNewType for TypeBound {
3956 type Repr = rowan::SyntaxNode;
3959 impl AstNode for TypeBound {
3960 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3961 match syntax.kind() {
3962 TYPE_BOUND => Some(TypeBound::from_repr(syntax.into_repr())),
3966 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3969 impl ToOwned for TypeBound {
3970 type Owned = TreeArc<TypeBound>;
3971 fn to_owned(&self) -> TreeArc<TypeBound> { TreeArc::cast(self.syntax.to_owned()) }
3976 pub fn type_ref(&self) -> Option<&TypeRef> {
3977 super::child_opt(self)
3982 #[derive(Debug, PartialEq, Eq, Hash)]
3983 #[repr(transparent)]
3984 pub struct TypeBoundList {
3985 pub(crate) syntax: SyntaxNode,
3987 unsafe impl TransparentNewType for TypeBoundList {
3988 type Repr = rowan::SyntaxNode;
3991 impl AstNode for TypeBoundList {
3992 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3993 match syntax.kind() {
3994 TYPE_BOUND_LIST => Some(TypeBoundList::from_repr(syntax.into_repr())),
3998 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4001 impl ToOwned for TypeBoundList {
4002 type Owned = TreeArc<TypeBoundList>;
4003 fn to_owned(&self) -> TreeArc<TypeBoundList> { TreeArc::cast(self.syntax.to_owned()) }
4007 impl TypeBoundList {
4008 pub fn bounds(&self) -> impl Iterator<Item = &TypeBound> {
4009 super::children(self)
4014 #[derive(Debug, PartialEq, Eq, Hash)]
4015 #[repr(transparent)]
4016 pub struct TypeParam {
4017 pub(crate) syntax: SyntaxNode,
4019 unsafe impl TransparentNewType for TypeParam {
4020 type Repr = rowan::SyntaxNode;
4023 impl AstNode for TypeParam {
4024 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4025 match syntax.kind() {
4026 TYPE_PARAM => Some(TypeParam::from_repr(syntax.into_repr())),
4030 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4033 impl ToOwned for TypeParam {
4034 type Owned = TreeArc<TypeParam>;
4035 fn to_owned(&self) -> TreeArc<TypeParam> { TreeArc::cast(self.syntax.to_owned()) }
4039 impl ast::NameOwner for TypeParam {}
4040 impl ast::AttrsOwner for TypeParam {}
4041 impl ast::TypeBoundsOwner for TypeParam {}
4042 impl ast::DefaultTypeParamOwner for TypeParam {}
4046 #[derive(Debug, PartialEq, Eq, Hash)]
4047 #[repr(transparent)]
4048 pub struct TypeParamList {
4049 pub(crate) syntax: SyntaxNode,
4051 unsafe impl TransparentNewType for TypeParamList {
4052 type Repr = rowan::SyntaxNode;
4055 impl AstNode for TypeParamList {
4056 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4057 match syntax.kind() {
4058 TYPE_PARAM_LIST => Some(TypeParamList::from_repr(syntax.into_repr())),
4062 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4065 impl ToOwned for TypeParamList {
4066 type Owned = TreeArc<TypeParamList>;
4067 fn to_owned(&self) -> TreeArc<TypeParamList> { TreeArc::cast(self.syntax.to_owned()) }
4071 impl TypeParamList {
4072 pub fn type_params(&self) -> impl Iterator<Item = &TypeParam> {
4073 super::children(self)
4076 pub fn lifetime_params(&self) -> impl Iterator<Item = &LifetimeParam> {
4077 super::children(self)
4082 #[derive(Debug, PartialEq, Eq, Hash)]
4083 #[repr(transparent)]
4084 pub struct TypeRef {
4085 pub(crate) syntax: SyntaxNode,
4087 unsafe impl TransparentNewType for TypeRef {
4088 type Repr = rowan::SyntaxNode;
4091 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4092 pub enum TypeRefKind<'a> {
4093 ParenType(&'a ParenType),
4094 TupleType(&'a TupleType),
4095 NeverType(&'a NeverType),
4096 PathType(&'a PathType),
4097 PointerType(&'a PointerType),
4098 ArrayType(&'a ArrayType),
4099 SliceType(&'a SliceType),
4100 ReferenceType(&'a ReferenceType),
4101 PlaceholderType(&'a PlaceholderType),
4102 FnPointerType(&'a FnPointerType),
4103 ForType(&'a ForType),
4104 ImplTraitType(&'a ImplTraitType),
4105 DynTraitType(&'a DynTraitType),
4107 impl<'a> From<&'a ParenType> for &'a TypeRef {
4108 fn from(n: &'a ParenType) -> &'a TypeRef {
4109 TypeRef::cast(&n.syntax).unwrap()
4112 impl<'a> From<&'a TupleType> for &'a TypeRef {
4113 fn from(n: &'a TupleType) -> &'a TypeRef {
4114 TypeRef::cast(&n.syntax).unwrap()
4117 impl<'a> From<&'a NeverType> for &'a TypeRef {
4118 fn from(n: &'a NeverType) -> &'a TypeRef {
4119 TypeRef::cast(&n.syntax).unwrap()
4122 impl<'a> From<&'a PathType> for &'a TypeRef {
4123 fn from(n: &'a PathType) -> &'a TypeRef {
4124 TypeRef::cast(&n.syntax).unwrap()
4127 impl<'a> From<&'a PointerType> for &'a TypeRef {
4128 fn from(n: &'a PointerType) -> &'a TypeRef {
4129 TypeRef::cast(&n.syntax).unwrap()
4132 impl<'a> From<&'a ArrayType> for &'a TypeRef {
4133 fn from(n: &'a ArrayType) -> &'a TypeRef {
4134 TypeRef::cast(&n.syntax).unwrap()
4137 impl<'a> From<&'a SliceType> for &'a TypeRef {
4138 fn from(n: &'a SliceType) -> &'a TypeRef {
4139 TypeRef::cast(&n.syntax).unwrap()
4142 impl<'a> From<&'a ReferenceType> for &'a TypeRef {
4143 fn from(n: &'a ReferenceType) -> &'a TypeRef {
4144 TypeRef::cast(&n.syntax).unwrap()
4147 impl<'a> From<&'a PlaceholderType> for &'a TypeRef {
4148 fn from(n: &'a PlaceholderType) -> &'a TypeRef {
4149 TypeRef::cast(&n.syntax).unwrap()
4152 impl<'a> From<&'a FnPointerType> for &'a TypeRef {
4153 fn from(n: &'a FnPointerType) -> &'a TypeRef {
4154 TypeRef::cast(&n.syntax).unwrap()
4157 impl<'a> From<&'a ForType> for &'a TypeRef {
4158 fn from(n: &'a ForType) -> &'a TypeRef {
4159 TypeRef::cast(&n.syntax).unwrap()
4162 impl<'a> From<&'a ImplTraitType> for &'a TypeRef {
4163 fn from(n: &'a ImplTraitType) -> &'a TypeRef {
4164 TypeRef::cast(&n.syntax).unwrap()
4167 impl<'a> From<&'a DynTraitType> for &'a TypeRef {
4168 fn from(n: &'a DynTraitType) -> &'a TypeRef {
4169 TypeRef::cast(&n.syntax).unwrap()
4174 impl AstNode for TypeRef {
4175 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4176 match syntax.kind() {
4189 | DYN_TRAIT_TYPE => Some(TypeRef::from_repr(syntax.into_repr())),
4193 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4196 impl ToOwned for TypeRef {
4197 type Owned = TreeArc<TypeRef>;
4198 fn to_owned(&self) -> TreeArc<TypeRef> { TreeArc::cast(self.syntax.to_owned()) }
4202 pub fn kind(&self) -> TypeRefKind {
4203 match self.syntax.kind() {
4204 PAREN_TYPE => TypeRefKind::ParenType(ParenType::cast(&self.syntax).unwrap()),
4205 TUPLE_TYPE => TypeRefKind::TupleType(TupleType::cast(&self.syntax).unwrap()),
4206 NEVER_TYPE => TypeRefKind::NeverType(NeverType::cast(&self.syntax).unwrap()),
4207 PATH_TYPE => TypeRefKind::PathType(PathType::cast(&self.syntax).unwrap()),
4208 POINTER_TYPE => TypeRefKind::PointerType(PointerType::cast(&self.syntax).unwrap()),
4209 ARRAY_TYPE => TypeRefKind::ArrayType(ArrayType::cast(&self.syntax).unwrap()),
4210 SLICE_TYPE => TypeRefKind::SliceType(SliceType::cast(&self.syntax).unwrap()),
4211 REFERENCE_TYPE => TypeRefKind::ReferenceType(ReferenceType::cast(&self.syntax).unwrap()),
4212 PLACEHOLDER_TYPE => TypeRefKind::PlaceholderType(PlaceholderType::cast(&self.syntax).unwrap()),
4213 FN_POINTER_TYPE => TypeRefKind::FnPointerType(FnPointerType::cast(&self.syntax).unwrap()),
4214 FOR_TYPE => TypeRefKind::ForType(ForType::cast(&self.syntax).unwrap()),
4215 IMPL_TRAIT_TYPE => TypeRefKind::ImplTraitType(ImplTraitType::cast(&self.syntax).unwrap()),
4216 DYN_TRAIT_TYPE => TypeRefKind::DynTraitType(DynTraitType::cast(&self.syntax).unwrap()),
4217 _ => unreachable!(),
4225 #[derive(Debug, PartialEq, Eq, Hash)]
4226 #[repr(transparent)]
4227 pub struct UseItem {
4228 pub(crate) syntax: SyntaxNode,
4230 unsafe impl TransparentNewType for UseItem {
4231 type Repr = rowan::SyntaxNode;
4234 impl AstNode for UseItem {
4235 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4236 match syntax.kind() {
4237 USE_ITEM => Some(UseItem::from_repr(syntax.into_repr())),
4241 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4244 impl ToOwned for UseItem {
4245 type Owned = TreeArc<UseItem>;
4246 fn to_owned(&self) -> TreeArc<UseItem> { TreeArc::cast(self.syntax.to_owned()) }
4250 impl ast::AttrsOwner for UseItem {}
4252 pub fn use_tree(&self) -> Option<&UseTree> {
4253 super::child_opt(self)
4258 #[derive(Debug, PartialEq, Eq, Hash)]
4259 #[repr(transparent)]
4260 pub struct UseTree {
4261 pub(crate) syntax: SyntaxNode,
4263 unsafe impl TransparentNewType for UseTree {
4264 type Repr = rowan::SyntaxNode;
4267 impl AstNode for UseTree {
4268 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4269 match syntax.kind() {
4270 USE_TREE => Some(UseTree::from_repr(syntax.into_repr())),
4274 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4277 impl ToOwned for UseTree {
4278 type Owned = TreeArc<UseTree>;
4279 fn to_owned(&self) -> TreeArc<UseTree> { TreeArc::cast(self.syntax.to_owned()) }
4284 pub fn path(&self) -> Option<&Path> {
4285 super::child_opt(self)
4288 pub fn use_tree_list(&self) -> Option<&UseTreeList> {
4289 super::child_opt(self)
4292 pub fn alias(&self) -> Option<&Alias> {
4293 super::child_opt(self)
4298 #[derive(Debug, PartialEq, Eq, Hash)]
4299 #[repr(transparent)]
4300 pub struct UseTreeList {
4301 pub(crate) syntax: SyntaxNode,
4303 unsafe impl TransparentNewType for UseTreeList {
4304 type Repr = rowan::SyntaxNode;
4307 impl AstNode for UseTreeList {
4308 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4309 match syntax.kind() {
4310 USE_TREE_LIST => Some(UseTreeList::from_repr(syntax.into_repr())),
4314 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4317 impl ToOwned for UseTreeList {
4318 type Owned = TreeArc<UseTreeList>;
4319 fn to_owned(&self) -> TreeArc<UseTreeList> { TreeArc::cast(self.syntax.to_owned()) }
4324 pub fn use_trees(&self) -> impl Iterator<Item = &UseTree> {
4325 super::children(self)
4330 #[derive(Debug, PartialEq, Eq, Hash)]
4331 #[repr(transparent)]
4332 pub struct Visibility {
4333 pub(crate) syntax: SyntaxNode,
4335 unsafe impl TransparentNewType for Visibility {
4336 type Repr = rowan::SyntaxNode;
4339 impl AstNode for Visibility {
4340 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4341 match syntax.kind() {
4342 VISIBILITY => Some(Visibility::from_repr(syntax.into_repr())),
4346 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4349 impl ToOwned for Visibility {
4350 type Owned = TreeArc<Visibility>;
4351 fn to_owned(&self) -> TreeArc<Visibility> { TreeArc::cast(self.syntax.to_owned()) }
4358 #[derive(Debug, PartialEq, Eq, Hash)]
4359 #[repr(transparent)]
4360 pub struct WhereClause {
4361 pub(crate) syntax: SyntaxNode,
4363 unsafe impl TransparentNewType for WhereClause {
4364 type Repr = rowan::SyntaxNode;
4367 impl AstNode for WhereClause {
4368 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4369 match syntax.kind() {
4370 WHERE_CLAUSE => Some(WhereClause::from_repr(syntax.into_repr())),
4374 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4377 impl ToOwned for WhereClause {
4378 type Owned = TreeArc<WhereClause>;
4379 fn to_owned(&self) -> TreeArc<WhereClause> { TreeArc::cast(self.syntax.to_owned()) }
4384 pub fn predicates(&self) -> impl Iterator<Item = &WherePred> {
4385 super::children(self)
4390 #[derive(Debug, PartialEq, Eq, Hash)]
4391 #[repr(transparent)]
4392 pub struct WherePred {
4393 pub(crate) syntax: SyntaxNode,
4395 unsafe impl TransparentNewType for WherePred {
4396 type Repr = rowan::SyntaxNode;
4399 impl AstNode for WherePred {
4400 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4401 match syntax.kind() {
4402 WHERE_PRED => Some(WherePred::from_repr(syntax.into_repr())),
4406 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4409 impl ToOwned for WherePred {
4410 type Owned = TreeArc<WherePred>;
4411 fn to_owned(&self) -> TreeArc<WherePred> { TreeArc::cast(self.syntax.to_owned()) }
4415 impl ast::TypeBoundsOwner for WherePred {}
4417 pub fn type_ref(&self) -> Option<&TypeRef> {
4418 super::child_opt(self)
4423 #[derive(Debug, PartialEq, Eq, Hash)]
4424 #[repr(transparent)]
4425 pub struct WhileExpr {
4426 pub(crate) syntax: SyntaxNode,
4428 unsafe impl TransparentNewType for WhileExpr {
4429 type Repr = rowan::SyntaxNode;
4432 impl AstNode for WhileExpr {
4433 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4434 match syntax.kind() {
4435 WHILE_EXPR => Some(WhileExpr::from_repr(syntax.into_repr())),
4439 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4442 impl ToOwned for WhileExpr {
4443 type Owned = TreeArc<WhileExpr>;
4444 fn to_owned(&self) -> TreeArc<WhileExpr> { TreeArc::cast(self.syntax.to_owned()) }
4448 impl ast::LoopBodyOwner for WhileExpr {}
4450 pub fn condition(&self) -> Option<&Condition> {
4451 super::child_opt(self)