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::{RaTypes, TreeArc},
21 #[derive(Debug, PartialEq, Eq, Hash)]
24 pub(crate) syntax: SyntaxNode,
26 unsafe impl TransparentNewType for Alias {
27 type Repr = rowan::SyntaxNode<RaTypes>;
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<RaTypes>;
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<RaTypes>;
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<RaTypes>;
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<RaTypes>;
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<RaTypes>;
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<RaTypes>;
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<RaTypes>;
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<RaTypes>;
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<RaTypes>;
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<RaTypes>;
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<RaTypes>;
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<RaTypes>;
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<RaTypes>;
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<RaTypes>;
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 {}
519 #[derive(Debug, PartialEq, Eq, Hash)]
521 pub struct ContinueExpr {
522 pub(crate) syntax: SyntaxNode,
524 unsafe impl TransparentNewType for ContinueExpr {
525 type Repr = rowan::SyntaxNode<RaTypes>;
528 impl AstNode for ContinueExpr {
529 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
530 match syntax.kind() {
531 CONTINUE_EXPR => Some(ContinueExpr::from_repr(syntax.into_repr())),
535 fn syntax(&self) -> &SyntaxNode { &self.syntax }
538 impl ToOwned for ContinueExpr {
539 type Owned = TreeArc<ContinueExpr>;
540 fn to_owned(&self) -> TreeArc<ContinueExpr> { TreeArc::cast(self.syntax.to_owned()) }
547 #[derive(Debug, PartialEq, Eq, Hash)]
549 pub struct DynTraitType {
550 pub(crate) syntax: SyntaxNode,
552 unsafe impl TransparentNewType for DynTraitType {
553 type Repr = rowan::SyntaxNode<RaTypes>;
556 impl AstNode for DynTraitType {
557 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
558 match syntax.kind() {
559 DYN_TRAIT_TYPE => Some(DynTraitType::from_repr(syntax.into_repr())),
563 fn syntax(&self) -> &SyntaxNode { &self.syntax }
566 impl ToOwned for DynTraitType {
567 type Owned = TreeArc<DynTraitType>;
568 fn to_owned(&self) -> TreeArc<DynTraitType> { TreeArc::cast(self.syntax.to_owned()) }
572 impl ast::TypeBoundsOwner for DynTraitType {}
576 #[derive(Debug, PartialEq, Eq, Hash)]
579 pub(crate) syntax: SyntaxNode,
581 unsafe impl TransparentNewType for EnumDef {
582 type Repr = rowan::SyntaxNode<RaTypes>;
585 impl AstNode for EnumDef {
586 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
587 match syntax.kind() {
588 ENUM_DEF => Some(EnumDef::from_repr(syntax.into_repr())),
592 fn syntax(&self) -> &SyntaxNode { &self.syntax }
595 impl ToOwned for EnumDef {
596 type Owned = TreeArc<EnumDef>;
597 fn to_owned(&self) -> TreeArc<EnumDef> { TreeArc::cast(self.syntax.to_owned()) }
601 impl ast::VisibilityOwner for EnumDef {}
602 impl ast::NameOwner for EnumDef {}
603 impl ast::TypeParamsOwner for EnumDef {}
604 impl ast::AttrsOwner for EnumDef {}
605 impl ast::DocCommentsOwner for EnumDef {}
607 pub fn variant_list(&self) -> Option<&EnumVariantList> {
608 super::child_opt(self)
613 #[derive(Debug, PartialEq, Eq, Hash)]
615 pub struct EnumVariant {
616 pub(crate) syntax: SyntaxNode,
618 unsafe impl TransparentNewType for EnumVariant {
619 type Repr = rowan::SyntaxNode<RaTypes>;
622 impl AstNode for EnumVariant {
623 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
624 match syntax.kind() {
625 ENUM_VARIANT => Some(EnumVariant::from_repr(syntax.into_repr())),
629 fn syntax(&self) -> &SyntaxNode { &self.syntax }
632 impl ToOwned for EnumVariant {
633 type Owned = TreeArc<EnumVariant>;
634 fn to_owned(&self) -> TreeArc<EnumVariant> { TreeArc::cast(self.syntax.to_owned()) }
638 impl ast::NameOwner for EnumVariant {}
639 impl ast::DocCommentsOwner for EnumVariant {}
640 impl ast::AttrsOwner for EnumVariant {}
642 pub fn expr(&self) -> Option<&Expr> {
643 super::child_opt(self)
648 #[derive(Debug, PartialEq, Eq, Hash)]
650 pub struct EnumVariantList {
651 pub(crate) syntax: SyntaxNode,
653 unsafe impl TransparentNewType for EnumVariantList {
654 type Repr = rowan::SyntaxNode<RaTypes>;
657 impl AstNode for EnumVariantList {
658 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
659 match syntax.kind() {
660 ENUM_VARIANT_LIST => Some(EnumVariantList::from_repr(syntax.into_repr())),
664 fn syntax(&self) -> &SyntaxNode { &self.syntax }
667 impl ToOwned for EnumVariantList {
668 type Owned = TreeArc<EnumVariantList>;
669 fn to_owned(&self) -> TreeArc<EnumVariantList> { TreeArc::cast(self.syntax.to_owned()) }
673 impl EnumVariantList {
674 pub fn variants(&self) -> impl Iterator<Item = &EnumVariant> {
675 super::children(self)
680 #[derive(Debug, PartialEq, Eq, Hash)]
683 pub(crate) syntax: SyntaxNode,
685 unsafe impl TransparentNewType for Expr {
686 type Repr = rowan::SyntaxNode<RaTypes>;
689 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
690 pub enum ExprKind<'a> {
691 TupleExpr(&'a TupleExpr),
692 ArrayExpr(&'a ArrayExpr),
693 ParenExpr(&'a ParenExpr),
694 PathExpr(&'a PathExpr),
695 LambdaExpr(&'a LambdaExpr),
697 LoopExpr(&'a LoopExpr),
698 ForExpr(&'a ForExpr),
699 WhileExpr(&'a WhileExpr),
700 ContinueExpr(&'a ContinueExpr),
701 BreakExpr(&'a BreakExpr),
703 BlockExpr(&'a BlockExpr),
704 ReturnExpr(&'a ReturnExpr),
705 MatchExpr(&'a MatchExpr),
706 StructLit(&'a StructLit),
707 CallExpr(&'a CallExpr),
708 IndexExpr(&'a IndexExpr),
709 MethodCallExpr(&'a MethodCallExpr),
710 FieldExpr(&'a FieldExpr),
711 TryExpr(&'a TryExpr),
712 CastExpr(&'a CastExpr),
713 RefExpr(&'a RefExpr),
714 PrefixExpr(&'a PrefixExpr),
715 RangeExpr(&'a RangeExpr),
716 BinExpr(&'a BinExpr),
717 Literal(&'a Literal),
718 MacroCall(&'a MacroCall),
720 impl<'a> From<&'a TupleExpr> for &'a Expr {
721 fn from(n: &'a TupleExpr) -> &'a Expr {
722 Expr::cast(&n.syntax).unwrap()
725 impl<'a> From<&'a ArrayExpr> for &'a Expr {
726 fn from(n: &'a ArrayExpr) -> &'a Expr {
727 Expr::cast(&n.syntax).unwrap()
730 impl<'a> From<&'a ParenExpr> for &'a Expr {
731 fn from(n: &'a ParenExpr) -> &'a Expr {
732 Expr::cast(&n.syntax).unwrap()
735 impl<'a> From<&'a PathExpr> for &'a Expr {
736 fn from(n: &'a PathExpr) -> &'a Expr {
737 Expr::cast(&n.syntax).unwrap()
740 impl<'a> From<&'a LambdaExpr> for &'a Expr {
741 fn from(n: &'a LambdaExpr) -> &'a Expr {
742 Expr::cast(&n.syntax).unwrap()
745 impl<'a> From<&'a IfExpr> for &'a Expr {
746 fn from(n: &'a IfExpr) -> &'a Expr {
747 Expr::cast(&n.syntax).unwrap()
750 impl<'a> From<&'a LoopExpr> for &'a Expr {
751 fn from(n: &'a LoopExpr) -> &'a Expr {
752 Expr::cast(&n.syntax).unwrap()
755 impl<'a> From<&'a ForExpr> for &'a Expr {
756 fn from(n: &'a ForExpr) -> &'a Expr {
757 Expr::cast(&n.syntax).unwrap()
760 impl<'a> From<&'a WhileExpr> for &'a Expr {
761 fn from(n: &'a WhileExpr) -> &'a Expr {
762 Expr::cast(&n.syntax).unwrap()
765 impl<'a> From<&'a ContinueExpr> for &'a Expr {
766 fn from(n: &'a ContinueExpr) -> &'a Expr {
767 Expr::cast(&n.syntax).unwrap()
770 impl<'a> From<&'a BreakExpr> for &'a Expr {
771 fn from(n: &'a BreakExpr) -> &'a Expr {
772 Expr::cast(&n.syntax).unwrap()
775 impl<'a> From<&'a Label> for &'a Expr {
776 fn from(n: &'a Label) -> &'a Expr {
777 Expr::cast(&n.syntax).unwrap()
780 impl<'a> From<&'a BlockExpr> for &'a Expr {
781 fn from(n: &'a BlockExpr) -> &'a Expr {
782 Expr::cast(&n.syntax).unwrap()
785 impl<'a> From<&'a ReturnExpr> for &'a Expr {
786 fn from(n: &'a ReturnExpr) -> &'a Expr {
787 Expr::cast(&n.syntax).unwrap()
790 impl<'a> From<&'a MatchExpr> for &'a Expr {
791 fn from(n: &'a MatchExpr) -> &'a Expr {
792 Expr::cast(&n.syntax).unwrap()
795 impl<'a> From<&'a StructLit> for &'a Expr {
796 fn from(n: &'a StructLit) -> &'a Expr {
797 Expr::cast(&n.syntax).unwrap()
800 impl<'a> From<&'a CallExpr> for &'a Expr {
801 fn from(n: &'a CallExpr) -> &'a Expr {
802 Expr::cast(&n.syntax).unwrap()
805 impl<'a> From<&'a IndexExpr> for &'a Expr {
806 fn from(n: &'a IndexExpr) -> &'a Expr {
807 Expr::cast(&n.syntax).unwrap()
810 impl<'a> From<&'a MethodCallExpr> for &'a Expr {
811 fn from(n: &'a MethodCallExpr) -> &'a Expr {
812 Expr::cast(&n.syntax).unwrap()
815 impl<'a> From<&'a FieldExpr> for &'a Expr {
816 fn from(n: &'a FieldExpr) -> &'a Expr {
817 Expr::cast(&n.syntax).unwrap()
820 impl<'a> From<&'a TryExpr> for &'a Expr {
821 fn from(n: &'a TryExpr) -> &'a Expr {
822 Expr::cast(&n.syntax).unwrap()
825 impl<'a> From<&'a CastExpr> for &'a Expr {
826 fn from(n: &'a CastExpr) -> &'a Expr {
827 Expr::cast(&n.syntax).unwrap()
830 impl<'a> From<&'a RefExpr> for &'a Expr {
831 fn from(n: &'a RefExpr) -> &'a Expr {
832 Expr::cast(&n.syntax).unwrap()
835 impl<'a> From<&'a PrefixExpr> for &'a Expr {
836 fn from(n: &'a PrefixExpr) -> &'a Expr {
837 Expr::cast(&n.syntax).unwrap()
840 impl<'a> From<&'a RangeExpr> for &'a Expr {
841 fn from(n: &'a RangeExpr) -> &'a Expr {
842 Expr::cast(&n.syntax).unwrap()
845 impl<'a> From<&'a BinExpr> for &'a Expr {
846 fn from(n: &'a BinExpr) -> &'a Expr {
847 Expr::cast(&n.syntax).unwrap()
850 impl<'a> From<&'a Literal> for &'a Expr {
851 fn from(n: &'a Literal) -> &'a Expr {
852 Expr::cast(&n.syntax).unwrap()
855 impl<'a> From<&'a MacroCall> for &'a Expr {
856 fn from(n: &'a MacroCall) -> &'a Expr {
857 Expr::cast(&n.syntax).unwrap()
862 impl AstNode for Expr {
863 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
864 match syntax.kind() {
892 | MACRO_CALL => Some(Expr::from_repr(syntax.into_repr())),
896 fn syntax(&self) -> &SyntaxNode { &self.syntax }
899 impl ToOwned for Expr {
900 type Owned = TreeArc<Expr>;
901 fn to_owned(&self) -> TreeArc<Expr> { TreeArc::cast(self.syntax.to_owned()) }
905 pub fn kind(&self) -> ExprKind {
906 match self.syntax.kind() {
907 TUPLE_EXPR => ExprKind::TupleExpr(TupleExpr::cast(&self.syntax).unwrap()),
908 ARRAY_EXPR => ExprKind::ArrayExpr(ArrayExpr::cast(&self.syntax).unwrap()),
909 PAREN_EXPR => ExprKind::ParenExpr(ParenExpr::cast(&self.syntax).unwrap()),
910 PATH_EXPR => ExprKind::PathExpr(PathExpr::cast(&self.syntax).unwrap()),
911 LAMBDA_EXPR => ExprKind::LambdaExpr(LambdaExpr::cast(&self.syntax).unwrap()),
912 IF_EXPR => ExprKind::IfExpr(IfExpr::cast(&self.syntax).unwrap()),
913 LOOP_EXPR => ExprKind::LoopExpr(LoopExpr::cast(&self.syntax).unwrap()),
914 FOR_EXPR => ExprKind::ForExpr(ForExpr::cast(&self.syntax).unwrap()),
915 WHILE_EXPR => ExprKind::WhileExpr(WhileExpr::cast(&self.syntax).unwrap()),
916 CONTINUE_EXPR => ExprKind::ContinueExpr(ContinueExpr::cast(&self.syntax).unwrap()),
917 BREAK_EXPR => ExprKind::BreakExpr(BreakExpr::cast(&self.syntax).unwrap()),
918 LABEL => ExprKind::Label(Label::cast(&self.syntax).unwrap()),
919 BLOCK_EXPR => ExprKind::BlockExpr(BlockExpr::cast(&self.syntax).unwrap()),
920 RETURN_EXPR => ExprKind::ReturnExpr(ReturnExpr::cast(&self.syntax).unwrap()),
921 MATCH_EXPR => ExprKind::MatchExpr(MatchExpr::cast(&self.syntax).unwrap()),
922 STRUCT_LIT => ExprKind::StructLit(StructLit::cast(&self.syntax).unwrap()),
923 CALL_EXPR => ExprKind::CallExpr(CallExpr::cast(&self.syntax).unwrap()),
924 INDEX_EXPR => ExprKind::IndexExpr(IndexExpr::cast(&self.syntax).unwrap()),
925 METHOD_CALL_EXPR => ExprKind::MethodCallExpr(MethodCallExpr::cast(&self.syntax).unwrap()),
926 FIELD_EXPR => ExprKind::FieldExpr(FieldExpr::cast(&self.syntax).unwrap()),
927 TRY_EXPR => ExprKind::TryExpr(TryExpr::cast(&self.syntax).unwrap()),
928 CAST_EXPR => ExprKind::CastExpr(CastExpr::cast(&self.syntax).unwrap()),
929 REF_EXPR => ExprKind::RefExpr(RefExpr::cast(&self.syntax).unwrap()),
930 PREFIX_EXPR => ExprKind::PrefixExpr(PrefixExpr::cast(&self.syntax).unwrap()),
931 RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(&self.syntax).unwrap()),
932 BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(&self.syntax).unwrap()),
933 LITERAL => ExprKind::Literal(Literal::cast(&self.syntax).unwrap()),
934 MACRO_CALL => ExprKind::MacroCall(MacroCall::cast(&self.syntax).unwrap()),
943 #[derive(Debug, PartialEq, Eq, Hash)]
945 pub struct ExprStmt {
946 pub(crate) syntax: SyntaxNode,
948 unsafe impl TransparentNewType for ExprStmt {
949 type Repr = rowan::SyntaxNode<RaTypes>;
952 impl AstNode for ExprStmt {
953 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
954 match syntax.kind() {
955 EXPR_STMT => Some(ExprStmt::from_repr(syntax.into_repr())),
959 fn syntax(&self) -> &SyntaxNode { &self.syntax }
962 impl ToOwned for ExprStmt {
963 type Owned = TreeArc<ExprStmt>;
964 fn to_owned(&self) -> TreeArc<ExprStmt> { TreeArc::cast(self.syntax.to_owned()) }
969 pub fn expr(&self) -> Option<&Expr> {
970 super::child_opt(self)
975 #[derive(Debug, PartialEq, Eq, Hash)]
977 pub struct ExternCrateItem {
978 pub(crate) syntax: SyntaxNode,
980 unsafe impl TransparentNewType for ExternCrateItem {
981 type Repr = rowan::SyntaxNode<RaTypes>;
984 impl AstNode for ExternCrateItem {
985 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
986 match syntax.kind() {
987 EXTERN_CRATE_ITEM => Some(ExternCrateItem::from_repr(syntax.into_repr())),
991 fn syntax(&self) -> &SyntaxNode { &self.syntax }
994 impl ToOwned for ExternCrateItem {
995 type Owned = TreeArc<ExternCrateItem>;
996 fn to_owned(&self) -> TreeArc<ExternCrateItem> { TreeArc::cast(self.syntax.to_owned()) }
1000 impl ExternCrateItem {
1001 pub fn name_ref(&self) -> Option<&NameRef> {
1002 super::child_opt(self)
1005 pub fn alias(&self) -> Option<&Alias> {
1006 super::child_opt(self)
1011 #[derive(Debug, PartialEq, Eq, Hash)]
1012 #[repr(transparent)]
1013 pub struct FieldExpr {
1014 pub(crate) syntax: SyntaxNode,
1016 unsafe impl TransparentNewType for FieldExpr {
1017 type Repr = rowan::SyntaxNode<RaTypes>;
1020 impl AstNode for FieldExpr {
1021 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1022 match syntax.kind() {
1023 FIELD_EXPR => Some(FieldExpr::from_repr(syntax.into_repr())),
1027 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1030 impl ToOwned for FieldExpr {
1031 type Owned = TreeArc<FieldExpr>;
1032 fn to_owned(&self) -> TreeArc<FieldExpr> { TreeArc::cast(self.syntax.to_owned()) }
1037 pub fn expr(&self) -> Option<&Expr> {
1038 super::child_opt(self)
1041 pub fn name_ref(&self) -> Option<&NameRef> {
1042 super::child_opt(self)
1047 #[derive(Debug, PartialEq, Eq, Hash)]
1048 #[repr(transparent)]
1049 pub struct FieldPat {
1050 pub(crate) syntax: SyntaxNode,
1052 unsafe impl TransparentNewType for FieldPat {
1053 type Repr = rowan::SyntaxNode<RaTypes>;
1056 impl AstNode for FieldPat {
1057 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1058 match syntax.kind() {
1059 FIELD_PAT => Some(FieldPat::from_repr(syntax.into_repr())),
1063 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1066 impl ToOwned for FieldPat {
1067 type Owned = TreeArc<FieldPat>;
1068 fn to_owned(&self) -> TreeArc<FieldPat> { TreeArc::cast(self.syntax.to_owned()) }
1072 impl ast::NameOwner for FieldPat {}
1074 pub fn pat(&self) -> Option<&Pat> {
1075 super::child_opt(self)
1080 #[derive(Debug, PartialEq, Eq, Hash)]
1081 #[repr(transparent)]
1082 pub struct FieldPatList {
1083 pub(crate) syntax: SyntaxNode,
1085 unsafe impl TransparentNewType for FieldPatList {
1086 type Repr = rowan::SyntaxNode<RaTypes>;
1089 impl AstNode for FieldPatList {
1090 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1091 match syntax.kind() {
1092 FIELD_PAT_LIST => Some(FieldPatList::from_repr(syntax.into_repr())),
1096 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1099 impl ToOwned for FieldPatList {
1100 type Owned = TreeArc<FieldPatList>;
1101 fn to_owned(&self) -> TreeArc<FieldPatList> { TreeArc::cast(self.syntax.to_owned()) }
1106 pub fn field_pats(&self) -> impl Iterator<Item = &FieldPat> {
1107 super::children(self)
1110 pub fn bind_pats(&self) -> impl Iterator<Item = &BindPat> {
1111 super::children(self)
1116 #[derive(Debug, PartialEq, Eq, Hash)]
1117 #[repr(transparent)]
1119 pub(crate) syntax: SyntaxNode,
1121 unsafe impl TransparentNewType for FnDef {
1122 type Repr = rowan::SyntaxNode<RaTypes>;
1125 impl AstNode for FnDef {
1126 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1127 match syntax.kind() {
1128 FN_DEF => Some(FnDef::from_repr(syntax.into_repr())),
1132 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1135 impl ToOwned for FnDef {
1136 type Owned = TreeArc<FnDef>;
1137 fn to_owned(&self) -> TreeArc<FnDef> { TreeArc::cast(self.syntax.to_owned()) }
1141 impl ast::VisibilityOwner for FnDef {}
1142 impl ast::NameOwner for FnDef {}
1143 impl ast::TypeParamsOwner for FnDef {}
1144 impl ast::AttrsOwner for FnDef {}
1145 impl ast::DocCommentsOwner for FnDef {}
1147 pub fn param_list(&self) -> Option<&ParamList> {
1148 super::child_opt(self)
1151 pub fn body(&self) -> Option<&Block> {
1152 super::child_opt(self)
1155 pub fn ret_type(&self) -> Option<&RetType> {
1156 super::child_opt(self)
1161 #[derive(Debug, PartialEq, Eq, Hash)]
1162 #[repr(transparent)]
1163 pub struct FnPointerType {
1164 pub(crate) syntax: SyntaxNode,
1166 unsafe impl TransparentNewType for FnPointerType {
1167 type Repr = rowan::SyntaxNode<RaTypes>;
1170 impl AstNode for FnPointerType {
1171 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1172 match syntax.kind() {
1173 FN_POINTER_TYPE => Some(FnPointerType::from_repr(syntax.into_repr())),
1177 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1180 impl ToOwned for FnPointerType {
1181 type Owned = TreeArc<FnPointerType>;
1182 fn to_owned(&self) -> TreeArc<FnPointerType> { TreeArc::cast(self.syntax.to_owned()) }
1186 impl FnPointerType {
1187 pub fn param_list(&self) -> Option<&ParamList> {
1188 super::child_opt(self)
1191 pub fn ret_type(&self) -> Option<&RetType> {
1192 super::child_opt(self)
1197 #[derive(Debug, PartialEq, Eq, Hash)]
1198 #[repr(transparent)]
1199 pub struct ForExpr {
1200 pub(crate) syntax: SyntaxNode,
1202 unsafe impl TransparentNewType for ForExpr {
1203 type Repr = rowan::SyntaxNode<RaTypes>;
1206 impl AstNode for ForExpr {
1207 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1208 match syntax.kind() {
1209 FOR_EXPR => Some(ForExpr::from_repr(syntax.into_repr())),
1213 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1216 impl ToOwned for ForExpr {
1217 type Owned = TreeArc<ForExpr>;
1218 fn to_owned(&self) -> TreeArc<ForExpr> { TreeArc::cast(self.syntax.to_owned()) }
1222 impl ast::LoopBodyOwner for ForExpr {}
1224 pub fn pat(&self) -> Option<&Pat> {
1225 super::child_opt(self)
1228 pub fn iterable(&self) -> Option<&Expr> {
1229 super::child_opt(self)
1234 #[derive(Debug, PartialEq, Eq, Hash)]
1235 #[repr(transparent)]
1236 pub struct ForType {
1237 pub(crate) syntax: SyntaxNode,
1239 unsafe impl TransparentNewType for ForType {
1240 type Repr = rowan::SyntaxNode<RaTypes>;
1243 impl AstNode for ForType {
1244 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1245 match syntax.kind() {
1246 FOR_TYPE => Some(ForType::from_repr(syntax.into_repr())),
1250 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1253 impl ToOwned for ForType {
1254 type Owned = TreeArc<ForType>;
1255 fn to_owned(&self) -> TreeArc<ForType> { TreeArc::cast(self.syntax.to_owned()) }
1260 pub fn type_ref(&self) -> Option<&TypeRef> {
1261 super::child_opt(self)
1266 #[derive(Debug, PartialEq, Eq, Hash)]
1267 #[repr(transparent)]
1269 pub(crate) syntax: SyntaxNode,
1271 unsafe impl TransparentNewType for IfExpr {
1272 type Repr = rowan::SyntaxNode<RaTypes>;
1275 impl AstNode for IfExpr {
1276 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1277 match syntax.kind() {
1278 IF_EXPR => Some(IfExpr::from_repr(syntax.into_repr())),
1282 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1285 impl ToOwned for IfExpr {
1286 type Owned = TreeArc<IfExpr>;
1287 fn to_owned(&self) -> TreeArc<IfExpr> { TreeArc::cast(self.syntax.to_owned()) }
1292 pub fn condition(&self) -> Option<&Condition> {
1293 super::child_opt(self)
1298 #[derive(Debug, PartialEq, Eq, Hash)]
1299 #[repr(transparent)]
1300 pub struct ImplBlock {
1301 pub(crate) syntax: SyntaxNode,
1303 unsafe impl TransparentNewType for ImplBlock {
1304 type Repr = rowan::SyntaxNode<RaTypes>;
1307 impl AstNode for ImplBlock {
1308 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1309 match syntax.kind() {
1310 IMPL_BLOCK => Some(ImplBlock::from_repr(syntax.into_repr())),
1314 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1317 impl ToOwned for ImplBlock {
1318 type Owned = TreeArc<ImplBlock>;
1319 fn to_owned(&self) -> TreeArc<ImplBlock> { TreeArc::cast(self.syntax.to_owned()) }
1323 impl ast::TypeParamsOwner for ImplBlock {}
1325 pub fn item_list(&self) -> Option<&ItemList> {
1326 super::child_opt(self)
1331 #[derive(Debug, PartialEq, Eq, Hash)]
1332 #[repr(transparent)]
1333 pub struct ImplItem {
1334 pub(crate) syntax: SyntaxNode,
1336 unsafe impl TransparentNewType for ImplItem {
1337 type Repr = rowan::SyntaxNode<RaTypes>;
1340 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1341 pub enum ImplItemKind<'a> {
1343 TypeAliasDef(&'a TypeAliasDef),
1344 ConstDef(&'a ConstDef),
1346 impl<'a> From<&'a FnDef> for &'a ImplItem {
1347 fn from(n: &'a FnDef) -> &'a ImplItem {
1348 ImplItem::cast(&n.syntax).unwrap()
1351 impl<'a> From<&'a TypeAliasDef> for &'a ImplItem {
1352 fn from(n: &'a TypeAliasDef) -> &'a ImplItem {
1353 ImplItem::cast(&n.syntax).unwrap()
1356 impl<'a> From<&'a ConstDef> for &'a ImplItem {
1357 fn from(n: &'a ConstDef) -> &'a ImplItem {
1358 ImplItem::cast(&n.syntax).unwrap()
1363 impl AstNode for ImplItem {
1364 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1365 match syntax.kind() {
1368 | CONST_DEF => Some(ImplItem::from_repr(syntax.into_repr())),
1372 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1375 impl ToOwned for ImplItem {
1376 type Owned = TreeArc<ImplItem>;
1377 fn to_owned(&self) -> TreeArc<ImplItem> { TreeArc::cast(self.syntax.to_owned()) }
1381 pub fn kind(&self) -> ImplItemKind {
1382 match self.syntax.kind() {
1383 FN_DEF => ImplItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
1384 TYPE_ALIAS_DEF => ImplItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
1385 CONST_DEF => ImplItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
1386 _ => unreachable!(),
1394 #[derive(Debug, PartialEq, Eq, Hash)]
1395 #[repr(transparent)]
1396 pub struct ImplTraitType {
1397 pub(crate) syntax: SyntaxNode,
1399 unsafe impl TransparentNewType for ImplTraitType {
1400 type Repr = rowan::SyntaxNode<RaTypes>;
1403 impl AstNode for ImplTraitType {
1404 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1405 match syntax.kind() {
1406 IMPL_TRAIT_TYPE => Some(ImplTraitType::from_repr(syntax.into_repr())),
1410 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1413 impl ToOwned for ImplTraitType {
1414 type Owned = TreeArc<ImplTraitType>;
1415 fn to_owned(&self) -> TreeArc<ImplTraitType> { TreeArc::cast(self.syntax.to_owned()) }
1419 impl ast::TypeBoundsOwner for ImplTraitType {}
1420 impl ImplTraitType {}
1423 #[derive(Debug, PartialEq, Eq, Hash)]
1424 #[repr(transparent)]
1425 pub struct IndexExpr {
1426 pub(crate) syntax: SyntaxNode,
1428 unsafe impl TransparentNewType for IndexExpr {
1429 type Repr = rowan::SyntaxNode<RaTypes>;
1432 impl AstNode for IndexExpr {
1433 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1434 match syntax.kind() {
1435 INDEX_EXPR => Some(IndexExpr::from_repr(syntax.into_repr())),
1439 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1442 impl ToOwned for IndexExpr {
1443 type Owned = TreeArc<IndexExpr>;
1444 fn to_owned(&self) -> TreeArc<IndexExpr> { TreeArc::cast(self.syntax.to_owned()) }
1451 #[derive(Debug, PartialEq, Eq, Hash)]
1452 #[repr(transparent)]
1453 pub struct ItemList {
1454 pub(crate) syntax: SyntaxNode,
1456 unsafe impl TransparentNewType for ItemList {
1457 type Repr = rowan::SyntaxNode<RaTypes>;
1460 impl AstNode for ItemList {
1461 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1462 match syntax.kind() {
1463 ITEM_LIST => Some(ItemList::from_repr(syntax.into_repr())),
1467 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1470 impl ToOwned for ItemList {
1471 type Owned = TreeArc<ItemList>;
1472 fn to_owned(&self) -> TreeArc<ItemList> { TreeArc::cast(self.syntax.to_owned()) }
1476 impl ast::FnDefOwner for ItemList {}
1477 impl ast::ModuleItemOwner for ItemList {}
1479 pub fn impl_items(&self) -> impl Iterator<Item = &ImplItem> {
1480 super::children(self)
1485 #[derive(Debug, PartialEq, Eq, Hash)]
1486 #[repr(transparent)]
1488 pub(crate) syntax: SyntaxNode,
1490 unsafe impl TransparentNewType for Label {
1491 type Repr = rowan::SyntaxNode<RaTypes>;
1494 impl AstNode for Label {
1495 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1496 match syntax.kind() {
1497 LABEL => Some(Label::from_repr(syntax.into_repr())),
1501 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1504 impl ToOwned for Label {
1505 type Owned = TreeArc<Label>;
1506 fn to_owned(&self) -> TreeArc<Label> { TreeArc::cast(self.syntax.to_owned()) }
1513 #[derive(Debug, PartialEq, Eq, Hash)]
1514 #[repr(transparent)]
1515 pub struct LambdaExpr {
1516 pub(crate) syntax: SyntaxNode,
1518 unsafe impl TransparentNewType for LambdaExpr {
1519 type Repr = rowan::SyntaxNode<RaTypes>;
1522 impl AstNode for LambdaExpr {
1523 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1524 match syntax.kind() {
1525 LAMBDA_EXPR => Some(LambdaExpr::from_repr(syntax.into_repr())),
1529 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1532 impl ToOwned for LambdaExpr {
1533 type Owned = TreeArc<LambdaExpr>;
1534 fn to_owned(&self) -> TreeArc<LambdaExpr> { TreeArc::cast(self.syntax.to_owned()) }
1539 pub fn param_list(&self) -> Option<&ParamList> {
1540 super::child_opt(self)
1543 pub fn body(&self) -> Option<&Expr> {
1544 super::child_opt(self)
1549 #[derive(Debug, PartialEq, Eq, Hash)]
1550 #[repr(transparent)]
1551 pub struct LetStmt {
1552 pub(crate) syntax: SyntaxNode,
1554 unsafe impl TransparentNewType for LetStmt {
1555 type Repr = rowan::SyntaxNode<RaTypes>;
1558 impl AstNode for LetStmt {
1559 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1560 match syntax.kind() {
1561 LET_STMT => Some(LetStmt::from_repr(syntax.into_repr())),
1565 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1568 impl ToOwned for LetStmt {
1569 type Owned = TreeArc<LetStmt>;
1570 fn to_owned(&self) -> TreeArc<LetStmt> { TreeArc::cast(self.syntax.to_owned()) }
1574 impl ast::TypeAscriptionOwner for LetStmt {}
1576 pub fn pat(&self) -> Option<&Pat> {
1577 super::child_opt(self)
1580 pub fn initializer(&self) -> Option<&Expr> {
1581 super::child_opt(self)
1586 #[derive(Debug, PartialEq, Eq, Hash)]
1587 #[repr(transparent)]
1588 pub struct LifetimeArg {
1589 pub(crate) syntax: SyntaxNode,
1591 unsafe impl TransparentNewType for LifetimeArg {
1592 type Repr = rowan::SyntaxNode<RaTypes>;
1595 impl AstNode for LifetimeArg {
1596 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1597 match syntax.kind() {
1598 LIFETIME_ARG => Some(LifetimeArg::from_repr(syntax.into_repr())),
1602 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1605 impl ToOwned for LifetimeArg {
1606 type Owned = TreeArc<LifetimeArg>;
1607 fn to_owned(&self) -> TreeArc<LifetimeArg> { TreeArc::cast(self.syntax.to_owned()) }
1614 #[derive(Debug, PartialEq, Eq, Hash)]
1615 #[repr(transparent)]
1616 pub struct LifetimeParam {
1617 pub(crate) syntax: SyntaxNode,
1619 unsafe impl TransparentNewType for LifetimeParam {
1620 type Repr = rowan::SyntaxNode<RaTypes>;
1623 impl AstNode for LifetimeParam {
1624 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1625 match syntax.kind() {
1626 LIFETIME_PARAM => Some(LifetimeParam::from_repr(syntax.into_repr())),
1630 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1633 impl ToOwned for LifetimeParam {
1634 type Owned = TreeArc<LifetimeParam>;
1635 fn to_owned(&self) -> TreeArc<LifetimeParam> { TreeArc::cast(self.syntax.to_owned()) }
1639 impl ast::AttrsOwner for LifetimeParam {}
1640 impl LifetimeParam {}
1643 #[derive(Debug, PartialEq, Eq, Hash)]
1644 #[repr(transparent)]
1645 pub struct Literal {
1646 pub(crate) syntax: SyntaxNode,
1648 unsafe impl TransparentNewType for Literal {
1649 type Repr = rowan::SyntaxNode<RaTypes>;
1652 impl AstNode for Literal {
1653 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1654 match syntax.kind() {
1655 LITERAL => Some(Literal::from_repr(syntax.into_repr())),
1659 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1662 impl ToOwned for Literal {
1663 type Owned = TreeArc<Literal>;
1664 fn to_owned(&self) -> TreeArc<Literal> { TreeArc::cast(self.syntax.to_owned()) }
1671 #[derive(Debug, PartialEq, Eq, Hash)]
1672 #[repr(transparent)]
1673 pub struct LiteralPat {
1674 pub(crate) syntax: SyntaxNode,
1676 unsafe impl TransparentNewType for LiteralPat {
1677 type Repr = rowan::SyntaxNode<RaTypes>;
1680 impl AstNode for LiteralPat {
1681 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1682 match syntax.kind() {
1683 LITERAL_PAT => Some(LiteralPat::from_repr(syntax.into_repr())),
1687 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1690 impl ToOwned for LiteralPat {
1691 type Owned = TreeArc<LiteralPat>;
1692 fn to_owned(&self) -> TreeArc<LiteralPat> { TreeArc::cast(self.syntax.to_owned()) }
1697 pub fn literal(&self) -> Option<&Literal> {
1698 super::child_opt(self)
1703 #[derive(Debug, PartialEq, Eq, Hash)]
1704 #[repr(transparent)]
1705 pub struct LoopExpr {
1706 pub(crate) syntax: SyntaxNode,
1708 unsafe impl TransparentNewType for LoopExpr {
1709 type Repr = rowan::SyntaxNode<RaTypes>;
1712 impl AstNode for LoopExpr {
1713 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1714 match syntax.kind() {
1715 LOOP_EXPR => Some(LoopExpr::from_repr(syntax.into_repr())),
1719 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1722 impl ToOwned for LoopExpr {
1723 type Owned = TreeArc<LoopExpr>;
1724 fn to_owned(&self) -> TreeArc<LoopExpr> { TreeArc::cast(self.syntax.to_owned()) }
1728 impl ast::LoopBodyOwner for LoopExpr {}
1732 #[derive(Debug, PartialEq, Eq, Hash)]
1733 #[repr(transparent)]
1734 pub struct MacroCall {
1735 pub(crate) syntax: SyntaxNode,
1737 unsafe impl TransparentNewType for MacroCall {
1738 type Repr = rowan::SyntaxNode<RaTypes>;
1741 impl AstNode for MacroCall {
1742 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1743 match syntax.kind() {
1744 MACRO_CALL => Some(MacroCall::from_repr(syntax.into_repr())),
1748 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1751 impl ToOwned for MacroCall {
1752 type Owned = TreeArc<MacroCall>;
1753 fn to_owned(&self) -> TreeArc<MacroCall> { TreeArc::cast(self.syntax.to_owned()) }
1757 impl ast::NameOwner for MacroCall {}
1758 impl ast::AttrsOwner for MacroCall {}
1760 pub fn token_tree(&self) -> Option<&TokenTree> {
1761 super::child_opt(self)
1764 pub fn path(&self) -> Option<&Path> {
1765 super::child_opt(self)
1770 #[derive(Debug, PartialEq, Eq, Hash)]
1771 #[repr(transparent)]
1772 pub struct MatchArm {
1773 pub(crate) syntax: SyntaxNode,
1775 unsafe impl TransparentNewType for MatchArm {
1776 type Repr = rowan::SyntaxNode<RaTypes>;
1779 impl AstNode for MatchArm {
1780 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1781 match syntax.kind() {
1782 MATCH_ARM => Some(MatchArm::from_repr(syntax.into_repr())),
1786 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1789 impl ToOwned for MatchArm {
1790 type Owned = TreeArc<MatchArm>;
1791 fn to_owned(&self) -> TreeArc<MatchArm> { TreeArc::cast(self.syntax.to_owned()) }
1795 impl ast::AttrsOwner for MatchArm {}
1797 pub fn pats(&self) -> impl Iterator<Item = &Pat> {
1798 super::children(self)
1801 pub fn guard(&self) -> Option<&MatchGuard> {
1802 super::child_opt(self)
1805 pub fn expr(&self) -> Option<&Expr> {
1806 super::child_opt(self)
1811 #[derive(Debug, PartialEq, Eq, Hash)]
1812 #[repr(transparent)]
1813 pub struct MatchArmList {
1814 pub(crate) syntax: SyntaxNode,
1816 unsafe impl TransparentNewType for MatchArmList {
1817 type Repr = rowan::SyntaxNode<RaTypes>;
1820 impl AstNode for MatchArmList {
1821 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1822 match syntax.kind() {
1823 MATCH_ARM_LIST => Some(MatchArmList::from_repr(syntax.into_repr())),
1827 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1830 impl ToOwned for MatchArmList {
1831 type Owned = TreeArc<MatchArmList>;
1832 fn to_owned(&self) -> TreeArc<MatchArmList> { TreeArc::cast(self.syntax.to_owned()) }
1836 impl ast::AttrsOwner for MatchArmList {}
1838 pub fn arms(&self) -> impl Iterator<Item = &MatchArm> {
1839 super::children(self)
1844 #[derive(Debug, PartialEq, Eq, Hash)]
1845 #[repr(transparent)]
1846 pub struct MatchExpr {
1847 pub(crate) syntax: SyntaxNode,
1849 unsafe impl TransparentNewType for MatchExpr {
1850 type Repr = rowan::SyntaxNode<RaTypes>;
1853 impl AstNode for MatchExpr {
1854 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1855 match syntax.kind() {
1856 MATCH_EXPR => Some(MatchExpr::from_repr(syntax.into_repr())),
1860 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1863 impl ToOwned for MatchExpr {
1864 type Owned = TreeArc<MatchExpr>;
1865 fn to_owned(&self) -> TreeArc<MatchExpr> { TreeArc::cast(self.syntax.to_owned()) }
1870 pub fn expr(&self) -> Option<&Expr> {
1871 super::child_opt(self)
1874 pub fn match_arm_list(&self) -> Option<&MatchArmList> {
1875 super::child_opt(self)
1880 #[derive(Debug, PartialEq, Eq, Hash)]
1881 #[repr(transparent)]
1882 pub struct MatchGuard {
1883 pub(crate) syntax: SyntaxNode,
1885 unsafe impl TransparentNewType for MatchGuard {
1886 type Repr = rowan::SyntaxNode<RaTypes>;
1889 impl AstNode for MatchGuard {
1890 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1891 match syntax.kind() {
1892 MATCH_GUARD => Some(MatchGuard::from_repr(syntax.into_repr())),
1896 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1899 impl ToOwned for MatchGuard {
1900 type Owned = TreeArc<MatchGuard>;
1901 fn to_owned(&self) -> TreeArc<MatchGuard> { TreeArc::cast(self.syntax.to_owned()) }
1906 pub fn expr(&self) -> Option<&Expr> {
1907 super::child_opt(self)
1912 #[derive(Debug, PartialEq, Eq, Hash)]
1913 #[repr(transparent)]
1914 pub struct MethodCallExpr {
1915 pub(crate) syntax: SyntaxNode,
1917 unsafe impl TransparentNewType for MethodCallExpr {
1918 type Repr = rowan::SyntaxNode<RaTypes>;
1921 impl AstNode for MethodCallExpr {
1922 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1923 match syntax.kind() {
1924 METHOD_CALL_EXPR => Some(MethodCallExpr::from_repr(syntax.into_repr())),
1928 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1931 impl ToOwned for MethodCallExpr {
1932 type Owned = TreeArc<MethodCallExpr>;
1933 fn to_owned(&self) -> TreeArc<MethodCallExpr> { TreeArc::cast(self.syntax.to_owned()) }
1937 impl ast::ArgListOwner for MethodCallExpr {}
1938 impl MethodCallExpr {
1939 pub fn expr(&self) -> Option<&Expr> {
1940 super::child_opt(self)
1943 pub fn name_ref(&self) -> Option<&NameRef> {
1944 super::child_opt(self)
1947 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
1948 super::child_opt(self)
1953 #[derive(Debug, PartialEq, Eq, Hash)]
1954 #[repr(transparent)]
1956 pub(crate) syntax: SyntaxNode,
1958 unsafe impl TransparentNewType for Module {
1959 type Repr = rowan::SyntaxNode<RaTypes>;
1962 impl AstNode for Module {
1963 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1964 match syntax.kind() {
1965 MODULE => Some(Module::from_repr(syntax.into_repr())),
1969 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1972 impl ToOwned for Module {
1973 type Owned = TreeArc<Module>;
1974 fn to_owned(&self) -> TreeArc<Module> { TreeArc::cast(self.syntax.to_owned()) }
1978 impl ast::VisibilityOwner for Module {}
1979 impl ast::NameOwner for Module {}
1980 impl ast::AttrsOwner for Module {}
1981 impl ast::DocCommentsOwner for Module {}
1983 pub fn item_list(&self) -> Option<&ItemList> {
1984 super::child_opt(self)
1989 #[derive(Debug, PartialEq, Eq, Hash)]
1990 #[repr(transparent)]
1991 pub struct ModuleItem {
1992 pub(crate) syntax: SyntaxNode,
1994 unsafe impl TransparentNewType for ModuleItem {
1995 type Repr = rowan::SyntaxNode<RaTypes>;
1998 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1999 pub enum ModuleItemKind<'a> {
2000 StructDef(&'a StructDef),
2001 EnumDef(&'a EnumDef),
2003 TraitDef(&'a TraitDef),
2004 TypeAliasDef(&'a TypeAliasDef),
2005 ImplBlock(&'a ImplBlock),
2006 UseItem(&'a UseItem),
2007 ExternCrateItem(&'a ExternCrateItem),
2008 ConstDef(&'a ConstDef),
2009 StaticDef(&'a StaticDef),
2012 impl<'a> From<&'a StructDef> for &'a ModuleItem {
2013 fn from(n: &'a StructDef) -> &'a ModuleItem {
2014 ModuleItem::cast(&n.syntax).unwrap()
2017 impl<'a> From<&'a EnumDef> for &'a ModuleItem {
2018 fn from(n: &'a EnumDef) -> &'a ModuleItem {
2019 ModuleItem::cast(&n.syntax).unwrap()
2022 impl<'a> From<&'a FnDef> for &'a ModuleItem {
2023 fn from(n: &'a FnDef) -> &'a ModuleItem {
2024 ModuleItem::cast(&n.syntax).unwrap()
2027 impl<'a> From<&'a TraitDef> for &'a ModuleItem {
2028 fn from(n: &'a TraitDef) -> &'a ModuleItem {
2029 ModuleItem::cast(&n.syntax).unwrap()
2032 impl<'a> From<&'a TypeAliasDef> for &'a ModuleItem {
2033 fn from(n: &'a TypeAliasDef) -> &'a ModuleItem {
2034 ModuleItem::cast(&n.syntax).unwrap()
2037 impl<'a> From<&'a ImplBlock> for &'a ModuleItem {
2038 fn from(n: &'a ImplBlock) -> &'a ModuleItem {
2039 ModuleItem::cast(&n.syntax).unwrap()
2042 impl<'a> From<&'a UseItem> for &'a ModuleItem {
2043 fn from(n: &'a UseItem) -> &'a ModuleItem {
2044 ModuleItem::cast(&n.syntax).unwrap()
2047 impl<'a> From<&'a ExternCrateItem> for &'a ModuleItem {
2048 fn from(n: &'a ExternCrateItem) -> &'a ModuleItem {
2049 ModuleItem::cast(&n.syntax).unwrap()
2052 impl<'a> From<&'a ConstDef> for &'a ModuleItem {
2053 fn from(n: &'a ConstDef) -> &'a ModuleItem {
2054 ModuleItem::cast(&n.syntax).unwrap()
2057 impl<'a> From<&'a StaticDef> for &'a ModuleItem {
2058 fn from(n: &'a StaticDef) -> &'a ModuleItem {
2059 ModuleItem::cast(&n.syntax).unwrap()
2062 impl<'a> From<&'a Module> for &'a ModuleItem {
2063 fn from(n: &'a Module) -> &'a ModuleItem {
2064 ModuleItem::cast(&n.syntax).unwrap()
2069 impl AstNode for ModuleItem {
2070 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2071 match syntax.kind() {
2082 | MODULE => Some(ModuleItem::from_repr(syntax.into_repr())),
2086 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2089 impl ToOwned for ModuleItem {
2090 type Owned = TreeArc<ModuleItem>;
2091 fn to_owned(&self) -> TreeArc<ModuleItem> { TreeArc::cast(self.syntax.to_owned()) }
2095 pub fn kind(&self) -> ModuleItemKind {
2096 match self.syntax.kind() {
2097 STRUCT_DEF => ModuleItemKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2098 ENUM_DEF => ModuleItemKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2099 FN_DEF => ModuleItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
2100 TRAIT_DEF => ModuleItemKind::TraitDef(TraitDef::cast(&self.syntax).unwrap()),
2101 TYPE_ALIAS_DEF => ModuleItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
2102 IMPL_BLOCK => ModuleItemKind::ImplBlock(ImplBlock::cast(&self.syntax).unwrap()),
2103 USE_ITEM => ModuleItemKind::UseItem(UseItem::cast(&self.syntax).unwrap()),
2104 EXTERN_CRATE_ITEM => ModuleItemKind::ExternCrateItem(ExternCrateItem::cast(&self.syntax).unwrap()),
2105 CONST_DEF => ModuleItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
2106 STATIC_DEF => ModuleItemKind::StaticDef(StaticDef::cast(&self.syntax).unwrap()),
2107 MODULE => ModuleItemKind::Module(Module::cast(&self.syntax).unwrap()),
2108 _ => unreachable!(),
2116 #[derive(Debug, PartialEq, Eq, Hash)]
2117 #[repr(transparent)]
2119 pub(crate) syntax: SyntaxNode,
2121 unsafe impl TransparentNewType for Name {
2122 type Repr = rowan::SyntaxNode<RaTypes>;
2125 impl AstNode for Name {
2126 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2127 match syntax.kind() {
2128 NAME => Some(Name::from_repr(syntax.into_repr())),
2132 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2135 impl ToOwned for Name {
2136 type Owned = TreeArc<Name>;
2137 fn to_owned(&self) -> TreeArc<Name> { TreeArc::cast(self.syntax.to_owned()) }
2144 #[derive(Debug, PartialEq, Eq, Hash)]
2145 #[repr(transparent)]
2146 pub struct NameRef {
2147 pub(crate) syntax: SyntaxNode,
2149 unsafe impl TransparentNewType for NameRef {
2150 type Repr = rowan::SyntaxNode<RaTypes>;
2153 impl AstNode for NameRef {
2154 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2155 match syntax.kind() {
2156 NAME_REF => Some(NameRef::from_repr(syntax.into_repr())),
2160 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2163 impl ToOwned for NameRef {
2164 type Owned = TreeArc<NameRef>;
2165 fn to_owned(&self) -> TreeArc<NameRef> { TreeArc::cast(self.syntax.to_owned()) }
2172 #[derive(Debug, PartialEq, Eq, Hash)]
2173 #[repr(transparent)]
2174 pub struct NamedField {
2175 pub(crate) syntax: SyntaxNode,
2177 unsafe impl TransparentNewType for NamedField {
2178 type Repr = rowan::SyntaxNode<RaTypes>;
2181 impl AstNode for NamedField {
2182 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2183 match syntax.kind() {
2184 NAMED_FIELD => Some(NamedField::from_repr(syntax.into_repr())),
2188 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2191 impl ToOwned for NamedField {
2192 type Owned = TreeArc<NamedField>;
2193 fn to_owned(&self) -> TreeArc<NamedField> { TreeArc::cast(self.syntax.to_owned()) }
2198 pub fn name_ref(&self) -> Option<&NameRef> {
2199 super::child_opt(self)
2202 pub fn expr(&self) -> Option<&Expr> {
2203 super::child_opt(self)
2208 #[derive(Debug, PartialEq, Eq, Hash)]
2209 #[repr(transparent)]
2210 pub struct NamedFieldDef {
2211 pub(crate) syntax: SyntaxNode,
2213 unsafe impl TransparentNewType for NamedFieldDef {
2214 type Repr = rowan::SyntaxNode<RaTypes>;
2217 impl AstNode for NamedFieldDef {
2218 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2219 match syntax.kind() {
2220 NAMED_FIELD_DEF => Some(NamedFieldDef::from_repr(syntax.into_repr())),
2224 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2227 impl ToOwned for NamedFieldDef {
2228 type Owned = TreeArc<NamedFieldDef>;
2229 fn to_owned(&self) -> TreeArc<NamedFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2233 impl ast::VisibilityOwner for NamedFieldDef {}
2234 impl ast::NameOwner for NamedFieldDef {}
2235 impl ast::AttrsOwner for NamedFieldDef {}
2236 impl ast::DocCommentsOwner for NamedFieldDef {}
2237 impl ast::TypeAscriptionOwner for NamedFieldDef {}
2238 impl NamedFieldDef {}
2240 // NamedFieldDefList
2241 #[derive(Debug, PartialEq, Eq, Hash)]
2242 #[repr(transparent)]
2243 pub struct NamedFieldDefList {
2244 pub(crate) syntax: SyntaxNode,
2246 unsafe impl TransparentNewType for NamedFieldDefList {
2247 type Repr = rowan::SyntaxNode<RaTypes>;
2250 impl AstNode for NamedFieldDefList {
2251 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2252 match syntax.kind() {
2253 NAMED_FIELD_DEF_LIST => Some(NamedFieldDefList::from_repr(syntax.into_repr())),
2257 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2260 impl ToOwned for NamedFieldDefList {
2261 type Owned = TreeArc<NamedFieldDefList>;
2262 fn to_owned(&self) -> TreeArc<NamedFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
2266 impl NamedFieldDefList {
2267 pub fn fields(&self) -> impl Iterator<Item = &NamedFieldDef> {
2268 super::children(self)
2273 #[derive(Debug, PartialEq, Eq, Hash)]
2274 #[repr(transparent)]
2275 pub struct NamedFieldList {
2276 pub(crate) syntax: SyntaxNode,
2278 unsafe impl TransparentNewType for NamedFieldList {
2279 type Repr = rowan::SyntaxNode<RaTypes>;
2282 impl AstNode for NamedFieldList {
2283 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2284 match syntax.kind() {
2285 NAMED_FIELD_LIST => Some(NamedFieldList::from_repr(syntax.into_repr())),
2289 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2292 impl ToOwned for NamedFieldList {
2293 type Owned = TreeArc<NamedFieldList>;
2294 fn to_owned(&self) -> TreeArc<NamedFieldList> { TreeArc::cast(self.syntax.to_owned()) }
2298 impl NamedFieldList {
2299 pub fn fields(&self) -> impl Iterator<Item = &NamedField> {
2300 super::children(self)
2305 #[derive(Debug, PartialEq, Eq, Hash)]
2306 #[repr(transparent)]
2307 pub struct NeverType {
2308 pub(crate) syntax: SyntaxNode,
2310 unsafe impl TransparentNewType for NeverType {
2311 type Repr = rowan::SyntaxNode<RaTypes>;
2314 impl AstNode for NeverType {
2315 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2316 match syntax.kind() {
2317 NEVER_TYPE => Some(NeverType::from_repr(syntax.into_repr())),
2321 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2324 impl ToOwned for NeverType {
2325 type Owned = TreeArc<NeverType>;
2326 fn to_owned(&self) -> TreeArc<NeverType> { TreeArc::cast(self.syntax.to_owned()) }
2333 #[derive(Debug, PartialEq, Eq, Hash)]
2334 #[repr(transparent)]
2335 pub struct NominalDef {
2336 pub(crate) syntax: SyntaxNode,
2338 unsafe impl TransparentNewType for NominalDef {
2339 type Repr = rowan::SyntaxNode<RaTypes>;
2342 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2343 pub enum NominalDefKind<'a> {
2344 StructDef(&'a StructDef),
2345 EnumDef(&'a EnumDef),
2347 impl<'a> From<&'a StructDef> for &'a NominalDef {
2348 fn from(n: &'a StructDef) -> &'a NominalDef {
2349 NominalDef::cast(&n.syntax).unwrap()
2352 impl<'a> From<&'a EnumDef> for &'a NominalDef {
2353 fn from(n: &'a EnumDef) -> &'a NominalDef {
2354 NominalDef::cast(&n.syntax).unwrap()
2359 impl AstNode for NominalDef {
2360 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2361 match syntax.kind() {
2363 | ENUM_DEF => Some(NominalDef::from_repr(syntax.into_repr())),
2367 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2370 impl ToOwned for NominalDef {
2371 type Owned = TreeArc<NominalDef>;
2372 fn to_owned(&self) -> TreeArc<NominalDef> { TreeArc::cast(self.syntax.to_owned()) }
2376 pub fn kind(&self) -> NominalDefKind {
2377 match self.syntax.kind() {
2378 STRUCT_DEF => NominalDefKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2379 ENUM_DEF => NominalDefKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2380 _ => unreachable!(),
2385 impl ast::NameOwner for NominalDef {}
2386 impl ast::TypeParamsOwner for NominalDef {}
2387 impl ast::AttrsOwner for NominalDef {}
2391 #[derive(Debug, PartialEq, Eq, Hash)]
2392 #[repr(transparent)]
2394 pub(crate) syntax: SyntaxNode,
2396 unsafe impl TransparentNewType for Param {
2397 type Repr = rowan::SyntaxNode<RaTypes>;
2400 impl AstNode for Param {
2401 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2402 match syntax.kind() {
2403 PARAM => Some(Param::from_repr(syntax.into_repr())),
2407 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2410 impl ToOwned for Param {
2411 type Owned = TreeArc<Param>;
2412 fn to_owned(&self) -> TreeArc<Param> { TreeArc::cast(self.syntax.to_owned()) }
2416 impl ast::TypeAscriptionOwner for Param {}
2418 pub fn pat(&self) -> Option<&Pat> {
2419 super::child_opt(self)
2424 #[derive(Debug, PartialEq, Eq, Hash)]
2425 #[repr(transparent)]
2426 pub struct ParamList {
2427 pub(crate) syntax: SyntaxNode,
2429 unsafe impl TransparentNewType for ParamList {
2430 type Repr = rowan::SyntaxNode<RaTypes>;
2433 impl AstNode for ParamList {
2434 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2435 match syntax.kind() {
2436 PARAM_LIST => Some(ParamList::from_repr(syntax.into_repr())),
2440 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2443 impl ToOwned for ParamList {
2444 type Owned = TreeArc<ParamList>;
2445 fn to_owned(&self) -> TreeArc<ParamList> { TreeArc::cast(self.syntax.to_owned()) }
2450 pub fn params(&self) -> impl Iterator<Item = &Param> {
2451 super::children(self)
2454 pub fn self_param(&self) -> Option<&SelfParam> {
2455 super::child_opt(self)
2460 #[derive(Debug, PartialEq, Eq, Hash)]
2461 #[repr(transparent)]
2462 pub struct ParenExpr {
2463 pub(crate) syntax: SyntaxNode,
2465 unsafe impl TransparentNewType for ParenExpr {
2466 type Repr = rowan::SyntaxNode<RaTypes>;
2469 impl AstNode for ParenExpr {
2470 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2471 match syntax.kind() {
2472 PAREN_EXPR => Some(ParenExpr::from_repr(syntax.into_repr())),
2476 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2479 impl ToOwned for ParenExpr {
2480 type Owned = TreeArc<ParenExpr>;
2481 fn to_owned(&self) -> TreeArc<ParenExpr> { TreeArc::cast(self.syntax.to_owned()) }
2486 pub fn expr(&self) -> Option<&Expr> {
2487 super::child_opt(self)
2492 #[derive(Debug, PartialEq, Eq, Hash)]
2493 #[repr(transparent)]
2494 pub struct ParenType {
2495 pub(crate) syntax: SyntaxNode,
2497 unsafe impl TransparentNewType for ParenType {
2498 type Repr = rowan::SyntaxNode<RaTypes>;
2501 impl AstNode for ParenType {
2502 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2503 match syntax.kind() {
2504 PAREN_TYPE => Some(ParenType::from_repr(syntax.into_repr())),
2508 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2511 impl ToOwned for ParenType {
2512 type Owned = TreeArc<ParenType>;
2513 fn to_owned(&self) -> TreeArc<ParenType> { TreeArc::cast(self.syntax.to_owned()) }
2518 pub fn type_ref(&self) -> Option<&TypeRef> {
2519 super::child_opt(self)
2524 #[derive(Debug, PartialEq, Eq, Hash)]
2525 #[repr(transparent)]
2527 pub(crate) syntax: SyntaxNode,
2529 unsafe impl TransparentNewType for Pat {
2530 type Repr = rowan::SyntaxNode<RaTypes>;
2533 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2534 pub enum PatKind<'a> {
2536 BindPat(&'a BindPat),
2537 PlaceholderPat(&'a PlaceholderPat),
2538 PathPat(&'a PathPat),
2539 StructPat(&'a StructPat),
2540 TupleStructPat(&'a TupleStructPat),
2541 TuplePat(&'a TuplePat),
2542 SlicePat(&'a SlicePat),
2543 RangePat(&'a RangePat),
2544 LiteralPat(&'a LiteralPat),
2546 impl<'a> From<&'a RefPat> for &'a Pat {
2547 fn from(n: &'a RefPat) -> &'a Pat {
2548 Pat::cast(&n.syntax).unwrap()
2551 impl<'a> From<&'a BindPat> for &'a Pat {
2552 fn from(n: &'a BindPat) -> &'a Pat {
2553 Pat::cast(&n.syntax).unwrap()
2556 impl<'a> From<&'a PlaceholderPat> for &'a Pat {
2557 fn from(n: &'a PlaceholderPat) -> &'a Pat {
2558 Pat::cast(&n.syntax).unwrap()
2561 impl<'a> From<&'a PathPat> for &'a Pat {
2562 fn from(n: &'a PathPat) -> &'a Pat {
2563 Pat::cast(&n.syntax).unwrap()
2566 impl<'a> From<&'a StructPat> for &'a Pat {
2567 fn from(n: &'a StructPat) -> &'a Pat {
2568 Pat::cast(&n.syntax).unwrap()
2571 impl<'a> From<&'a TupleStructPat> for &'a Pat {
2572 fn from(n: &'a TupleStructPat) -> &'a Pat {
2573 Pat::cast(&n.syntax).unwrap()
2576 impl<'a> From<&'a TuplePat> for &'a Pat {
2577 fn from(n: &'a TuplePat) -> &'a Pat {
2578 Pat::cast(&n.syntax).unwrap()
2581 impl<'a> From<&'a SlicePat> for &'a Pat {
2582 fn from(n: &'a SlicePat) -> &'a Pat {
2583 Pat::cast(&n.syntax).unwrap()
2586 impl<'a> From<&'a RangePat> for &'a Pat {
2587 fn from(n: &'a RangePat) -> &'a Pat {
2588 Pat::cast(&n.syntax).unwrap()
2591 impl<'a> From<&'a LiteralPat> for &'a Pat {
2592 fn from(n: &'a LiteralPat) -> &'a Pat {
2593 Pat::cast(&n.syntax).unwrap()
2598 impl AstNode for Pat {
2599 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2600 match syntax.kind() {
2610 | LITERAL_PAT => Some(Pat::from_repr(syntax.into_repr())),
2614 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2617 impl ToOwned for Pat {
2618 type Owned = TreeArc<Pat>;
2619 fn to_owned(&self) -> TreeArc<Pat> { TreeArc::cast(self.syntax.to_owned()) }
2623 pub fn kind(&self) -> PatKind {
2624 match self.syntax.kind() {
2625 REF_PAT => PatKind::RefPat(RefPat::cast(&self.syntax).unwrap()),
2626 BIND_PAT => PatKind::BindPat(BindPat::cast(&self.syntax).unwrap()),
2627 PLACEHOLDER_PAT => PatKind::PlaceholderPat(PlaceholderPat::cast(&self.syntax).unwrap()),
2628 PATH_PAT => PatKind::PathPat(PathPat::cast(&self.syntax).unwrap()),
2629 STRUCT_PAT => PatKind::StructPat(StructPat::cast(&self.syntax).unwrap()),
2630 TUPLE_STRUCT_PAT => PatKind::TupleStructPat(TupleStructPat::cast(&self.syntax).unwrap()),
2631 TUPLE_PAT => PatKind::TuplePat(TuplePat::cast(&self.syntax).unwrap()),
2632 SLICE_PAT => PatKind::SlicePat(SlicePat::cast(&self.syntax).unwrap()),
2633 RANGE_PAT => PatKind::RangePat(RangePat::cast(&self.syntax).unwrap()),
2634 LITERAL_PAT => PatKind::LiteralPat(LiteralPat::cast(&self.syntax).unwrap()),
2635 _ => unreachable!(),
2643 #[derive(Debug, PartialEq, Eq, Hash)]
2644 #[repr(transparent)]
2646 pub(crate) syntax: SyntaxNode,
2648 unsafe impl TransparentNewType for Path {
2649 type Repr = rowan::SyntaxNode<RaTypes>;
2652 impl AstNode for Path {
2653 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2654 match syntax.kind() {
2655 PATH => Some(Path::from_repr(syntax.into_repr())),
2659 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2662 impl ToOwned for Path {
2663 type Owned = TreeArc<Path>;
2664 fn to_owned(&self) -> TreeArc<Path> { TreeArc::cast(self.syntax.to_owned()) }
2669 pub fn segment(&self) -> Option<&PathSegment> {
2670 super::child_opt(self)
2673 pub fn qualifier(&self) -> Option<&Path> {
2674 super::child_opt(self)
2679 #[derive(Debug, PartialEq, Eq, Hash)]
2680 #[repr(transparent)]
2681 pub struct PathExpr {
2682 pub(crate) syntax: SyntaxNode,
2684 unsafe impl TransparentNewType for PathExpr {
2685 type Repr = rowan::SyntaxNode<RaTypes>;
2688 impl AstNode for PathExpr {
2689 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2690 match syntax.kind() {
2691 PATH_EXPR => Some(PathExpr::from_repr(syntax.into_repr())),
2695 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2698 impl ToOwned for PathExpr {
2699 type Owned = TreeArc<PathExpr>;
2700 fn to_owned(&self) -> TreeArc<PathExpr> { TreeArc::cast(self.syntax.to_owned()) }
2705 pub fn path(&self) -> Option<&Path> {
2706 super::child_opt(self)
2711 #[derive(Debug, PartialEq, Eq, Hash)]
2712 #[repr(transparent)]
2713 pub struct PathPat {
2714 pub(crate) syntax: SyntaxNode,
2716 unsafe impl TransparentNewType for PathPat {
2717 type Repr = rowan::SyntaxNode<RaTypes>;
2720 impl AstNode for PathPat {
2721 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2722 match syntax.kind() {
2723 PATH_PAT => Some(PathPat::from_repr(syntax.into_repr())),
2727 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2730 impl ToOwned for PathPat {
2731 type Owned = TreeArc<PathPat>;
2732 fn to_owned(&self) -> TreeArc<PathPat> { TreeArc::cast(self.syntax.to_owned()) }
2737 pub fn path(&self) -> Option<&Path> {
2738 super::child_opt(self)
2743 #[derive(Debug, PartialEq, Eq, Hash)]
2744 #[repr(transparent)]
2745 pub struct PathSegment {
2746 pub(crate) syntax: SyntaxNode,
2748 unsafe impl TransparentNewType for PathSegment {
2749 type Repr = rowan::SyntaxNode<RaTypes>;
2752 impl AstNode for PathSegment {
2753 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2754 match syntax.kind() {
2755 PATH_SEGMENT => Some(PathSegment::from_repr(syntax.into_repr())),
2759 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2762 impl ToOwned for PathSegment {
2763 type Owned = TreeArc<PathSegment>;
2764 fn to_owned(&self) -> TreeArc<PathSegment> { TreeArc::cast(self.syntax.to_owned()) }
2769 pub fn name_ref(&self) -> Option<&NameRef> {
2770 super::child_opt(self)
2773 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
2774 super::child_opt(self)
2779 #[derive(Debug, PartialEq, Eq, Hash)]
2780 #[repr(transparent)]
2781 pub struct PathType {
2782 pub(crate) syntax: SyntaxNode,
2784 unsafe impl TransparentNewType for PathType {
2785 type Repr = rowan::SyntaxNode<RaTypes>;
2788 impl AstNode for PathType {
2789 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2790 match syntax.kind() {
2791 PATH_TYPE => Some(PathType::from_repr(syntax.into_repr())),
2795 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2798 impl ToOwned for PathType {
2799 type Owned = TreeArc<PathType>;
2800 fn to_owned(&self) -> TreeArc<PathType> { TreeArc::cast(self.syntax.to_owned()) }
2805 pub fn path(&self) -> Option<&Path> {
2806 super::child_opt(self)
2811 #[derive(Debug, PartialEq, Eq, Hash)]
2812 #[repr(transparent)]
2813 pub struct PlaceholderPat {
2814 pub(crate) syntax: SyntaxNode,
2816 unsafe impl TransparentNewType for PlaceholderPat {
2817 type Repr = rowan::SyntaxNode<RaTypes>;
2820 impl AstNode for PlaceholderPat {
2821 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2822 match syntax.kind() {
2823 PLACEHOLDER_PAT => Some(PlaceholderPat::from_repr(syntax.into_repr())),
2827 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2830 impl ToOwned for PlaceholderPat {
2831 type Owned = TreeArc<PlaceholderPat>;
2832 fn to_owned(&self) -> TreeArc<PlaceholderPat> { TreeArc::cast(self.syntax.to_owned()) }
2836 impl PlaceholderPat {}
2839 #[derive(Debug, PartialEq, Eq, Hash)]
2840 #[repr(transparent)]
2841 pub struct PlaceholderType {
2842 pub(crate) syntax: SyntaxNode,
2844 unsafe impl TransparentNewType for PlaceholderType {
2845 type Repr = rowan::SyntaxNode<RaTypes>;
2848 impl AstNode for PlaceholderType {
2849 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2850 match syntax.kind() {
2851 PLACEHOLDER_TYPE => Some(PlaceholderType::from_repr(syntax.into_repr())),
2855 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2858 impl ToOwned for PlaceholderType {
2859 type Owned = TreeArc<PlaceholderType>;
2860 fn to_owned(&self) -> TreeArc<PlaceholderType> { TreeArc::cast(self.syntax.to_owned()) }
2864 impl PlaceholderType {}
2867 #[derive(Debug, PartialEq, Eq, Hash)]
2868 #[repr(transparent)]
2869 pub struct PointerType {
2870 pub(crate) syntax: SyntaxNode,
2872 unsafe impl TransparentNewType for PointerType {
2873 type Repr = rowan::SyntaxNode<RaTypes>;
2876 impl AstNode for PointerType {
2877 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2878 match syntax.kind() {
2879 POINTER_TYPE => Some(PointerType::from_repr(syntax.into_repr())),
2883 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2886 impl ToOwned for PointerType {
2887 type Owned = TreeArc<PointerType>;
2888 fn to_owned(&self) -> TreeArc<PointerType> { TreeArc::cast(self.syntax.to_owned()) }
2893 pub fn type_ref(&self) -> Option<&TypeRef> {
2894 super::child_opt(self)
2899 #[derive(Debug, PartialEq, Eq, Hash)]
2900 #[repr(transparent)]
2901 pub struct PosFieldDef {
2902 pub(crate) syntax: SyntaxNode,
2904 unsafe impl TransparentNewType for PosFieldDef {
2905 type Repr = rowan::SyntaxNode<RaTypes>;
2908 impl AstNode for PosFieldDef {
2909 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2910 match syntax.kind() {
2911 POS_FIELD_DEF => Some(PosFieldDef::from_repr(syntax.into_repr())),
2915 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2918 impl ToOwned for PosFieldDef {
2919 type Owned = TreeArc<PosFieldDef>;
2920 fn to_owned(&self) -> TreeArc<PosFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2924 impl ast::VisibilityOwner for PosFieldDef {}
2925 impl ast::AttrsOwner for PosFieldDef {}
2927 pub fn type_ref(&self) -> Option<&TypeRef> {
2928 super::child_opt(self)
2933 #[derive(Debug, PartialEq, Eq, Hash)]
2934 #[repr(transparent)]
2935 pub struct PosFieldDefList {
2936 pub(crate) syntax: SyntaxNode,
2938 unsafe impl TransparentNewType for PosFieldDefList {
2939 type Repr = rowan::SyntaxNode<RaTypes>;
2942 impl AstNode for PosFieldDefList {
2943 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2944 match syntax.kind() {
2945 POS_FIELD_DEF_LIST => Some(PosFieldDefList::from_repr(syntax.into_repr())),
2949 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2952 impl ToOwned for PosFieldDefList {
2953 type Owned = TreeArc<PosFieldDefList>;
2954 fn to_owned(&self) -> TreeArc<PosFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
2958 impl PosFieldDefList {
2959 pub fn fields(&self) -> impl Iterator<Item = &PosFieldDef> {
2960 super::children(self)
2965 #[derive(Debug, PartialEq, Eq, Hash)]
2966 #[repr(transparent)]
2967 pub struct PrefixExpr {
2968 pub(crate) syntax: SyntaxNode,
2970 unsafe impl TransparentNewType for PrefixExpr {
2971 type Repr = rowan::SyntaxNode<RaTypes>;
2974 impl AstNode for PrefixExpr {
2975 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2976 match syntax.kind() {
2977 PREFIX_EXPR => Some(PrefixExpr::from_repr(syntax.into_repr())),
2981 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2984 impl ToOwned for PrefixExpr {
2985 type Owned = TreeArc<PrefixExpr>;
2986 fn to_owned(&self) -> TreeArc<PrefixExpr> { TreeArc::cast(self.syntax.to_owned()) }
2991 pub fn expr(&self) -> Option<&Expr> {
2992 super::child_opt(self)
2997 #[derive(Debug, PartialEq, Eq, Hash)]
2998 #[repr(transparent)]
2999 pub struct RangeExpr {
3000 pub(crate) syntax: SyntaxNode,
3002 unsafe impl TransparentNewType for RangeExpr {
3003 type Repr = rowan::SyntaxNode<RaTypes>;
3006 impl AstNode for RangeExpr {
3007 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3008 match syntax.kind() {
3009 RANGE_EXPR => Some(RangeExpr::from_repr(syntax.into_repr())),
3013 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3016 impl ToOwned for RangeExpr {
3017 type Owned = TreeArc<RangeExpr>;
3018 fn to_owned(&self) -> TreeArc<RangeExpr> { TreeArc::cast(self.syntax.to_owned()) }
3025 #[derive(Debug, PartialEq, Eq, Hash)]
3026 #[repr(transparent)]
3027 pub struct RangePat {
3028 pub(crate) syntax: SyntaxNode,
3030 unsafe impl TransparentNewType for RangePat {
3031 type Repr = rowan::SyntaxNode<RaTypes>;
3034 impl AstNode for RangePat {
3035 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3036 match syntax.kind() {
3037 RANGE_PAT => Some(RangePat::from_repr(syntax.into_repr())),
3041 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3044 impl ToOwned for RangePat {
3045 type Owned = TreeArc<RangePat>;
3046 fn to_owned(&self) -> TreeArc<RangePat> { TreeArc::cast(self.syntax.to_owned()) }
3053 #[derive(Debug, PartialEq, Eq, Hash)]
3054 #[repr(transparent)]
3055 pub struct RefExpr {
3056 pub(crate) syntax: SyntaxNode,
3058 unsafe impl TransparentNewType for RefExpr {
3059 type Repr = rowan::SyntaxNode<RaTypes>;
3062 impl AstNode for RefExpr {
3063 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3064 match syntax.kind() {
3065 REF_EXPR => Some(RefExpr::from_repr(syntax.into_repr())),
3069 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3072 impl ToOwned for RefExpr {
3073 type Owned = TreeArc<RefExpr>;
3074 fn to_owned(&self) -> TreeArc<RefExpr> { TreeArc::cast(self.syntax.to_owned()) }
3079 pub fn expr(&self) -> Option<&Expr> {
3080 super::child_opt(self)
3085 #[derive(Debug, PartialEq, Eq, Hash)]
3086 #[repr(transparent)]
3088 pub(crate) syntax: SyntaxNode,
3090 unsafe impl TransparentNewType for RefPat {
3091 type Repr = rowan::SyntaxNode<RaTypes>;
3094 impl AstNode for RefPat {
3095 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3096 match syntax.kind() {
3097 REF_PAT => Some(RefPat::from_repr(syntax.into_repr())),
3101 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3104 impl ToOwned for RefPat {
3105 type Owned = TreeArc<RefPat>;
3106 fn to_owned(&self) -> TreeArc<RefPat> { TreeArc::cast(self.syntax.to_owned()) }
3111 pub fn pat(&self) -> Option<&Pat> {
3112 super::child_opt(self)
3117 #[derive(Debug, PartialEq, Eq, Hash)]
3118 #[repr(transparent)]
3119 pub struct ReferenceType {
3120 pub(crate) syntax: SyntaxNode,
3122 unsafe impl TransparentNewType for ReferenceType {
3123 type Repr = rowan::SyntaxNode<RaTypes>;
3126 impl AstNode for ReferenceType {
3127 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3128 match syntax.kind() {
3129 REFERENCE_TYPE => Some(ReferenceType::from_repr(syntax.into_repr())),
3133 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3136 impl ToOwned for ReferenceType {
3137 type Owned = TreeArc<ReferenceType>;
3138 fn to_owned(&self) -> TreeArc<ReferenceType> { TreeArc::cast(self.syntax.to_owned()) }
3142 impl ReferenceType {
3143 pub fn type_ref(&self) -> Option<&TypeRef> {
3144 super::child_opt(self)
3149 #[derive(Debug, PartialEq, Eq, Hash)]
3150 #[repr(transparent)]
3151 pub struct RetType {
3152 pub(crate) syntax: SyntaxNode,
3154 unsafe impl TransparentNewType for RetType {
3155 type Repr = rowan::SyntaxNode<RaTypes>;
3158 impl AstNode for RetType {
3159 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3160 match syntax.kind() {
3161 RET_TYPE => Some(RetType::from_repr(syntax.into_repr())),
3165 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3168 impl ToOwned for RetType {
3169 type Owned = TreeArc<RetType>;
3170 fn to_owned(&self) -> TreeArc<RetType> { TreeArc::cast(self.syntax.to_owned()) }
3175 pub fn type_ref(&self) -> Option<&TypeRef> {
3176 super::child_opt(self)
3181 #[derive(Debug, PartialEq, Eq, Hash)]
3182 #[repr(transparent)]
3183 pub struct ReturnExpr {
3184 pub(crate) syntax: SyntaxNode,
3186 unsafe impl TransparentNewType for ReturnExpr {
3187 type Repr = rowan::SyntaxNode<RaTypes>;
3190 impl AstNode for ReturnExpr {
3191 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3192 match syntax.kind() {
3193 RETURN_EXPR => Some(ReturnExpr::from_repr(syntax.into_repr())),
3197 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3200 impl ToOwned for ReturnExpr {
3201 type Owned = TreeArc<ReturnExpr>;
3202 fn to_owned(&self) -> TreeArc<ReturnExpr> { TreeArc::cast(self.syntax.to_owned()) }
3207 pub fn expr(&self) -> Option<&Expr> {
3208 super::child_opt(self)
3213 #[derive(Debug, PartialEq, Eq, Hash)]
3214 #[repr(transparent)]
3215 pub struct SelfParam {
3216 pub(crate) syntax: SyntaxNode,
3218 unsafe impl TransparentNewType for SelfParam {
3219 type Repr = rowan::SyntaxNode<RaTypes>;
3222 impl AstNode for SelfParam {
3223 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3224 match syntax.kind() {
3225 SELF_PARAM => Some(SelfParam::from_repr(syntax.into_repr())),
3229 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3232 impl ToOwned for SelfParam {
3233 type Owned = TreeArc<SelfParam>;
3234 fn to_owned(&self) -> TreeArc<SelfParam> { TreeArc::cast(self.syntax.to_owned()) }
3238 impl ast::TypeAscriptionOwner for SelfParam {}
3242 #[derive(Debug, PartialEq, Eq, Hash)]
3243 #[repr(transparent)]
3244 pub struct SlicePat {
3245 pub(crate) syntax: SyntaxNode,
3247 unsafe impl TransparentNewType for SlicePat {
3248 type Repr = rowan::SyntaxNode<RaTypes>;
3251 impl AstNode for SlicePat {
3252 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3253 match syntax.kind() {
3254 SLICE_PAT => Some(SlicePat::from_repr(syntax.into_repr())),
3258 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3261 impl ToOwned for SlicePat {
3262 type Owned = TreeArc<SlicePat>;
3263 fn to_owned(&self) -> TreeArc<SlicePat> { TreeArc::cast(self.syntax.to_owned()) }
3270 #[derive(Debug, PartialEq, Eq, Hash)]
3271 #[repr(transparent)]
3272 pub struct SliceType {
3273 pub(crate) syntax: SyntaxNode,
3275 unsafe impl TransparentNewType for SliceType {
3276 type Repr = rowan::SyntaxNode<RaTypes>;
3279 impl AstNode for SliceType {
3280 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3281 match syntax.kind() {
3282 SLICE_TYPE => Some(SliceType::from_repr(syntax.into_repr())),
3286 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3289 impl ToOwned for SliceType {
3290 type Owned = TreeArc<SliceType>;
3291 fn to_owned(&self) -> TreeArc<SliceType> { TreeArc::cast(self.syntax.to_owned()) }
3296 pub fn type_ref(&self) -> Option<&TypeRef> {
3297 super::child_opt(self)
3302 #[derive(Debug, PartialEq, Eq, Hash)]
3303 #[repr(transparent)]
3304 pub struct SourceFile {
3305 pub(crate) syntax: SyntaxNode,
3307 unsafe impl TransparentNewType for SourceFile {
3308 type Repr = rowan::SyntaxNode<RaTypes>;
3311 impl AstNode for SourceFile {
3312 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3313 match syntax.kind() {
3314 SOURCE_FILE => Some(SourceFile::from_repr(syntax.into_repr())),
3318 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3321 impl ToOwned for SourceFile {
3322 type Owned = TreeArc<SourceFile>;
3323 fn to_owned(&self) -> TreeArc<SourceFile> { TreeArc::cast(self.syntax.to_owned()) }
3327 impl ast::ModuleItemOwner for SourceFile {}
3328 impl ast::FnDefOwner for SourceFile {}
3330 pub fn modules(&self) -> impl Iterator<Item = &Module> {
3331 super::children(self)
3336 #[derive(Debug, PartialEq, Eq, Hash)]
3337 #[repr(transparent)]
3338 pub struct StaticDef {
3339 pub(crate) syntax: SyntaxNode,
3341 unsafe impl TransparentNewType for StaticDef {
3342 type Repr = rowan::SyntaxNode<RaTypes>;
3345 impl AstNode for StaticDef {
3346 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3347 match syntax.kind() {
3348 STATIC_DEF => Some(StaticDef::from_repr(syntax.into_repr())),
3352 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3355 impl ToOwned for StaticDef {
3356 type Owned = TreeArc<StaticDef>;
3357 fn to_owned(&self) -> TreeArc<StaticDef> { TreeArc::cast(self.syntax.to_owned()) }
3361 impl ast::VisibilityOwner for StaticDef {}
3362 impl ast::NameOwner for StaticDef {}
3363 impl ast::TypeParamsOwner for StaticDef {}
3364 impl ast::AttrsOwner for StaticDef {}
3365 impl ast::DocCommentsOwner for StaticDef {}
3366 impl ast::TypeAscriptionOwner for StaticDef {}
3370 #[derive(Debug, PartialEq, Eq, Hash)]
3371 #[repr(transparent)]
3373 pub(crate) syntax: SyntaxNode,
3375 unsafe impl TransparentNewType for Stmt {
3376 type Repr = rowan::SyntaxNode<RaTypes>;
3379 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3380 pub enum StmtKind<'a> {
3381 ExprStmt(&'a ExprStmt),
3382 LetStmt(&'a LetStmt),
3384 impl<'a> From<&'a ExprStmt> for &'a Stmt {
3385 fn from(n: &'a ExprStmt) -> &'a Stmt {
3386 Stmt::cast(&n.syntax).unwrap()
3389 impl<'a> From<&'a LetStmt> for &'a Stmt {
3390 fn from(n: &'a LetStmt) -> &'a Stmt {
3391 Stmt::cast(&n.syntax).unwrap()
3396 impl AstNode for Stmt {
3397 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3398 match syntax.kind() {
3400 | LET_STMT => Some(Stmt::from_repr(syntax.into_repr())),
3404 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3407 impl ToOwned for Stmt {
3408 type Owned = TreeArc<Stmt>;
3409 fn to_owned(&self) -> TreeArc<Stmt> { TreeArc::cast(self.syntax.to_owned()) }
3413 pub fn kind(&self) -> StmtKind {
3414 match self.syntax.kind() {
3415 EXPR_STMT => StmtKind::ExprStmt(ExprStmt::cast(&self.syntax).unwrap()),
3416 LET_STMT => StmtKind::LetStmt(LetStmt::cast(&self.syntax).unwrap()),
3417 _ => unreachable!(),
3425 #[derive(Debug, PartialEq, Eq, Hash)]
3426 #[repr(transparent)]
3427 pub struct StructDef {
3428 pub(crate) syntax: SyntaxNode,
3430 unsafe impl TransparentNewType for StructDef {
3431 type Repr = rowan::SyntaxNode<RaTypes>;
3434 impl AstNode for StructDef {
3435 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3436 match syntax.kind() {
3437 STRUCT_DEF => Some(StructDef::from_repr(syntax.into_repr())),
3441 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3444 impl ToOwned for StructDef {
3445 type Owned = TreeArc<StructDef>;
3446 fn to_owned(&self) -> TreeArc<StructDef> { TreeArc::cast(self.syntax.to_owned()) }
3450 impl ast::VisibilityOwner for StructDef {}
3451 impl ast::NameOwner for StructDef {}
3452 impl ast::TypeParamsOwner for StructDef {}
3453 impl ast::AttrsOwner for StructDef {}
3454 impl ast::DocCommentsOwner for StructDef {}
3458 #[derive(Debug, PartialEq, Eq, Hash)]
3459 #[repr(transparent)]
3460 pub struct StructLit {
3461 pub(crate) syntax: SyntaxNode,
3463 unsafe impl TransparentNewType for StructLit {
3464 type Repr = rowan::SyntaxNode<RaTypes>;
3467 impl AstNode for StructLit {
3468 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3469 match syntax.kind() {
3470 STRUCT_LIT => Some(StructLit::from_repr(syntax.into_repr())),
3474 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3477 impl ToOwned for StructLit {
3478 type Owned = TreeArc<StructLit>;
3479 fn to_owned(&self) -> TreeArc<StructLit> { TreeArc::cast(self.syntax.to_owned()) }
3484 pub fn path(&self) -> Option<&Path> {
3485 super::child_opt(self)
3488 pub fn named_field_list(&self) -> Option<&NamedFieldList> {
3489 super::child_opt(self)
3492 pub fn spread(&self) -> Option<&Expr> {
3493 super::child_opt(self)
3498 #[derive(Debug, PartialEq, Eq, Hash)]
3499 #[repr(transparent)]
3500 pub struct StructPat {
3501 pub(crate) syntax: SyntaxNode,
3503 unsafe impl TransparentNewType for StructPat {
3504 type Repr = rowan::SyntaxNode<RaTypes>;
3507 impl AstNode for StructPat {
3508 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3509 match syntax.kind() {
3510 STRUCT_PAT => Some(StructPat::from_repr(syntax.into_repr())),
3514 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3517 impl ToOwned for StructPat {
3518 type Owned = TreeArc<StructPat>;
3519 fn to_owned(&self) -> TreeArc<StructPat> { TreeArc::cast(self.syntax.to_owned()) }
3524 pub fn field_pat_list(&self) -> Option<&FieldPatList> {
3525 super::child_opt(self)
3528 pub fn path(&self) -> Option<&Path> {
3529 super::child_opt(self)
3534 #[derive(Debug, PartialEq, Eq, Hash)]
3535 #[repr(transparent)]
3536 pub struct TokenTree {
3537 pub(crate) syntax: SyntaxNode,
3539 unsafe impl TransparentNewType for TokenTree {
3540 type Repr = rowan::SyntaxNode<RaTypes>;
3543 impl AstNode for TokenTree {
3544 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3545 match syntax.kind() {
3546 TOKEN_TREE => Some(TokenTree::from_repr(syntax.into_repr())),
3550 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3553 impl ToOwned for TokenTree {
3554 type Owned = TreeArc<TokenTree>;
3555 fn to_owned(&self) -> TreeArc<TokenTree> { TreeArc::cast(self.syntax.to_owned()) }
3562 #[derive(Debug, PartialEq, Eq, Hash)]
3563 #[repr(transparent)]
3564 pub struct TraitDef {
3565 pub(crate) syntax: SyntaxNode,
3567 unsafe impl TransparentNewType for TraitDef {
3568 type Repr = rowan::SyntaxNode<RaTypes>;
3571 impl AstNode for TraitDef {
3572 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3573 match syntax.kind() {
3574 TRAIT_DEF => Some(TraitDef::from_repr(syntax.into_repr())),
3578 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3581 impl ToOwned for TraitDef {
3582 type Owned = TreeArc<TraitDef>;
3583 fn to_owned(&self) -> TreeArc<TraitDef> { TreeArc::cast(self.syntax.to_owned()) }
3587 impl ast::VisibilityOwner for TraitDef {}
3588 impl ast::NameOwner for TraitDef {}
3589 impl ast::AttrsOwner for TraitDef {}
3590 impl ast::DocCommentsOwner for TraitDef {}
3591 impl ast::TypeParamsOwner for TraitDef {}
3592 impl ast::TypeBoundsOwner for TraitDef {}
3594 pub fn item_list(&self) -> Option<&ItemList> {
3595 super::child_opt(self)
3600 #[derive(Debug, PartialEq, Eq, Hash)]
3601 #[repr(transparent)]
3602 pub struct TryExpr {
3603 pub(crate) syntax: SyntaxNode,
3605 unsafe impl TransparentNewType for TryExpr {
3606 type Repr = rowan::SyntaxNode<RaTypes>;
3609 impl AstNode for TryExpr {
3610 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3611 match syntax.kind() {
3612 TRY_EXPR => Some(TryExpr::from_repr(syntax.into_repr())),
3616 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3619 impl ToOwned for TryExpr {
3620 type Owned = TreeArc<TryExpr>;
3621 fn to_owned(&self) -> TreeArc<TryExpr> { TreeArc::cast(self.syntax.to_owned()) }
3626 pub fn expr(&self) -> Option<&Expr> {
3627 super::child_opt(self)
3632 #[derive(Debug, PartialEq, Eq, Hash)]
3633 #[repr(transparent)]
3634 pub struct TupleExpr {
3635 pub(crate) syntax: SyntaxNode,
3637 unsafe impl TransparentNewType for TupleExpr {
3638 type Repr = rowan::SyntaxNode<RaTypes>;
3641 impl AstNode for TupleExpr {
3642 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3643 match syntax.kind() {
3644 TUPLE_EXPR => Some(TupleExpr::from_repr(syntax.into_repr())),
3648 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3651 impl ToOwned for TupleExpr {
3652 type Owned = TreeArc<TupleExpr>;
3653 fn to_owned(&self) -> TreeArc<TupleExpr> { TreeArc::cast(self.syntax.to_owned()) }
3658 pub fn exprs(&self) -> impl Iterator<Item = &Expr> {
3659 super::children(self)
3664 #[derive(Debug, PartialEq, Eq, Hash)]
3665 #[repr(transparent)]
3666 pub struct TuplePat {
3667 pub(crate) syntax: SyntaxNode,
3669 unsafe impl TransparentNewType for TuplePat {
3670 type Repr = rowan::SyntaxNode<RaTypes>;
3673 impl AstNode for TuplePat {
3674 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3675 match syntax.kind() {
3676 TUPLE_PAT => Some(TuplePat::from_repr(syntax.into_repr())),
3680 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3683 impl ToOwned for TuplePat {
3684 type Owned = TreeArc<TuplePat>;
3685 fn to_owned(&self) -> TreeArc<TuplePat> { TreeArc::cast(self.syntax.to_owned()) }
3690 pub fn args(&self) -> impl Iterator<Item = &Pat> {
3691 super::children(self)
3696 #[derive(Debug, PartialEq, Eq, Hash)]
3697 #[repr(transparent)]
3698 pub struct TupleStructPat {
3699 pub(crate) syntax: SyntaxNode,
3701 unsafe impl TransparentNewType for TupleStructPat {
3702 type Repr = rowan::SyntaxNode<RaTypes>;
3705 impl AstNode for TupleStructPat {
3706 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3707 match syntax.kind() {
3708 TUPLE_STRUCT_PAT => Some(TupleStructPat::from_repr(syntax.into_repr())),
3712 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3715 impl ToOwned for TupleStructPat {
3716 type Owned = TreeArc<TupleStructPat>;
3717 fn to_owned(&self) -> TreeArc<TupleStructPat> { TreeArc::cast(self.syntax.to_owned()) }
3721 impl TupleStructPat {
3722 pub fn args(&self) -> impl Iterator<Item = &Pat> {
3723 super::children(self)
3726 pub fn path(&self) -> Option<&Path> {
3727 super::child_opt(self)
3732 #[derive(Debug, PartialEq, Eq, Hash)]
3733 #[repr(transparent)]
3734 pub struct TupleType {
3735 pub(crate) syntax: SyntaxNode,
3737 unsafe impl TransparentNewType for TupleType {
3738 type Repr = rowan::SyntaxNode<RaTypes>;
3741 impl AstNode for TupleType {
3742 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3743 match syntax.kind() {
3744 TUPLE_TYPE => Some(TupleType::from_repr(syntax.into_repr())),
3748 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3751 impl ToOwned for TupleType {
3752 type Owned = TreeArc<TupleType>;
3753 fn to_owned(&self) -> TreeArc<TupleType> { TreeArc::cast(self.syntax.to_owned()) }
3758 pub fn fields(&self) -> impl Iterator<Item = &TypeRef> {
3759 super::children(self)
3764 #[derive(Debug, PartialEq, Eq, Hash)]
3765 #[repr(transparent)]
3766 pub struct TypeAliasDef {
3767 pub(crate) syntax: SyntaxNode,
3769 unsafe impl TransparentNewType for TypeAliasDef {
3770 type Repr = rowan::SyntaxNode<RaTypes>;
3773 impl AstNode for TypeAliasDef {
3774 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3775 match syntax.kind() {
3776 TYPE_ALIAS_DEF => Some(TypeAliasDef::from_repr(syntax.into_repr())),
3780 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3783 impl ToOwned for TypeAliasDef {
3784 type Owned = TreeArc<TypeAliasDef>;
3785 fn to_owned(&self) -> TreeArc<TypeAliasDef> { TreeArc::cast(self.syntax.to_owned()) }
3789 impl ast::VisibilityOwner for TypeAliasDef {}
3790 impl ast::NameOwner for TypeAliasDef {}
3791 impl ast::TypeParamsOwner for TypeAliasDef {}
3792 impl ast::AttrsOwner for TypeAliasDef {}
3793 impl ast::DocCommentsOwner for TypeAliasDef {}
3794 impl ast::TypeBoundsOwner for TypeAliasDef {}
3796 pub fn type_ref(&self) -> Option<&TypeRef> {
3797 super::child_opt(self)
3802 #[derive(Debug, PartialEq, Eq, Hash)]
3803 #[repr(transparent)]
3804 pub struct TypeArg {
3805 pub(crate) syntax: SyntaxNode,
3807 unsafe impl TransparentNewType for TypeArg {
3808 type Repr = rowan::SyntaxNode<RaTypes>;
3811 impl AstNode for TypeArg {
3812 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3813 match syntax.kind() {
3814 TYPE_ARG => Some(TypeArg::from_repr(syntax.into_repr())),
3818 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3821 impl ToOwned for TypeArg {
3822 type Owned = TreeArc<TypeArg>;
3823 fn to_owned(&self) -> TreeArc<TypeArg> { TreeArc::cast(self.syntax.to_owned()) }
3828 pub fn type_ref(&self) -> Option<&TypeRef> {
3829 super::child_opt(self)
3834 #[derive(Debug, PartialEq, Eq, Hash)]
3835 #[repr(transparent)]
3836 pub struct TypeArgList {
3837 pub(crate) syntax: SyntaxNode,
3839 unsafe impl TransparentNewType for TypeArgList {
3840 type Repr = rowan::SyntaxNode<RaTypes>;
3843 impl AstNode for TypeArgList {
3844 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3845 match syntax.kind() {
3846 TYPE_ARG_LIST => Some(TypeArgList::from_repr(syntax.into_repr())),
3850 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3853 impl ToOwned for TypeArgList {
3854 type Owned = TreeArc<TypeArgList>;
3855 fn to_owned(&self) -> TreeArc<TypeArgList> { TreeArc::cast(self.syntax.to_owned()) }
3860 pub fn type_args(&self) -> impl Iterator<Item = &TypeArg> {
3861 super::children(self)
3864 pub fn lifetime_args(&self) -> impl Iterator<Item = &LifetimeArg> {
3865 super::children(self)
3868 pub fn assoc_type_args(&self) -> impl Iterator<Item = &AssocTypeArg> {
3869 super::children(self)
3874 #[derive(Debug, PartialEq, Eq, Hash)]
3875 #[repr(transparent)]
3876 pub struct TypeBound {
3877 pub(crate) syntax: SyntaxNode,
3879 unsafe impl TransparentNewType for TypeBound {
3880 type Repr = rowan::SyntaxNode<RaTypes>;
3883 impl AstNode for TypeBound {
3884 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3885 match syntax.kind() {
3886 TYPE_BOUND => Some(TypeBound::from_repr(syntax.into_repr())),
3890 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3893 impl ToOwned for TypeBound {
3894 type Owned = TreeArc<TypeBound>;
3895 fn to_owned(&self) -> TreeArc<TypeBound> { TreeArc::cast(self.syntax.to_owned()) }
3900 pub fn type_ref(&self) -> Option<&TypeRef> {
3901 super::child_opt(self)
3906 #[derive(Debug, PartialEq, Eq, Hash)]
3907 #[repr(transparent)]
3908 pub struct TypeBoundList {
3909 pub(crate) syntax: SyntaxNode,
3911 unsafe impl TransparentNewType for TypeBoundList {
3912 type Repr = rowan::SyntaxNode<RaTypes>;
3915 impl AstNode for TypeBoundList {
3916 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3917 match syntax.kind() {
3918 TYPE_BOUND_LIST => Some(TypeBoundList::from_repr(syntax.into_repr())),
3922 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3925 impl ToOwned for TypeBoundList {
3926 type Owned = TreeArc<TypeBoundList>;
3927 fn to_owned(&self) -> TreeArc<TypeBoundList> { TreeArc::cast(self.syntax.to_owned()) }
3931 impl TypeBoundList {
3932 pub fn bounds(&self) -> impl Iterator<Item = &TypeBound> {
3933 super::children(self)
3938 #[derive(Debug, PartialEq, Eq, Hash)]
3939 #[repr(transparent)]
3940 pub struct TypeParam {
3941 pub(crate) syntax: SyntaxNode,
3943 unsafe impl TransparentNewType for TypeParam {
3944 type Repr = rowan::SyntaxNode<RaTypes>;
3947 impl AstNode for TypeParam {
3948 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3949 match syntax.kind() {
3950 TYPE_PARAM => Some(TypeParam::from_repr(syntax.into_repr())),
3954 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3957 impl ToOwned for TypeParam {
3958 type Owned = TreeArc<TypeParam>;
3959 fn to_owned(&self) -> TreeArc<TypeParam> { TreeArc::cast(self.syntax.to_owned()) }
3963 impl ast::NameOwner for TypeParam {}
3964 impl ast::AttrsOwner for TypeParam {}
3965 impl ast::TypeBoundsOwner for TypeParam {}
3969 #[derive(Debug, PartialEq, Eq, Hash)]
3970 #[repr(transparent)]
3971 pub struct TypeParamList {
3972 pub(crate) syntax: SyntaxNode,
3974 unsafe impl TransparentNewType for TypeParamList {
3975 type Repr = rowan::SyntaxNode<RaTypes>;
3978 impl AstNode for TypeParamList {
3979 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3980 match syntax.kind() {
3981 TYPE_PARAM_LIST => Some(TypeParamList::from_repr(syntax.into_repr())),
3985 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3988 impl ToOwned for TypeParamList {
3989 type Owned = TreeArc<TypeParamList>;
3990 fn to_owned(&self) -> TreeArc<TypeParamList> { TreeArc::cast(self.syntax.to_owned()) }
3994 impl TypeParamList {
3995 pub fn type_params(&self) -> impl Iterator<Item = &TypeParam> {
3996 super::children(self)
3999 pub fn lifetime_params(&self) -> impl Iterator<Item = &LifetimeParam> {
4000 super::children(self)
4005 #[derive(Debug, PartialEq, Eq, Hash)]
4006 #[repr(transparent)]
4007 pub struct TypeRef {
4008 pub(crate) syntax: SyntaxNode,
4010 unsafe impl TransparentNewType for TypeRef {
4011 type Repr = rowan::SyntaxNode<RaTypes>;
4014 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4015 pub enum TypeRefKind<'a> {
4016 ParenType(&'a ParenType),
4017 TupleType(&'a TupleType),
4018 NeverType(&'a NeverType),
4019 PathType(&'a PathType),
4020 PointerType(&'a PointerType),
4021 ArrayType(&'a ArrayType),
4022 SliceType(&'a SliceType),
4023 ReferenceType(&'a ReferenceType),
4024 PlaceholderType(&'a PlaceholderType),
4025 FnPointerType(&'a FnPointerType),
4026 ForType(&'a ForType),
4027 ImplTraitType(&'a ImplTraitType),
4028 DynTraitType(&'a DynTraitType),
4030 impl<'a> From<&'a ParenType> for &'a TypeRef {
4031 fn from(n: &'a ParenType) -> &'a TypeRef {
4032 TypeRef::cast(&n.syntax).unwrap()
4035 impl<'a> From<&'a TupleType> for &'a TypeRef {
4036 fn from(n: &'a TupleType) -> &'a TypeRef {
4037 TypeRef::cast(&n.syntax).unwrap()
4040 impl<'a> From<&'a NeverType> for &'a TypeRef {
4041 fn from(n: &'a NeverType) -> &'a TypeRef {
4042 TypeRef::cast(&n.syntax).unwrap()
4045 impl<'a> From<&'a PathType> for &'a TypeRef {
4046 fn from(n: &'a PathType) -> &'a TypeRef {
4047 TypeRef::cast(&n.syntax).unwrap()
4050 impl<'a> From<&'a PointerType> for &'a TypeRef {
4051 fn from(n: &'a PointerType) -> &'a TypeRef {
4052 TypeRef::cast(&n.syntax).unwrap()
4055 impl<'a> From<&'a ArrayType> for &'a TypeRef {
4056 fn from(n: &'a ArrayType) -> &'a TypeRef {
4057 TypeRef::cast(&n.syntax).unwrap()
4060 impl<'a> From<&'a SliceType> for &'a TypeRef {
4061 fn from(n: &'a SliceType) -> &'a TypeRef {
4062 TypeRef::cast(&n.syntax).unwrap()
4065 impl<'a> From<&'a ReferenceType> for &'a TypeRef {
4066 fn from(n: &'a ReferenceType) -> &'a TypeRef {
4067 TypeRef::cast(&n.syntax).unwrap()
4070 impl<'a> From<&'a PlaceholderType> for &'a TypeRef {
4071 fn from(n: &'a PlaceholderType) -> &'a TypeRef {
4072 TypeRef::cast(&n.syntax).unwrap()
4075 impl<'a> From<&'a FnPointerType> for &'a TypeRef {
4076 fn from(n: &'a FnPointerType) -> &'a TypeRef {
4077 TypeRef::cast(&n.syntax).unwrap()
4080 impl<'a> From<&'a ForType> for &'a TypeRef {
4081 fn from(n: &'a ForType) -> &'a TypeRef {
4082 TypeRef::cast(&n.syntax).unwrap()
4085 impl<'a> From<&'a ImplTraitType> for &'a TypeRef {
4086 fn from(n: &'a ImplTraitType) -> &'a TypeRef {
4087 TypeRef::cast(&n.syntax).unwrap()
4090 impl<'a> From<&'a DynTraitType> for &'a TypeRef {
4091 fn from(n: &'a DynTraitType) -> &'a TypeRef {
4092 TypeRef::cast(&n.syntax).unwrap()
4097 impl AstNode for TypeRef {
4098 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4099 match syntax.kind() {
4112 | DYN_TRAIT_TYPE => Some(TypeRef::from_repr(syntax.into_repr())),
4116 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4119 impl ToOwned for TypeRef {
4120 type Owned = TreeArc<TypeRef>;
4121 fn to_owned(&self) -> TreeArc<TypeRef> { TreeArc::cast(self.syntax.to_owned()) }
4125 pub fn kind(&self) -> TypeRefKind {
4126 match self.syntax.kind() {
4127 PAREN_TYPE => TypeRefKind::ParenType(ParenType::cast(&self.syntax).unwrap()),
4128 TUPLE_TYPE => TypeRefKind::TupleType(TupleType::cast(&self.syntax).unwrap()),
4129 NEVER_TYPE => TypeRefKind::NeverType(NeverType::cast(&self.syntax).unwrap()),
4130 PATH_TYPE => TypeRefKind::PathType(PathType::cast(&self.syntax).unwrap()),
4131 POINTER_TYPE => TypeRefKind::PointerType(PointerType::cast(&self.syntax).unwrap()),
4132 ARRAY_TYPE => TypeRefKind::ArrayType(ArrayType::cast(&self.syntax).unwrap()),
4133 SLICE_TYPE => TypeRefKind::SliceType(SliceType::cast(&self.syntax).unwrap()),
4134 REFERENCE_TYPE => TypeRefKind::ReferenceType(ReferenceType::cast(&self.syntax).unwrap()),
4135 PLACEHOLDER_TYPE => TypeRefKind::PlaceholderType(PlaceholderType::cast(&self.syntax).unwrap()),
4136 FN_POINTER_TYPE => TypeRefKind::FnPointerType(FnPointerType::cast(&self.syntax).unwrap()),
4137 FOR_TYPE => TypeRefKind::ForType(ForType::cast(&self.syntax).unwrap()),
4138 IMPL_TRAIT_TYPE => TypeRefKind::ImplTraitType(ImplTraitType::cast(&self.syntax).unwrap()),
4139 DYN_TRAIT_TYPE => TypeRefKind::DynTraitType(DynTraitType::cast(&self.syntax).unwrap()),
4140 _ => unreachable!(),
4148 #[derive(Debug, PartialEq, Eq, Hash)]
4149 #[repr(transparent)]
4150 pub struct UseItem {
4151 pub(crate) syntax: SyntaxNode,
4153 unsafe impl TransparentNewType for UseItem {
4154 type Repr = rowan::SyntaxNode<RaTypes>;
4157 impl AstNode for UseItem {
4158 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4159 match syntax.kind() {
4160 USE_ITEM => Some(UseItem::from_repr(syntax.into_repr())),
4164 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4167 impl ToOwned for UseItem {
4168 type Owned = TreeArc<UseItem>;
4169 fn to_owned(&self) -> TreeArc<UseItem> { TreeArc::cast(self.syntax.to_owned()) }
4173 impl ast::AttrsOwner for UseItem {}
4175 pub fn use_tree(&self) -> Option<&UseTree> {
4176 super::child_opt(self)
4181 #[derive(Debug, PartialEq, Eq, Hash)]
4182 #[repr(transparent)]
4183 pub struct UseTree {
4184 pub(crate) syntax: SyntaxNode,
4186 unsafe impl TransparentNewType for UseTree {
4187 type Repr = rowan::SyntaxNode<RaTypes>;
4190 impl AstNode for UseTree {
4191 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4192 match syntax.kind() {
4193 USE_TREE => Some(UseTree::from_repr(syntax.into_repr())),
4197 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4200 impl ToOwned for UseTree {
4201 type Owned = TreeArc<UseTree>;
4202 fn to_owned(&self) -> TreeArc<UseTree> { TreeArc::cast(self.syntax.to_owned()) }
4207 pub fn path(&self) -> Option<&Path> {
4208 super::child_opt(self)
4211 pub fn use_tree_list(&self) -> Option<&UseTreeList> {
4212 super::child_opt(self)
4215 pub fn alias(&self) -> Option<&Alias> {
4216 super::child_opt(self)
4221 #[derive(Debug, PartialEq, Eq, Hash)]
4222 #[repr(transparent)]
4223 pub struct UseTreeList {
4224 pub(crate) syntax: SyntaxNode,
4226 unsafe impl TransparentNewType for UseTreeList {
4227 type Repr = rowan::SyntaxNode<RaTypes>;
4230 impl AstNode for UseTreeList {
4231 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4232 match syntax.kind() {
4233 USE_TREE_LIST => Some(UseTreeList::from_repr(syntax.into_repr())),
4237 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4240 impl ToOwned for UseTreeList {
4241 type Owned = TreeArc<UseTreeList>;
4242 fn to_owned(&self) -> TreeArc<UseTreeList> { TreeArc::cast(self.syntax.to_owned()) }
4247 pub fn use_trees(&self) -> impl Iterator<Item = &UseTree> {
4248 super::children(self)
4253 #[derive(Debug, PartialEq, Eq, Hash)]
4254 #[repr(transparent)]
4255 pub struct Visibility {
4256 pub(crate) syntax: SyntaxNode,
4258 unsafe impl TransparentNewType for Visibility {
4259 type Repr = rowan::SyntaxNode<RaTypes>;
4262 impl AstNode for Visibility {
4263 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4264 match syntax.kind() {
4265 VISIBILITY => Some(Visibility::from_repr(syntax.into_repr())),
4269 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4272 impl ToOwned for Visibility {
4273 type Owned = TreeArc<Visibility>;
4274 fn to_owned(&self) -> TreeArc<Visibility> { TreeArc::cast(self.syntax.to_owned()) }
4281 #[derive(Debug, PartialEq, Eq, Hash)]
4282 #[repr(transparent)]
4283 pub struct WhereClause {
4284 pub(crate) syntax: SyntaxNode,
4286 unsafe impl TransparentNewType for WhereClause {
4287 type Repr = rowan::SyntaxNode<RaTypes>;
4290 impl AstNode for WhereClause {
4291 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4292 match syntax.kind() {
4293 WHERE_CLAUSE => Some(WhereClause::from_repr(syntax.into_repr())),
4297 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4300 impl ToOwned for WhereClause {
4301 type Owned = TreeArc<WhereClause>;
4302 fn to_owned(&self) -> TreeArc<WhereClause> { TreeArc::cast(self.syntax.to_owned()) }
4307 pub fn predicates(&self) -> impl Iterator<Item = &WherePred> {
4308 super::children(self)
4313 #[derive(Debug, PartialEq, Eq, Hash)]
4314 #[repr(transparent)]
4315 pub struct WherePred {
4316 pub(crate) syntax: SyntaxNode,
4318 unsafe impl TransparentNewType for WherePred {
4319 type Repr = rowan::SyntaxNode<RaTypes>;
4322 impl AstNode for WherePred {
4323 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4324 match syntax.kind() {
4325 WHERE_PRED => Some(WherePred::from_repr(syntax.into_repr())),
4329 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4332 impl ToOwned for WherePred {
4333 type Owned = TreeArc<WherePred>;
4334 fn to_owned(&self) -> TreeArc<WherePred> { TreeArc::cast(self.syntax.to_owned()) }
4338 impl ast::TypeBoundsOwner for WherePred {}
4340 pub fn type_ref(&self) -> Option<&TypeRef> {
4341 super::child_opt(self)
4346 #[derive(Debug, PartialEq, Eq, Hash)]
4347 #[repr(transparent)]
4348 pub struct WhileExpr {
4349 pub(crate) syntax: SyntaxNode,
4351 unsafe impl TransparentNewType for WhileExpr {
4352 type Repr = rowan::SyntaxNode<RaTypes>;
4355 impl AstNode for WhileExpr {
4356 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4357 match syntax.kind() {
4358 WHILE_EXPR => Some(WhileExpr::from_repr(syntax.into_repr())),
4362 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4365 impl ToOwned for WhileExpr {
4366 type Owned = TreeArc<WhileExpr>;
4367 fn to_owned(&self) -> TreeArc<WhileExpr> { TreeArc::cast(self.syntax.to_owned()) }
4371 impl ast::LoopBodyOwner for WhileExpr {}
4373 pub fn condition(&self) -> Option<&Condition> {
4374 super::child_opt(self)
4379 #[derive(Debug, PartialEq, Eq, Hash)]
4380 #[repr(transparent)]
4381 pub struct Whitespace {
4382 pub(crate) syntax: SyntaxNode,
4384 unsafe impl TransparentNewType for Whitespace {
4385 type Repr = rowan::SyntaxNode<RaTypes>;
4388 impl AstNode for Whitespace {
4389 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4390 match syntax.kind() {
4391 WHITESPACE => Some(Whitespace::from_repr(syntax.into_repr())),
4395 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4398 impl ToOwned for Whitespace {
4399 type Owned = TreeArc<Whitespace>;
4400 fn to_owned(&self) -> TreeArc<Whitespace> { TreeArc::cast(self.syntax.to_owned()) }
4404 impl ast::AstToken for Whitespace {}