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 {}
517 pub fn body(&self) -> Option<&Expr> {
518 super::child_opt(self)
523 #[derive(Debug, PartialEq, Eq, Hash)]
525 pub struct ContinueExpr {
526 pub(crate) syntax: SyntaxNode,
528 unsafe impl TransparentNewType for ContinueExpr {
529 type Repr = rowan::SyntaxNode<RaTypes>;
532 impl AstNode for ContinueExpr {
533 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
534 match syntax.kind() {
535 CONTINUE_EXPR => Some(ContinueExpr::from_repr(syntax.into_repr())),
539 fn syntax(&self) -> &SyntaxNode { &self.syntax }
542 impl ToOwned for ContinueExpr {
543 type Owned = TreeArc<ContinueExpr>;
544 fn to_owned(&self) -> TreeArc<ContinueExpr> { TreeArc::cast(self.syntax.to_owned()) }
551 #[derive(Debug, PartialEq, Eq, Hash)]
553 pub struct DynTraitType {
554 pub(crate) syntax: SyntaxNode,
556 unsafe impl TransparentNewType for DynTraitType {
557 type Repr = rowan::SyntaxNode<RaTypes>;
560 impl AstNode for DynTraitType {
561 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
562 match syntax.kind() {
563 DYN_TRAIT_TYPE => Some(DynTraitType::from_repr(syntax.into_repr())),
567 fn syntax(&self) -> &SyntaxNode { &self.syntax }
570 impl ToOwned for DynTraitType {
571 type Owned = TreeArc<DynTraitType>;
572 fn to_owned(&self) -> TreeArc<DynTraitType> { TreeArc::cast(self.syntax.to_owned()) }
576 impl ast::TypeBoundsOwner for DynTraitType {}
580 #[derive(Debug, PartialEq, Eq, Hash)]
583 pub(crate) syntax: SyntaxNode,
585 unsafe impl TransparentNewType for EnumDef {
586 type Repr = rowan::SyntaxNode<RaTypes>;
589 impl AstNode for EnumDef {
590 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
591 match syntax.kind() {
592 ENUM_DEF => Some(EnumDef::from_repr(syntax.into_repr())),
596 fn syntax(&self) -> &SyntaxNode { &self.syntax }
599 impl ToOwned for EnumDef {
600 type Owned = TreeArc<EnumDef>;
601 fn to_owned(&self) -> TreeArc<EnumDef> { TreeArc::cast(self.syntax.to_owned()) }
605 impl ast::VisibilityOwner for EnumDef {}
606 impl ast::NameOwner for EnumDef {}
607 impl ast::TypeParamsOwner for EnumDef {}
608 impl ast::AttrsOwner for EnumDef {}
609 impl ast::DocCommentsOwner for EnumDef {}
611 pub fn variant_list(&self) -> Option<&EnumVariantList> {
612 super::child_opt(self)
617 #[derive(Debug, PartialEq, Eq, Hash)]
619 pub struct EnumVariant {
620 pub(crate) syntax: SyntaxNode,
622 unsafe impl TransparentNewType for EnumVariant {
623 type Repr = rowan::SyntaxNode<RaTypes>;
626 impl AstNode for EnumVariant {
627 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
628 match syntax.kind() {
629 ENUM_VARIANT => Some(EnumVariant::from_repr(syntax.into_repr())),
633 fn syntax(&self) -> &SyntaxNode { &self.syntax }
636 impl ToOwned for EnumVariant {
637 type Owned = TreeArc<EnumVariant>;
638 fn to_owned(&self) -> TreeArc<EnumVariant> { TreeArc::cast(self.syntax.to_owned()) }
642 impl ast::NameOwner for EnumVariant {}
643 impl ast::DocCommentsOwner for EnumVariant {}
644 impl ast::AttrsOwner for EnumVariant {}
646 pub fn expr(&self) -> Option<&Expr> {
647 super::child_opt(self)
652 #[derive(Debug, PartialEq, Eq, Hash)]
654 pub struct EnumVariantList {
655 pub(crate) syntax: SyntaxNode,
657 unsafe impl TransparentNewType for EnumVariantList {
658 type Repr = rowan::SyntaxNode<RaTypes>;
661 impl AstNode for EnumVariantList {
662 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
663 match syntax.kind() {
664 ENUM_VARIANT_LIST => Some(EnumVariantList::from_repr(syntax.into_repr())),
668 fn syntax(&self) -> &SyntaxNode { &self.syntax }
671 impl ToOwned for EnumVariantList {
672 type Owned = TreeArc<EnumVariantList>;
673 fn to_owned(&self) -> TreeArc<EnumVariantList> { TreeArc::cast(self.syntax.to_owned()) }
677 impl EnumVariantList {
678 pub fn variants(&self) -> impl Iterator<Item = &EnumVariant> {
679 super::children(self)
684 #[derive(Debug, PartialEq, Eq, Hash)]
687 pub(crate) syntax: SyntaxNode,
689 unsafe impl TransparentNewType for Expr {
690 type Repr = rowan::SyntaxNode<RaTypes>;
693 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
694 pub enum ExprKind<'a> {
695 TupleExpr(&'a TupleExpr),
696 ArrayExpr(&'a ArrayExpr),
697 ParenExpr(&'a ParenExpr),
698 PathExpr(&'a PathExpr),
699 LambdaExpr(&'a LambdaExpr),
701 LoopExpr(&'a LoopExpr),
702 ForExpr(&'a ForExpr),
703 WhileExpr(&'a WhileExpr),
704 ContinueExpr(&'a ContinueExpr),
705 BreakExpr(&'a BreakExpr),
707 BlockExpr(&'a BlockExpr),
708 ReturnExpr(&'a ReturnExpr),
709 MatchExpr(&'a MatchExpr),
710 StructLit(&'a StructLit),
711 CallExpr(&'a CallExpr),
712 IndexExpr(&'a IndexExpr),
713 MethodCallExpr(&'a MethodCallExpr),
714 FieldExpr(&'a FieldExpr),
715 TryExpr(&'a TryExpr),
716 CastExpr(&'a CastExpr),
717 RefExpr(&'a RefExpr),
718 PrefixExpr(&'a PrefixExpr),
719 RangeExpr(&'a RangeExpr),
720 BinExpr(&'a BinExpr),
721 Literal(&'a Literal),
722 MacroCall(&'a MacroCall),
724 impl<'a> From<&'a TupleExpr> for &'a Expr {
725 fn from(n: &'a TupleExpr) -> &'a Expr {
726 Expr::cast(&n.syntax).unwrap()
729 impl<'a> From<&'a ArrayExpr> for &'a Expr {
730 fn from(n: &'a ArrayExpr) -> &'a Expr {
731 Expr::cast(&n.syntax).unwrap()
734 impl<'a> From<&'a ParenExpr> for &'a Expr {
735 fn from(n: &'a ParenExpr) -> &'a Expr {
736 Expr::cast(&n.syntax).unwrap()
739 impl<'a> From<&'a PathExpr> for &'a Expr {
740 fn from(n: &'a PathExpr) -> &'a Expr {
741 Expr::cast(&n.syntax).unwrap()
744 impl<'a> From<&'a LambdaExpr> for &'a Expr {
745 fn from(n: &'a LambdaExpr) -> &'a Expr {
746 Expr::cast(&n.syntax).unwrap()
749 impl<'a> From<&'a IfExpr> for &'a Expr {
750 fn from(n: &'a IfExpr) -> &'a Expr {
751 Expr::cast(&n.syntax).unwrap()
754 impl<'a> From<&'a LoopExpr> for &'a Expr {
755 fn from(n: &'a LoopExpr) -> &'a Expr {
756 Expr::cast(&n.syntax).unwrap()
759 impl<'a> From<&'a ForExpr> for &'a Expr {
760 fn from(n: &'a ForExpr) -> &'a Expr {
761 Expr::cast(&n.syntax).unwrap()
764 impl<'a> From<&'a WhileExpr> for &'a Expr {
765 fn from(n: &'a WhileExpr) -> &'a Expr {
766 Expr::cast(&n.syntax).unwrap()
769 impl<'a> From<&'a ContinueExpr> for &'a Expr {
770 fn from(n: &'a ContinueExpr) -> &'a Expr {
771 Expr::cast(&n.syntax).unwrap()
774 impl<'a> From<&'a BreakExpr> for &'a Expr {
775 fn from(n: &'a BreakExpr) -> &'a Expr {
776 Expr::cast(&n.syntax).unwrap()
779 impl<'a> From<&'a Label> for &'a Expr {
780 fn from(n: &'a Label) -> &'a Expr {
781 Expr::cast(&n.syntax).unwrap()
784 impl<'a> From<&'a BlockExpr> for &'a Expr {
785 fn from(n: &'a BlockExpr) -> &'a Expr {
786 Expr::cast(&n.syntax).unwrap()
789 impl<'a> From<&'a ReturnExpr> for &'a Expr {
790 fn from(n: &'a ReturnExpr) -> &'a Expr {
791 Expr::cast(&n.syntax).unwrap()
794 impl<'a> From<&'a MatchExpr> for &'a Expr {
795 fn from(n: &'a MatchExpr) -> &'a Expr {
796 Expr::cast(&n.syntax).unwrap()
799 impl<'a> From<&'a StructLit> for &'a Expr {
800 fn from(n: &'a StructLit) -> &'a Expr {
801 Expr::cast(&n.syntax).unwrap()
804 impl<'a> From<&'a CallExpr> for &'a Expr {
805 fn from(n: &'a CallExpr) -> &'a Expr {
806 Expr::cast(&n.syntax).unwrap()
809 impl<'a> From<&'a IndexExpr> for &'a Expr {
810 fn from(n: &'a IndexExpr) -> &'a Expr {
811 Expr::cast(&n.syntax).unwrap()
814 impl<'a> From<&'a MethodCallExpr> for &'a Expr {
815 fn from(n: &'a MethodCallExpr) -> &'a Expr {
816 Expr::cast(&n.syntax).unwrap()
819 impl<'a> From<&'a FieldExpr> for &'a Expr {
820 fn from(n: &'a FieldExpr) -> &'a Expr {
821 Expr::cast(&n.syntax).unwrap()
824 impl<'a> From<&'a TryExpr> for &'a Expr {
825 fn from(n: &'a TryExpr) -> &'a Expr {
826 Expr::cast(&n.syntax).unwrap()
829 impl<'a> From<&'a CastExpr> for &'a Expr {
830 fn from(n: &'a CastExpr) -> &'a Expr {
831 Expr::cast(&n.syntax).unwrap()
834 impl<'a> From<&'a RefExpr> for &'a Expr {
835 fn from(n: &'a RefExpr) -> &'a Expr {
836 Expr::cast(&n.syntax).unwrap()
839 impl<'a> From<&'a PrefixExpr> for &'a Expr {
840 fn from(n: &'a PrefixExpr) -> &'a Expr {
841 Expr::cast(&n.syntax).unwrap()
844 impl<'a> From<&'a RangeExpr> for &'a Expr {
845 fn from(n: &'a RangeExpr) -> &'a Expr {
846 Expr::cast(&n.syntax).unwrap()
849 impl<'a> From<&'a BinExpr> for &'a Expr {
850 fn from(n: &'a BinExpr) -> &'a Expr {
851 Expr::cast(&n.syntax).unwrap()
854 impl<'a> From<&'a Literal> for &'a Expr {
855 fn from(n: &'a Literal) -> &'a Expr {
856 Expr::cast(&n.syntax).unwrap()
859 impl<'a> From<&'a MacroCall> for &'a Expr {
860 fn from(n: &'a MacroCall) -> &'a Expr {
861 Expr::cast(&n.syntax).unwrap()
866 impl AstNode for Expr {
867 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
868 match syntax.kind() {
896 | MACRO_CALL => Some(Expr::from_repr(syntax.into_repr())),
900 fn syntax(&self) -> &SyntaxNode { &self.syntax }
903 impl ToOwned for Expr {
904 type Owned = TreeArc<Expr>;
905 fn to_owned(&self) -> TreeArc<Expr> { TreeArc::cast(self.syntax.to_owned()) }
909 pub fn kind(&self) -> ExprKind {
910 match self.syntax.kind() {
911 TUPLE_EXPR => ExprKind::TupleExpr(TupleExpr::cast(&self.syntax).unwrap()),
912 ARRAY_EXPR => ExprKind::ArrayExpr(ArrayExpr::cast(&self.syntax).unwrap()),
913 PAREN_EXPR => ExprKind::ParenExpr(ParenExpr::cast(&self.syntax).unwrap()),
914 PATH_EXPR => ExprKind::PathExpr(PathExpr::cast(&self.syntax).unwrap()),
915 LAMBDA_EXPR => ExprKind::LambdaExpr(LambdaExpr::cast(&self.syntax).unwrap()),
916 IF_EXPR => ExprKind::IfExpr(IfExpr::cast(&self.syntax).unwrap()),
917 LOOP_EXPR => ExprKind::LoopExpr(LoopExpr::cast(&self.syntax).unwrap()),
918 FOR_EXPR => ExprKind::ForExpr(ForExpr::cast(&self.syntax).unwrap()),
919 WHILE_EXPR => ExprKind::WhileExpr(WhileExpr::cast(&self.syntax).unwrap()),
920 CONTINUE_EXPR => ExprKind::ContinueExpr(ContinueExpr::cast(&self.syntax).unwrap()),
921 BREAK_EXPR => ExprKind::BreakExpr(BreakExpr::cast(&self.syntax).unwrap()),
922 LABEL => ExprKind::Label(Label::cast(&self.syntax).unwrap()),
923 BLOCK_EXPR => ExprKind::BlockExpr(BlockExpr::cast(&self.syntax).unwrap()),
924 RETURN_EXPR => ExprKind::ReturnExpr(ReturnExpr::cast(&self.syntax).unwrap()),
925 MATCH_EXPR => ExprKind::MatchExpr(MatchExpr::cast(&self.syntax).unwrap()),
926 STRUCT_LIT => ExprKind::StructLit(StructLit::cast(&self.syntax).unwrap()),
927 CALL_EXPR => ExprKind::CallExpr(CallExpr::cast(&self.syntax).unwrap()),
928 INDEX_EXPR => ExprKind::IndexExpr(IndexExpr::cast(&self.syntax).unwrap()),
929 METHOD_CALL_EXPR => ExprKind::MethodCallExpr(MethodCallExpr::cast(&self.syntax).unwrap()),
930 FIELD_EXPR => ExprKind::FieldExpr(FieldExpr::cast(&self.syntax).unwrap()),
931 TRY_EXPR => ExprKind::TryExpr(TryExpr::cast(&self.syntax).unwrap()),
932 CAST_EXPR => ExprKind::CastExpr(CastExpr::cast(&self.syntax).unwrap()),
933 REF_EXPR => ExprKind::RefExpr(RefExpr::cast(&self.syntax).unwrap()),
934 PREFIX_EXPR => ExprKind::PrefixExpr(PrefixExpr::cast(&self.syntax).unwrap()),
935 RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(&self.syntax).unwrap()),
936 BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(&self.syntax).unwrap()),
937 LITERAL => ExprKind::Literal(Literal::cast(&self.syntax).unwrap()),
938 MACRO_CALL => ExprKind::MacroCall(MacroCall::cast(&self.syntax).unwrap()),
947 #[derive(Debug, PartialEq, Eq, Hash)]
949 pub struct ExprStmt {
950 pub(crate) syntax: SyntaxNode,
952 unsafe impl TransparentNewType for ExprStmt {
953 type Repr = rowan::SyntaxNode<RaTypes>;
956 impl AstNode for ExprStmt {
957 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
958 match syntax.kind() {
959 EXPR_STMT => Some(ExprStmt::from_repr(syntax.into_repr())),
963 fn syntax(&self) -> &SyntaxNode { &self.syntax }
966 impl ToOwned for ExprStmt {
967 type Owned = TreeArc<ExprStmt>;
968 fn to_owned(&self) -> TreeArc<ExprStmt> { TreeArc::cast(self.syntax.to_owned()) }
973 pub fn expr(&self) -> Option<&Expr> {
974 super::child_opt(self)
979 #[derive(Debug, PartialEq, Eq, Hash)]
981 pub struct ExternCrateItem {
982 pub(crate) syntax: SyntaxNode,
984 unsafe impl TransparentNewType for ExternCrateItem {
985 type Repr = rowan::SyntaxNode<RaTypes>;
988 impl AstNode for ExternCrateItem {
989 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
990 match syntax.kind() {
991 EXTERN_CRATE_ITEM => Some(ExternCrateItem::from_repr(syntax.into_repr())),
995 fn syntax(&self) -> &SyntaxNode { &self.syntax }
998 impl ToOwned for ExternCrateItem {
999 type Owned = TreeArc<ExternCrateItem>;
1000 fn to_owned(&self) -> TreeArc<ExternCrateItem> { TreeArc::cast(self.syntax.to_owned()) }
1004 impl ExternCrateItem {
1005 pub fn name_ref(&self) -> Option<&NameRef> {
1006 super::child_opt(self)
1009 pub fn alias(&self) -> Option<&Alias> {
1010 super::child_opt(self)
1015 #[derive(Debug, PartialEq, Eq, Hash)]
1016 #[repr(transparent)]
1017 pub struct FieldExpr {
1018 pub(crate) syntax: SyntaxNode,
1020 unsafe impl TransparentNewType for FieldExpr {
1021 type Repr = rowan::SyntaxNode<RaTypes>;
1024 impl AstNode for FieldExpr {
1025 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1026 match syntax.kind() {
1027 FIELD_EXPR => Some(FieldExpr::from_repr(syntax.into_repr())),
1031 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1034 impl ToOwned for FieldExpr {
1035 type Owned = TreeArc<FieldExpr>;
1036 fn to_owned(&self) -> TreeArc<FieldExpr> { TreeArc::cast(self.syntax.to_owned()) }
1041 pub fn expr(&self) -> Option<&Expr> {
1042 super::child_opt(self)
1045 pub fn name_ref(&self) -> Option<&NameRef> {
1046 super::child_opt(self)
1051 #[derive(Debug, PartialEq, Eq, Hash)]
1052 #[repr(transparent)]
1053 pub struct FieldPat {
1054 pub(crate) syntax: SyntaxNode,
1056 unsafe impl TransparentNewType for FieldPat {
1057 type Repr = rowan::SyntaxNode<RaTypes>;
1060 impl AstNode for FieldPat {
1061 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1062 match syntax.kind() {
1063 FIELD_PAT => Some(FieldPat::from_repr(syntax.into_repr())),
1067 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1070 impl ToOwned for FieldPat {
1071 type Owned = TreeArc<FieldPat>;
1072 fn to_owned(&self) -> TreeArc<FieldPat> { TreeArc::cast(self.syntax.to_owned()) }
1076 impl ast::NameOwner for FieldPat {}
1078 pub fn pat(&self) -> Option<&Pat> {
1079 super::child_opt(self)
1084 #[derive(Debug, PartialEq, Eq, Hash)]
1085 #[repr(transparent)]
1086 pub struct FieldPatList {
1087 pub(crate) syntax: SyntaxNode,
1089 unsafe impl TransparentNewType for FieldPatList {
1090 type Repr = rowan::SyntaxNode<RaTypes>;
1093 impl AstNode for FieldPatList {
1094 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1095 match syntax.kind() {
1096 FIELD_PAT_LIST => Some(FieldPatList::from_repr(syntax.into_repr())),
1100 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1103 impl ToOwned for FieldPatList {
1104 type Owned = TreeArc<FieldPatList>;
1105 fn to_owned(&self) -> TreeArc<FieldPatList> { TreeArc::cast(self.syntax.to_owned()) }
1110 pub fn field_pats(&self) -> impl Iterator<Item = &FieldPat> {
1111 super::children(self)
1114 pub fn bind_pats(&self) -> impl Iterator<Item = &BindPat> {
1115 super::children(self)
1120 #[derive(Debug, PartialEq, Eq, Hash)]
1121 #[repr(transparent)]
1123 pub(crate) syntax: SyntaxNode,
1125 unsafe impl TransparentNewType for FnDef {
1126 type Repr = rowan::SyntaxNode<RaTypes>;
1129 impl AstNode for FnDef {
1130 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1131 match syntax.kind() {
1132 FN_DEF => Some(FnDef::from_repr(syntax.into_repr())),
1136 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1139 impl ToOwned for FnDef {
1140 type Owned = TreeArc<FnDef>;
1141 fn to_owned(&self) -> TreeArc<FnDef> { TreeArc::cast(self.syntax.to_owned()) }
1145 impl ast::VisibilityOwner for FnDef {}
1146 impl ast::NameOwner for FnDef {}
1147 impl ast::TypeParamsOwner for FnDef {}
1148 impl ast::AttrsOwner for FnDef {}
1149 impl ast::DocCommentsOwner for FnDef {}
1151 pub fn param_list(&self) -> Option<&ParamList> {
1152 super::child_opt(self)
1155 pub fn body(&self) -> Option<&Block> {
1156 super::child_opt(self)
1159 pub fn ret_type(&self) -> Option<&RetType> {
1160 super::child_opt(self)
1165 #[derive(Debug, PartialEq, Eq, Hash)]
1166 #[repr(transparent)]
1167 pub struct FnPointerType {
1168 pub(crate) syntax: SyntaxNode,
1170 unsafe impl TransparentNewType for FnPointerType {
1171 type Repr = rowan::SyntaxNode<RaTypes>;
1174 impl AstNode for FnPointerType {
1175 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1176 match syntax.kind() {
1177 FN_POINTER_TYPE => Some(FnPointerType::from_repr(syntax.into_repr())),
1181 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1184 impl ToOwned for FnPointerType {
1185 type Owned = TreeArc<FnPointerType>;
1186 fn to_owned(&self) -> TreeArc<FnPointerType> { TreeArc::cast(self.syntax.to_owned()) }
1190 impl FnPointerType {
1191 pub fn param_list(&self) -> Option<&ParamList> {
1192 super::child_opt(self)
1195 pub fn ret_type(&self) -> Option<&RetType> {
1196 super::child_opt(self)
1201 #[derive(Debug, PartialEq, Eq, Hash)]
1202 #[repr(transparent)]
1203 pub struct ForExpr {
1204 pub(crate) syntax: SyntaxNode,
1206 unsafe impl TransparentNewType for ForExpr {
1207 type Repr = rowan::SyntaxNode<RaTypes>;
1210 impl AstNode for ForExpr {
1211 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1212 match syntax.kind() {
1213 FOR_EXPR => Some(ForExpr::from_repr(syntax.into_repr())),
1217 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1220 impl ToOwned for ForExpr {
1221 type Owned = TreeArc<ForExpr>;
1222 fn to_owned(&self) -> TreeArc<ForExpr> { TreeArc::cast(self.syntax.to_owned()) }
1226 impl ast::LoopBodyOwner for ForExpr {}
1228 pub fn pat(&self) -> Option<&Pat> {
1229 super::child_opt(self)
1232 pub fn iterable(&self) -> Option<&Expr> {
1233 super::child_opt(self)
1238 #[derive(Debug, PartialEq, Eq, Hash)]
1239 #[repr(transparent)]
1240 pub struct ForType {
1241 pub(crate) syntax: SyntaxNode,
1243 unsafe impl TransparentNewType for ForType {
1244 type Repr = rowan::SyntaxNode<RaTypes>;
1247 impl AstNode for ForType {
1248 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1249 match syntax.kind() {
1250 FOR_TYPE => Some(ForType::from_repr(syntax.into_repr())),
1254 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1257 impl ToOwned for ForType {
1258 type Owned = TreeArc<ForType>;
1259 fn to_owned(&self) -> TreeArc<ForType> { TreeArc::cast(self.syntax.to_owned()) }
1264 pub fn type_ref(&self) -> Option<&TypeRef> {
1265 super::child_opt(self)
1270 #[derive(Debug, PartialEq, Eq, Hash)]
1271 #[repr(transparent)]
1273 pub(crate) syntax: SyntaxNode,
1275 unsafe impl TransparentNewType for IfExpr {
1276 type Repr = rowan::SyntaxNode<RaTypes>;
1279 impl AstNode for IfExpr {
1280 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1281 match syntax.kind() {
1282 IF_EXPR => Some(IfExpr::from_repr(syntax.into_repr())),
1286 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1289 impl ToOwned for IfExpr {
1290 type Owned = TreeArc<IfExpr>;
1291 fn to_owned(&self) -> TreeArc<IfExpr> { TreeArc::cast(self.syntax.to_owned()) }
1296 pub fn condition(&self) -> Option<&Condition> {
1297 super::child_opt(self)
1302 #[derive(Debug, PartialEq, Eq, Hash)]
1303 #[repr(transparent)]
1304 pub struct ImplBlock {
1305 pub(crate) syntax: SyntaxNode,
1307 unsafe impl TransparentNewType for ImplBlock {
1308 type Repr = rowan::SyntaxNode<RaTypes>;
1311 impl AstNode for ImplBlock {
1312 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1313 match syntax.kind() {
1314 IMPL_BLOCK => Some(ImplBlock::from_repr(syntax.into_repr())),
1318 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1321 impl ToOwned for ImplBlock {
1322 type Owned = TreeArc<ImplBlock>;
1323 fn to_owned(&self) -> TreeArc<ImplBlock> { TreeArc::cast(self.syntax.to_owned()) }
1327 impl ast::TypeParamsOwner for ImplBlock {}
1329 pub fn item_list(&self) -> Option<&ItemList> {
1330 super::child_opt(self)
1335 #[derive(Debug, PartialEq, Eq, Hash)]
1336 #[repr(transparent)]
1337 pub struct ImplItem {
1338 pub(crate) syntax: SyntaxNode,
1340 unsafe impl TransparentNewType for ImplItem {
1341 type Repr = rowan::SyntaxNode<RaTypes>;
1344 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1345 pub enum ImplItemKind<'a> {
1347 TypeAliasDef(&'a TypeAliasDef),
1348 ConstDef(&'a ConstDef),
1350 impl<'a> From<&'a FnDef> for &'a ImplItem {
1351 fn from(n: &'a FnDef) -> &'a ImplItem {
1352 ImplItem::cast(&n.syntax).unwrap()
1355 impl<'a> From<&'a TypeAliasDef> for &'a ImplItem {
1356 fn from(n: &'a TypeAliasDef) -> &'a ImplItem {
1357 ImplItem::cast(&n.syntax).unwrap()
1360 impl<'a> From<&'a ConstDef> for &'a ImplItem {
1361 fn from(n: &'a ConstDef) -> &'a ImplItem {
1362 ImplItem::cast(&n.syntax).unwrap()
1367 impl AstNode for ImplItem {
1368 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1369 match syntax.kind() {
1372 | CONST_DEF => Some(ImplItem::from_repr(syntax.into_repr())),
1376 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1379 impl ToOwned for ImplItem {
1380 type Owned = TreeArc<ImplItem>;
1381 fn to_owned(&self) -> TreeArc<ImplItem> { TreeArc::cast(self.syntax.to_owned()) }
1385 pub fn kind(&self) -> ImplItemKind {
1386 match self.syntax.kind() {
1387 FN_DEF => ImplItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
1388 TYPE_ALIAS_DEF => ImplItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
1389 CONST_DEF => ImplItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
1390 _ => unreachable!(),
1398 #[derive(Debug, PartialEq, Eq, Hash)]
1399 #[repr(transparent)]
1400 pub struct ImplTraitType {
1401 pub(crate) syntax: SyntaxNode,
1403 unsafe impl TransparentNewType for ImplTraitType {
1404 type Repr = rowan::SyntaxNode<RaTypes>;
1407 impl AstNode for ImplTraitType {
1408 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1409 match syntax.kind() {
1410 IMPL_TRAIT_TYPE => Some(ImplTraitType::from_repr(syntax.into_repr())),
1414 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1417 impl ToOwned for ImplTraitType {
1418 type Owned = TreeArc<ImplTraitType>;
1419 fn to_owned(&self) -> TreeArc<ImplTraitType> { TreeArc::cast(self.syntax.to_owned()) }
1423 impl ast::TypeBoundsOwner for ImplTraitType {}
1424 impl ImplTraitType {}
1427 #[derive(Debug, PartialEq, Eq, Hash)]
1428 #[repr(transparent)]
1429 pub struct IndexExpr {
1430 pub(crate) syntax: SyntaxNode,
1432 unsafe impl TransparentNewType for IndexExpr {
1433 type Repr = rowan::SyntaxNode<RaTypes>;
1436 impl AstNode for IndexExpr {
1437 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1438 match syntax.kind() {
1439 INDEX_EXPR => Some(IndexExpr::from_repr(syntax.into_repr())),
1443 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1446 impl ToOwned for IndexExpr {
1447 type Owned = TreeArc<IndexExpr>;
1448 fn to_owned(&self) -> TreeArc<IndexExpr> { TreeArc::cast(self.syntax.to_owned()) }
1455 #[derive(Debug, PartialEq, Eq, Hash)]
1456 #[repr(transparent)]
1457 pub struct ItemList {
1458 pub(crate) syntax: SyntaxNode,
1460 unsafe impl TransparentNewType for ItemList {
1461 type Repr = rowan::SyntaxNode<RaTypes>;
1464 impl AstNode for ItemList {
1465 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1466 match syntax.kind() {
1467 ITEM_LIST => Some(ItemList::from_repr(syntax.into_repr())),
1471 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1474 impl ToOwned for ItemList {
1475 type Owned = TreeArc<ItemList>;
1476 fn to_owned(&self) -> TreeArc<ItemList> { TreeArc::cast(self.syntax.to_owned()) }
1480 impl ast::FnDefOwner for ItemList {}
1481 impl ast::ModuleItemOwner for ItemList {}
1483 pub fn impl_items(&self) -> impl Iterator<Item = &ImplItem> {
1484 super::children(self)
1489 #[derive(Debug, PartialEq, Eq, Hash)]
1490 #[repr(transparent)]
1492 pub(crate) syntax: SyntaxNode,
1494 unsafe impl TransparentNewType for Label {
1495 type Repr = rowan::SyntaxNode<RaTypes>;
1498 impl AstNode for Label {
1499 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1500 match syntax.kind() {
1501 LABEL => Some(Label::from_repr(syntax.into_repr())),
1505 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1508 impl ToOwned for Label {
1509 type Owned = TreeArc<Label>;
1510 fn to_owned(&self) -> TreeArc<Label> { TreeArc::cast(self.syntax.to_owned()) }
1517 #[derive(Debug, PartialEq, Eq, Hash)]
1518 #[repr(transparent)]
1519 pub struct LambdaExpr {
1520 pub(crate) syntax: SyntaxNode,
1522 unsafe impl TransparentNewType for LambdaExpr {
1523 type Repr = rowan::SyntaxNode<RaTypes>;
1526 impl AstNode for LambdaExpr {
1527 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1528 match syntax.kind() {
1529 LAMBDA_EXPR => Some(LambdaExpr::from_repr(syntax.into_repr())),
1533 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1536 impl ToOwned for LambdaExpr {
1537 type Owned = TreeArc<LambdaExpr>;
1538 fn to_owned(&self) -> TreeArc<LambdaExpr> { TreeArc::cast(self.syntax.to_owned()) }
1543 pub fn param_list(&self) -> Option<&ParamList> {
1544 super::child_opt(self)
1547 pub fn body(&self) -> Option<&Expr> {
1548 super::child_opt(self)
1553 #[derive(Debug, PartialEq, Eq, Hash)]
1554 #[repr(transparent)]
1555 pub struct LetStmt {
1556 pub(crate) syntax: SyntaxNode,
1558 unsafe impl TransparentNewType for LetStmt {
1559 type Repr = rowan::SyntaxNode<RaTypes>;
1562 impl AstNode for LetStmt {
1563 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1564 match syntax.kind() {
1565 LET_STMT => Some(LetStmt::from_repr(syntax.into_repr())),
1569 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1572 impl ToOwned for LetStmt {
1573 type Owned = TreeArc<LetStmt>;
1574 fn to_owned(&self) -> TreeArc<LetStmt> { TreeArc::cast(self.syntax.to_owned()) }
1578 impl ast::TypeAscriptionOwner for LetStmt {}
1580 pub fn pat(&self) -> Option<&Pat> {
1581 super::child_opt(self)
1584 pub fn initializer(&self) -> Option<&Expr> {
1585 super::child_opt(self)
1590 #[derive(Debug, PartialEq, Eq, Hash)]
1591 #[repr(transparent)]
1592 pub struct LifetimeArg {
1593 pub(crate) syntax: SyntaxNode,
1595 unsafe impl TransparentNewType for LifetimeArg {
1596 type Repr = rowan::SyntaxNode<RaTypes>;
1599 impl AstNode for LifetimeArg {
1600 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1601 match syntax.kind() {
1602 LIFETIME_ARG => Some(LifetimeArg::from_repr(syntax.into_repr())),
1606 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1609 impl ToOwned for LifetimeArg {
1610 type Owned = TreeArc<LifetimeArg>;
1611 fn to_owned(&self) -> TreeArc<LifetimeArg> { TreeArc::cast(self.syntax.to_owned()) }
1618 #[derive(Debug, PartialEq, Eq, Hash)]
1619 #[repr(transparent)]
1620 pub struct LifetimeParam {
1621 pub(crate) syntax: SyntaxNode,
1623 unsafe impl TransparentNewType for LifetimeParam {
1624 type Repr = rowan::SyntaxNode<RaTypes>;
1627 impl AstNode for LifetimeParam {
1628 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1629 match syntax.kind() {
1630 LIFETIME_PARAM => Some(LifetimeParam::from_repr(syntax.into_repr())),
1634 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1637 impl ToOwned for LifetimeParam {
1638 type Owned = TreeArc<LifetimeParam>;
1639 fn to_owned(&self) -> TreeArc<LifetimeParam> { TreeArc::cast(self.syntax.to_owned()) }
1643 impl ast::AttrsOwner for LifetimeParam {}
1644 impl LifetimeParam {}
1647 #[derive(Debug, PartialEq, Eq, Hash)]
1648 #[repr(transparent)]
1649 pub struct Literal {
1650 pub(crate) syntax: SyntaxNode,
1652 unsafe impl TransparentNewType for Literal {
1653 type Repr = rowan::SyntaxNode<RaTypes>;
1656 impl AstNode for Literal {
1657 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1658 match syntax.kind() {
1659 LITERAL => Some(Literal::from_repr(syntax.into_repr())),
1663 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1666 impl ToOwned for Literal {
1667 type Owned = TreeArc<Literal>;
1668 fn to_owned(&self) -> TreeArc<Literal> { TreeArc::cast(self.syntax.to_owned()) }
1675 #[derive(Debug, PartialEq, Eq, Hash)]
1676 #[repr(transparent)]
1677 pub struct LiteralPat {
1678 pub(crate) syntax: SyntaxNode,
1680 unsafe impl TransparentNewType for LiteralPat {
1681 type Repr = rowan::SyntaxNode<RaTypes>;
1684 impl AstNode for LiteralPat {
1685 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1686 match syntax.kind() {
1687 LITERAL_PAT => Some(LiteralPat::from_repr(syntax.into_repr())),
1691 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1694 impl ToOwned for LiteralPat {
1695 type Owned = TreeArc<LiteralPat>;
1696 fn to_owned(&self) -> TreeArc<LiteralPat> { TreeArc::cast(self.syntax.to_owned()) }
1701 pub fn literal(&self) -> Option<&Literal> {
1702 super::child_opt(self)
1707 #[derive(Debug, PartialEq, Eq, Hash)]
1708 #[repr(transparent)]
1709 pub struct LoopExpr {
1710 pub(crate) syntax: SyntaxNode,
1712 unsafe impl TransparentNewType for LoopExpr {
1713 type Repr = rowan::SyntaxNode<RaTypes>;
1716 impl AstNode for LoopExpr {
1717 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1718 match syntax.kind() {
1719 LOOP_EXPR => Some(LoopExpr::from_repr(syntax.into_repr())),
1723 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1726 impl ToOwned for LoopExpr {
1727 type Owned = TreeArc<LoopExpr>;
1728 fn to_owned(&self) -> TreeArc<LoopExpr> { TreeArc::cast(self.syntax.to_owned()) }
1732 impl ast::LoopBodyOwner for LoopExpr {}
1736 #[derive(Debug, PartialEq, Eq, Hash)]
1737 #[repr(transparent)]
1738 pub struct MacroCall {
1739 pub(crate) syntax: SyntaxNode,
1741 unsafe impl TransparentNewType for MacroCall {
1742 type Repr = rowan::SyntaxNode<RaTypes>;
1745 impl AstNode for MacroCall {
1746 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1747 match syntax.kind() {
1748 MACRO_CALL => Some(MacroCall::from_repr(syntax.into_repr())),
1752 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1755 impl ToOwned for MacroCall {
1756 type Owned = TreeArc<MacroCall>;
1757 fn to_owned(&self) -> TreeArc<MacroCall> { TreeArc::cast(self.syntax.to_owned()) }
1761 impl ast::NameOwner for MacroCall {}
1762 impl ast::AttrsOwner for MacroCall {}
1764 pub fn token_tree(&self) -> Option<&TokenTree> {
1765 super::child_opt(self)
1768 pub fn path(&self) -> Option<&Path> {
1769 super::child_opt(self)
1774 #[derive(Debug, PartialEq, Eq, Hash)]
1775 #[repr(transparent)]
1776 pub struct MatchArm {
1777 pub(crate) syntax: SyntaxNode,
1779 unsafe impl TransparentNewType for MatchArm {
1780 type Repr = rowan::SyntaxNode<RaTypes>;
1783 impl AstNode for MatchArm {
1784 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1785 match syntax.kind() {
1786 MATCH_ARM => Some(MatchArm::from_repr(syntax.into_repr())),
1790 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1793 impl ToOwned for MatchArm {
1794 type Owned = TreeArc<MatchArm>;
1795 fn to_owned(&self) -> TreeArc<MatchArm> { TreeArc::cast(self.syntax.to_owned()) }
1799 impl ast::AttrsOwner for MatchArm {}
1801 pub fn pats(&self) -> impl Iterator<Item = &Pat> {
1802 super::children(self)
1805 pub fn guard(&self) -> Option<&MatchGuard> {
1806 super::child_opt(self)
1809 pub fn expr(&self) -> Option<&Expr> {
1810 super::child_opt(self)
1815 #[derive(Debug, PartialEq, Eq, Hash)]
1816 #[repr(transparent)]
1817 pub struct MatchArmList {
1818 pub(crate) syntax: SyntaxNode,
1820 unsafe impl TransparentNewType for MatchArmList {
1821 type Repr = rowan::SyntaxNode<RaTypes>;
1824 impl AstNode for MatchArmList {
1825 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1826 match syntax.kind() {
1827 MATCH_ARM_LIST => Some(MatchArmList::from_repr(syntax.into_repr())),
1831 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1834 impl ToOwned for MatchArmList {
1835 type Owned = TreeArc<MatchArmList>;
1836 fn to_owned(&self) -> TreeArc<MatchArmList> { TreeArc::cast(self.syntax.to_owned()) }
1840 impl ast::AttrsOwner for MatchArmList {}
1842 pub fn arms(&self) -> impl Iterator<Item = &MatchArm> {
1843 super::children(self)
1848 #[derive(Debug, PartialEq, Eq, Hash)]
1849 #[repr(transparent)]
1850 pub struct MatchExpr {
1851 pub(crate) syntax: SyntaxNode,
1853 unsafe impl TransparentNewType for MatchExpr {
1854 type Repr = rowan::SyntaxNode<RaTypes>;
1857 impl AstNode for MatchExpr {
1858 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1859 match syntax.kind() {
1860 MATCH_EXPR => Some(MatchExpr::from_repr(syntax.into_repr())),
1864 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1867 impl ToOwned for MatchExpr {
1868 type Owned = TreeArc<MatchExpr>;
1869 fn to_owned(&self) -> TreeArc<MatchExpr> { TreeArc::cast(self.syntax.to_owned()) }
1874 pub fn expr(&self) -> Option<&Expr> {
1875 super::child_opt(self)
1878 pub fn match_arm_list(&self) -> Option<&MatchArmList> {
1879 super::child_opt(self)
1884 #[derive(Debug, PartialEq, Eq, Hash)]
1885 #[repr(transparent)]
1886 pub struct MatchGuard {
1887 pub(crate) syntax: SyntaxNode,
1889 unsafe impl TransparentNewType for MatchGuard {
1890 type Repr = rowan::SyntaxNode<RaTypes>;
1893 impl AstNode for MatchGuard {
1894 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1895 match syntax.kind() {
1896 MATCH_GUARD => Some(MatchGuard::from_repr(syntax.into_repr())),
1900 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1903 impl ToOwned for MatchGuard {
1904 type Owned = TreeArc<MatchGuard>;
1905 fn to_owned(&self) -> TreeArc<MatchGuard> { TreeArc::cast(self.syntax.to_owned()) }
1910 pub fn expr(&self) -> Option<&Expr> {
1911 super::child_opt(self)
1916 #[derive(Debug, PartialEq, Eq, Hash)]
1917 #[repr(transparent)]
1918 pub struct MethodCallExpr {
1919 pub(crate) syntax: SyntaxNode,
1921 unsafe impl TransparentNewType for MethodCallExpr {
1922 type Repr = rowan::SyntaxNode<RaTypes>;
1925 impl AstNode for MethodCallExpr {
1926 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1927 match syntax.kind() {
1928 METHOD_CALL_EXPR => Some(MethodCallExpr::from_repr(syntax.into_repr())),
1932 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1935 impl ToOwned for MethodCallExpr {
1936 type Owned = TreeArc<MethodCallExpr>;
1937 fn to_owned(&self) -> TreeArc<MethodCallExpr> { TreeArc::cast(self.syntax.to_owned()) }
1941 impl ast::ArgListOwner for MethodCallExpr {}
1942 impl MethodCallExpr {
1943 pub fn expr(&self) -> Option<&Expr> {
1944 super::child_opt(self)
1947 pub fn name_ref(&self) -> Option<&NameRef> {
1948 super::child_opt(self)
1951 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
1952 super::child_opt(self)
1957 #[derive(Debug, PartialEq, Eq, Hash)]
1958 #[repr(transparent)]
1960 pub(crate) syntax: SyntaxNode,
1962 unsafe impl TransparentNewType for Module {
1963 type Repr = rowan::SyntaxNode<RaTypes>;
1966 impl AstNode for Module {
1967 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1968 match syntax.kind() {
1969 MODULE => Some(Module::from_repr(syntax.into_repr())),
1973 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1976 impl ToOwned for Module {
1977 type Owned = TreeArc<Module>;
1978 fn to_owned(&self) -> TreeArc<Module> { TreeArc::cast(self.syntax.to_owned()) }
1982 impl ast::VisibilityOwner for Module {}
1983 impl ast::NameOwner for Module {}
1984 impl ast::AttrsOwner for Module {}
1985 impl ast::DocCommentsOwner for Module {}
1987 pub fn item_list(&self) -> Option<&ItemList> {
1988 super::child_opt(self)
1993 #[derive(Debug, PartialEq, Eq, Hash)]
1994 #[repr(transparent)]
1995 pub struct ModuleItem {
1996 pub(crate) syntax: SyntaxNode,
1998 unsafe impl TransparentNewType for ModuleItem {
1999 type Repr = rowan::SyntaxNode<RaTypes>;
2002 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2003 pub enum ModuleItemKind<'a> {
2004 StructDef(&'a StructDef),
2005 EnumDef(&'a EnumDef),
2007 TraitDef(&'a TraitDef),
2008 TypeAliasDef(&'a TypeAliasDef),
2009 ImplBlock(&'a ImplBlock),
2010 UseItem(&'a UseItem),
2011 ExternCrateItem(&'a ExternCrateItem),
2012 ConstDef(&'a ConstDef),
2013 StaticDef(&'a StaticDef),
2016 impl<'a> From<&'a StructDef> for &'a ModuleItem {
2017 fn from(n: &'a StructDef) -> &'a ModuleItem {
2018 ModuleItem::cast(&n.syntax).unwrap()
2021 impl<'a> From<&'a EnumDef> for &'a ModuleItem {
2022 fn from(n: &'a EnumDef) -> &'a ModuleItem {
2023 ModuleItem::cast(&n.syntax).unwrap()
2026 impl<'a> From<&'a FnDef> for &'a ModuleItem {
2027 fn from(n: &'a FnDef) -> &'a ModuleItem {
2028 ModuleItem::cast(&n.syntax).unwrap()
2031 impl<'a> From<&'a TraitDef> for &'a ModuleItem {
2032 fn from(n: &'a TraitDef) -> &'a ModuleItem {
2033 ModuleItem::cast(&n.syntax).unwrap()
2036 impl<'a> From<&'a TypeAliasDef> for &'a ModuleItem {
2037 fn from(n: &'a TypeAliasDef) -> &'a ModuleItem {
2038 ModuleItem::cast(&n.syntax).unwrap()
2041 impl<'a> From<&'a ImplBlock> for &'a ModuleItem {
2042 fn from(n: &'a ImplBlock) -> &'a ModuleItem {
2043 ModuleItem::cast(&n.syntax).unwrap()
2046 impl<'a> From<&'a UseItem> for &'a ModuleItem {
2047 fn from(n: &'a UseItem) -> &'a ModuleItem {
2048 ModuleItem::cast(&n.syntax).unwrap()
2051 impl<'a> From<&'a ExternCrateItem> for &'a ModuleItem {
2052 fn from(n: &'a ExternCrateItem) -> &'a ModuleItem {
2053 ModuleItem::cast(&n.syntax).unwrap()
2056 impl<'a> From<&'a ConstDef> for &'a ModuleItem {
2057 fn from(n: &'a ConstDef) -> &'a ModuleItem {
2058 ModuleItem::cast(&n.syntax).unwrap()
2061 impl<'a> From<&'a StaticDef> for &'a ModuleItem {
2062 fn from(n: &'a StaticDef) -> &'a ModuleItem {
2063 ModuleItem::cast(&n.syntax).unwrap()
2066 impl<'a> From<&'a Module> for &'a ModuleItem {
2067 fn from(n: &'a Module) -> &'a ModuleItem {
2068 ModuleItem::cast(&n.syntax).unwrap()
2073 impl AstNode for ModuleItem {
2074 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2075 match syntax.kind() {
2086 | MODULE => Some(ModuleItem::from_repr(syntax.into_repr())),
2090 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2093 impl ToOwned for ModuleItem {
2094 type Owned = TreeArc<ModuleItem>;
2095 fn to_owned(&self) -> TreeArc<ModuleItem> { TreeArc::cast(self.syntax.to_owned()) }
2099 pub fn kind(&self) -> ModuleItemKind {
2100 match self.syntax.kind() {
2101 STRUCT_DEF => ModuleItemKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2102 ENUM_DEF => ModuleItemKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2103 FN_DEF => ModuleItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
2104 TRAIT_DEF => ModuleItemKind::TraitDef(TraitDef::cast(&self.syntax).unwrap()),
2105 TYPE_ALIAS_DEF => ModuleItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
2106 IMPL_BLOCK => ModuleItemKind::ImplBlock(ImplBlock::cast(&self.syntax).unwrap()),
2107 USE_ITEM => ModuleItemKind::UseItem(UseItem::cast(&self.syntax).unwrap()),
2108 EXTERN_CRATE_ITEM => ModuleItemKind::ExternCrateItem(ExternCrateItem::cast(&self.syntax).unwrap()),
2109 CONST_DEF => ModuleItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
2110 STATIC_DEF => ModuleItemKind::StaticDef(StaticDef::cast(&self.syntax).unwrap()),
2111 MODULE => ModuleItemKind::Module(Module::cast(&self.syntax).unwrap()),
2112 _ => unreachable!(),
2120 #[derive(Debug, PartialEq, Eq, Hash)]
2121 #[repr(transparent)]
2123 pub(crate) syntax: SyntaxNode,
2125 unsafe impl TransparentNewType for Name {
2126 type Repr = rowan::SyntaxNode<RaTypes>;
2129 impl AstNode for Name {
2130 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2131 match syntax.kind() {
2132 NAME => Some(Name::from_repr(syntax.into_repr())),
2136 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2139 impl ToOwned for Name {
2140 type Owned = TreeArc<Name>;
2141 fn to_owned(&self) -> TreeArc<Name> { TreeArc::cast(self.syntax.to_owned()) }
2148 #[derive(Debug, PartialEq, Eq, Hash)]
2149 #[repr(transparent)]
2150 pub struct NameRef {
2151 pub(crate) syntax: SyntaxNode,
2153 unsafe impl TransparentNewType for NameRef {
2154 type Repr = rowan::SyntaxNode<RaTypes>;
2157 impl AstNode for NameRef {
2158 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2159 match syntax.kind() {
2160 NAME_REF => Some(NameRef::from_repr(syntax.into_repr())),
2164 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2167 impl ToOwned for NameRef {
2168 type Owned = TreeArc<NameRef>;
2169 fn to_owned(&self) -> TreeArc<NameRef> { TreeArc::cast(self.syntax.to_owned()) }
2176 #[derive(Debug, PartialEq, Eq, Hash)]
2177 #[repr(transparent)]
2178 pub struct NamedField {
2179 pub(crate) syntax: SyntaxNode,
2181 unsafe impl TransparentNewType for NamedField {
2182 type Repr = rowan::SyntaxNode<RaTypes>;
2185 impl AstNode for NamedField {
2186 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2187 match syntax.kind() {
2188 NAMED_FIELD => Some(NamedField::from_repr(syntax.into_repr())),
2192 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2195 impl ToOwned for NamedField {
2196 type Owned = TreeArc<NamedField>;
2197 fn to_owned(&self) -> TreeArc<NamedField> { TreeArc::cast(self.syntax.to_owned()) }
2202 pub fn name_ref(&self) -> Option<&NameRef> {
2203 super::child_opt(self)
2206 pub fn expr(&self) -> Option<&Expr> {
2207 super::child_opt(self)
2212 #[derive(Debug, PartialEq, Eq, Hash)]
2213 #[repr(transparent)]
2214 pub struct NamedFieldDef {
2215 pub(crate) syntax: SyntaxNode,
2217 unsafe impl TransparentNewType for NamedFieldDef {
2218 type Repr = rowan::SyntaxNode<RaTypes>;
2221 impl AstNode for NamedFieldDef {
2222 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2223 match syntax.kind() {
2224 NAMED_FIELD_DEF => Some(NamedFieldDef::from_repr(syntax.into_repr())),
2228 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2231 impl ToOwned for NamedFieldDef {
2232 type Owned = TreeArc<NamedFieldDef>;
2233 fn to_owned(&self) -> TreeArc<NamedFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2237 impl ast::VisibilityOwner for NamedFieldDef {}
2238 impl ast::NameOwner for NamedFieldDef {}
2239 impl ast::AttrsOwner for NamedFieldDef {}
2240 impl ast::DocCommentsOwner for NamedFieldDef {}
2241 impl ast::TypeAscriptionOwner for NamedFieldDef {}
2242 impl NamedFieldDef {}
2244 // NamedFieldDefList
2245 #[derive(Debug, PartialEq, Eq, Hash)]
2246 #[repr(transparent)]
2247 pub struct NamedFieldDefList {
2248 pub(crate) syntax: SyntaxNode,
2250 unsafe impl TransparentNewType for NamedFieldDefList {
2251 type Repr = rowan::SyntaxNode<RaTypes>;
2254 impl AstNode for NamedFieldDefList {
2255 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2256 match syntax.kind() {
2257 NAMED_FIELD_DEF_LIST => Some(NamedFieldDefList::from_repr(syntax.into_repr())),
2261 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2264 impl ToOwned for NamedFieldDefList {
2265 type Owned = TreeArc<NamedFieldDefList>;
2266 fn to_owned(&self) -> TreeArc<NamedFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
2270 impl NamedFieldDefList {
2271 pub fn fields(&self) -> impl Iterator<Item = &NamedFieldDef> {
2272 super::children(self)
2277 #[derive(Debug, PartialEq, Eq, Hash)]
2278 #[repr(transparent)]
2279 pub struct NamedFieldList {
2280 pub(crate) syntax: SyntaxNode,
2282 unsafe impl TransparentNewType for NamedFieldList {
2283 type Repr = rowan::SyntaxNode<RaTypes>;
2286 impl AstNode for NamedFieldList {
2287 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2288 match syntax.kind() {
2289 NAMED_FIELD_LIST => Some(NamedFieldList::from_repr(syntax.into_repr())),
2293 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2296 impl ToOwned for NamedFieldList {
2297 type Owned = TreeArc<NamedFieldList>;
2298 fn to_owned(&self) -> TreeArc<NamedFieldList> { TreeArc::cast(self.syntax.to_owned()) }
2302 impl NamedFieldList {
2303 pub fn fields(&self) -> impl Iterator<Item = &NamedField> {
2304 super::children(self)
2309 #[derive(Debug, PartialEq, Eq, Hash)]
2310 #[repr(transparent)]
2311 pub struct NeverType {
2312 pub(crate) syntax: SyntaxNode,
2314 unsafe impl TransparentNewType for NeverType {
2315 type Repr = rowan::SyntaxNode<RaTypes>;
2318 impl AstNode for NeverType {
2319 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2320 match syntax.kind() {
2321 NEVER_TYPE => Some(NeverType::from_repr(syntax.into_repr())),
2325 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2328 impl ToOwned for NeverType {
2329 type Owned = TreeArc<NeverType>;
2330 fn to_owned(&self) -> TreeArc<NeverType> { TreeArc::cast(self.syntax.to_owned()) }
2337 #[derive(Debug, PartialEq, Eq, Hash)]
2338 #[repr(transparent)]
2339 pub struct NominalDef {
2340 pub(crate) syntax: SyntaxNode,
2342 unsafe impl TransparentNewType for NominalDef {
2343 type Repr = rowan::SyntaxNode<RaTypes>;
2346 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2347 pub enum NominalDefKind<'a> {
2348 StructDef(&'a StructDef),
2349 EnumDef(&'a EnumDef),
2351 impl<'a> From<&'a StructDef> for &'a NominalDef {
2352 fn from(n: &'a StructDef) -> &'a NominalDef {
2353 NominalDef::cast(&n.syntax).unwrap()
2356 impl<'a> From<&'a EnumDef> for &'a NominalDef {
2357 fn from(n: &'a EnumDef) -> &'a NominalDef {
2358 NominalDef::cast(&n.syntax).unwrap()
2363 impl AstNode for NominalDef {
2364 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2365 match syntax.kind() {
2367 | ENUM_DEF => Some(NominalDef::from_repr(syntax.into_repr())),
2371 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2374 impl ToOwned for NominalDef {
2375 type Owned = TreeArc<NominalDef>;
2376 fn to_owned(&self) -> TreeArc<NominalDef> { TreeArc::cast(self.syntax.to_owned()) }
2380 pub fn kind(&self) -> NominalDefKind {
2381 match self.syntax.kind() {
2382 STRUCT_DEF => NominalDefKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2383 ENUM_DEF => NominalDefKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2384 _ => unreachable!(),
2389 impl ast::NameOwner for NominalDef {}
2390 impl ast::TypeParamsOwner for NominalDef {}
2391 impl ast::AttrsOwner for NominalDef {}
2395 #[derive(Debug, PartialEq, Eq, Hash)]
2396 #[repr(transparent)]
2398 pub(crate) syntax: SyntaxNode,
2400 unsafe impl TransparentNewType for Param {
2401 type Repr = rowan::SyntaxNode<RaTypes>;
2404 impl AstNode for Param {
2405 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2406 match syntax.kind() {
2407 PARAM => Some(Param::from_repr(syntax.into_repr())),
2411 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2414 impl ToOwned for Param {
2415 type Owned = TreeArc<Param>;
2416 fn to_owned(&self) -> TreeArc<Param> { TreeArc::cast(self.syntax.to_owned()) }
2420 impl ast::TypeAscriptionOwner for Param {}
2422 pub fn pat(&self) -> Option<&Pat> {
2423 super::child_opt(self)
2428 #[derive(Debug, PartialEq, Eq, Hash)]
2429 #[repr(transparent)]
2430 pub struct ParamList {
2431 pub(crate) syntax: SyntaxNode,
2433 unsafe impl TransparentNewType for ParamList {
2434 type Repr = rowan::SyntaxNode<RaTypes>;
2437 impl AstNode for ParamList {
2438 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2439 match syntax.kind() {
2440 PARAM_LIST => Some(ParamList::from_repr(syntax.into_repr())),
2444 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2447 impl ToOwned for ParamList {
2448 type Owned = TreeArc<ParamList>;
2449 fn to_owned(&self) -> TreeArc<ParamList> { TreeArc::cast(self.syntax.to_owned()) }
2454 pub fn params(&self) -> impl Iterator<Item = &Param> {
2455 super::children(self)
2458 pub fn self_param(&self) -> Option<&SelfParam> {
2459 super::child_opt(self)
2464 #[derive(Debug, PartialEq, Eq, Hash)]
2465 #[repr(transparent)]
2466 pub struct ParenExpr {
2467 pub(crate) syntax: SyntaxNode,
2469 unsafe impl TransparentNewType for ParenExpr {
2470 type Repr = rowan::SyntaxNode<RaTypes>;
2473 impl AstNode for ParenExpr {
2474 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2475 match syntax.kind() {
2476 PAREN_EXPR => Some(ParenExpr::from_repr(syntax.into_repr())),
2480 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2483 impl ToOwned for ParenExpr {
2484 type Owned = TreeArc<ParenExpr>;
2485 fn to_owned(&self) -> TreeArc<ParenExpr> { TreeArc::cast(self.syntax.to_owned()) }
2490 pub fn expr(&self) -> Option<&Expr> {
2491 super::child_opt(self)
2496 #[derive(Debug, PartialEq, Eq, Hash)]
2497 #[repr(transparent)]
2498 pub struct ParenType {
2499 pub(crate) syntax: SyntaxNode,
2501 unsafe impl TransparentNewType for ParenType {
2502 type Repr = rowan::SyntaxNode<RaTypes>;
2505 impl AstNode for ParenType {
2506 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2507 match syntax.kind() {
2508 PAREN_TYPE => Some(ParenType::from_repr(syntax.into_repr())),
2512 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2515 impl ToOwned for ParenType {
2516 type Owned = TreeArc<ParenType>;
2517 fn to_owned(&self) -> TreeArc<ParenType> { TreeArc::cast(self.syntax.to_owned()) }
2522 pub fn type_ref(&self) -> Option<&TypeRef> {
2523 super::child_opt(self)
2528 #[derive(Debug, PartialEq, Eq, Hash)]
2529 #[repr(transparent)]
2531 pub(crate) syntax: SyntaxNode,
2533 unsafe impl TransparentNewType for Pat {
2534 type Repr = rowan::SyntaxNode<RaTypes>;
2537 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2538 pub enum PatKind<'a> {
2540 BindPat(&'a BindPat),
2541 PlaceholderPat(&'a PlaceholderPat),
2542 PathPat(&'a PathPat),
2543 StructPat(&'a StructPat),
2544 TupleStructPat(&'a TupleStructPat),
2545 TuplePat(&'a TuplePat),
2546 SlicePat(&'a SlicePat),
2547 RangePat(&'a RangePat),
2548 LiteralPat(&'a LiteralPat),
2550 impl<'a> From<&'a RefPat> for &'a Pat {
2551 fn from(n: &'a RefPat) -> &'a Pat {
2552 Pat::cast(&n.syntax).unwrap()
2555 impl<'a> From<&'a BindPat> for &'a Pat {
2556 fn from(n: &'a BindPat) -> &'a Pat {
2557 Pat::cast(&n.syntax).unwrap()
2560 impl<'a> From<&'a PlaceholderPat> for &'a Pat {
2561 fn from(n: &'a PlaceholderPat) -> &'a Pat {
2562 Pat::cast(&n.syntax).unwrap()
2565 impl<'a> From<&'a PathPat> for &'a Pat {
2566 fn from(n: &'a PathPat) -> &'a Pat {
2567 Pat::cast(&n.syntax).unwrap()
2570 impl<'a> From<&'a StructPat> for &'a Pat {
2571 fn from(n: &'a StructPat) -> &'a Pat {
2572 Pat::cast(&n.syntax).unwrap()
2575 impl<'a> From<&'a TupleStructPat> for &'a Pat {
2576 fn from(n: &'a TupleStructPat) -> &'a Pat {
2577 Pat::cast(&n.syntax).unwrap()
2580 impl<'a> From<&'a TuplePat> for &'a Pat {
2581 fn from(n: &'a TuplePat) -> &'a Pat {
2582 Pat::cast(&n.syntax).unwrap()
2585 impl<'a> From<&'a SlicePat> for &'a Pat {
2586 fn from(n: &'a SlicePat) -> &'a Pat {
2587 Pat::cast(&n.syntax).unwrap()
2590 impl<'a> From<&'a RangePat> for &'a Pat {
2591 fn from(n: &'a RangePat) -> &'a Pat {
2592 Pat::cast(&n.syntax).unwrap()
2595 impl<'a> From<&'a LiteralPat> for &'a Pat {
2596 fn from(n: &'a LiteralPat) -> &'a Pat {
2597 Pat::cast(&n.syntax).unwrap()
2602 impl AstNode for Pat {
2603 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2604 match syntax.kind() {
2614 | LITERAL_PAT => Some(Pat::from_repr(syntax.into_repr())),
2618 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2621 impl ToOwned for Pat {
2622 type Owned = TreeArc<Pat>;
2623 fn to_owned(&self) -> TreeArc<Pat> { TreeArc::cast(self.syntax.to_owned()) }
2627 pub fn kind(&self) -> PatKind {
2628 match self.syntax.kind() {
2629 REF_PAT => PatKind::RefPat(RefPat::cast(&self.syntax).unwrap()),
2630 BIND_PAT => PatKind::BindPat(BindPat::cast(&self.syntax).unwrap()),
2631 PLACEHOLDER_PAT => PatKind::PlaceholderPat(PlaceholderPat::cast(&self.syntax).unwrap()),
2632 PATH_PAT => PatKind::PathPat(PathPat::cast(&self.syntax).unwrap()),
2633 STRUCT_PAT => PatKind::StructPat(StructPat::cast(&self.syntax).unwrap()),
2634 TUPLE_STRUCT_PAT => PatKind::TupleStructPat(TupleStructPat::cast(&self.syntax).unwrap()),
2635 TUPLE_PAT => PatKind::TuplePat(TuplePat::cast(&self.syntax).unwrap()),
2636 SLICE_PAT => PatKind::SlicePat(SlicePat::cast(&self.syntax).unwrap()),
2637 RANGE_PAT => PatKind::RangePat(RangePat::cast(&self.syntax).unwrap()),
2638 LITERAL_PAT => PatKind::LiteralPat(LiteralPat::cast(&self.syntax).unwrap()),
2639 _ => unreachable!(),
2647 #[derive(Debug, PartialEq, Eq, Hash)]
2648 #[repr(transparent)]
2650 pub(crate) syntax: SyntaxNode,
2652 unsafe impl TransparentNewType for Path {
2653 type Repr = rowan::SyntaxNode<RaTypes>;
2656 impl AstNode for Path {
2657 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2658 match syntax.kind() {
2659 PATH => Some(Path::from_repr(syntax.into_repr())),
2663 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2666 impl ToOwned for Path {
2667 type Owned = TreeArc<Path>;
2668 fn to_owned(&self) -> TreeArc<Path> { TreeArc::cast(self.syntax.to_owned()) }
2673 pub fn segment(&self) -> Option<&PathSegment> {
2674 super::child_opt(self)
2677 pub fn qualifier(&self) -> Option<&Path> {
2678 super::child_opt(self)
2683 #[derive(Debug, PartialEq, Eq, Hash)]
2684 #[repr(transparent)]
2685 pub struct PathExpr {
2686 pub(crate) syntax: SyntaxNode,
2688 unsafe impl TransparentNewType for PathExpr {
2689 type Repr = rowan::SyntaxNode<RaTypes>;
2692 impl AstNode for PathExpr {
2693 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2694 match syntax.kind() {
2695 PATH_EXPR => Some(PathExpr::from_repr(syntax.into_repr())),
2699 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2702 impl ToOwned for PathExpr {
2703 type Owned = TreeArc<PathExpr>;
2704 fn to_owned(&self) -> TreeArc<PathExpr> { TreeArc::cast(self.syntax.to_owned()) }
2709 pub fn path(&self) -> Option<&Path> {
2710 super::child_opt(self)
2715 #[derive(Debug, PartialEq, Eq, Hash)]
2716 #[repr(transparent)]
2717 pub struct PathPat {
2718 pub(crate) syntax: SyntaxNode,
2720 unsafe impl TransparentNewType for PathPat {
2721 type Repr = rowan::SyntaxNode<RaTypes>;
2724 impl AstNode for PathPat {
2725 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2726 match syntax.kind() {
2727 PATH_PAT => Some(PathPat::from_repr(syntax.into_repr())),
2731 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2734 impl ToOwned for PathPat {
2735 type Owned = TreeArc<PathPat>;
2736 fn to_owned(&self) -> TreeArc<PathPat> { TreeArc::cast(self.syntax.to_owned()) }
2741 pub fn path(&self) -> Option<&Path> {
2742 super::child_opt(self)
2747 #[derive(Debug, PartialEq, Eq, Hash)]
2748 #[repr(transparent)]
2749 pub struct PathSegment {
2750 pub(crate) syntax: SyntaxNode,
2752 unsafe impl TransparentNewType for PathSegment {
2753 type Repr = rowan::SyntaxNode<RaTypes>;
2756 impl AstNode for PathSegment {
2757 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2758 match syntax.kind() {
2759 PATH_SEGMENT => Some(PathSegment::from_repr(syntax.into_repr())),
2763 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2766 impl ToOwned for PathSegment {
2767 type Owned = TreeArc<PathSegment>;
2768 fn to_owned(&self) -> TreeArc<PathSegment> { TreeArc::cast(self.syntax.to_owned()) }
2773 pub fn name_ref(&self) -> Option<&NameRef> {
2774 super::child_opt(self)
2777 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
2778 super::child_opt(self)
2783 #[derive(Debug, PartialEq, Eq, Hash)]
2784 #[repr(transparent)]
2785 pub struct PathType {
2786 pub(crate) syntax: SyntaxNode,
2788 unsafe impl TransparentNewType for PathType {
2789 type Repr = rowan::SyntaxNode<RaTypes>;
2792 impl AstNode for PathType {
2793 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2794 match syntax.kind() {
2795 PATH_TYPE => Some(PathType::from_repr(syntax.into_repr())),
2799 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2802 impl ToOwned for PathType {
2803 type Owned = TreeArc<PathType>;
2804 fn to_owned(&self) -> TreeArc<PathType> { TreeArc::cast(self.syntax.to_owned()) }
2809 pub fn path(&self) -> Option<&Path> {
2810 super::child_opt(self)
2815 #[derive(Debug, PartialEq, Eq, Hash)]
2816 #[repr(transparent)]
2817 pub struct PlaceholderPat {
2818 pub(crate) syntax: SyntaxNode,
2820 unsafe impl TransparentNewType for PlaceholderPat {
2821 type Repr = rowan::SyntaxNode<RaTypes>;
2824 impl AstNode for PlaceholderPat {
2825 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2826 match syntax.kind() {
2827 PLACEHOLDER_PAT => Some(PlaceholderPat::from_repr(syntax.into_repr())),
2831 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2834 impl ToOwned for PlaceholderPat {
2835 type Owned = TreeArc<PlaceholderPat>;
2836 fn to_owned(&self) -> TreeArc<PlaceholderPat> { TreeArc::cast(self.syntax.to_owned()) }
2840 impl PlaceholderPat {}
2843 #[derive(Debug, PartialEq, Eq, Hash)]
2844 #[repr(transparent)]
2845 pub struct PlaceholderType {
2846 pub(crate) syntax: SyntaxNode,
2848 unsafe impl TransparentNewType for PlaceholderType {
2849 type Repr = rowan::SyntaxNode<RaTypes>;
2852 impl AstNode for PlaceholderType {
2853 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2854 match syntax.kind() {
2855 PLACEHOLDER_TYPE => Some(PlaceholderType::from_repr(syntax.into_repr())),
2859 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2862 impl ToOwned for PlaceholderType {
2863 type Owned = TreeArc<PlaceholderType>;
2864 fn to_owned(&self) -> TreeArc<PlaceholderType> { TreeArc::cast(self.syntax.to_owned()) }
2868 impl PlaceholderType {}
2871 #[derive(Debug, PartialEq, Eq, Hash)]
2872 #[repr(transparent)]
2873 pub struct PointerType {
2874 pub(crate) syntax: SyntaxNode,
2876 unsafe impl TransparentNewType for PointerType {
2877 type Repr = rowan::SyntaxNode<RaTypes>;
2880 impl AstNode for PointerType {
2881 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2882 match syntax.kind() {
2883 POINTER_TYPE => Some(PointerType::from_repr(syntax.into_repr())),
2887 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2890 impl ToOwned for PointerType {
2891 type Owned = TreeArc<PointerType>;
2892 fn to_owned(&self) -> TreeArc<PointerType> { TreeArc::cast(self.syntax.to_owned()) }
2897 pub fn type_ref(&self) -> Option<&TypeRef> {
2898 super::child_opt(self)
2903 #[derive(Debug, PartialEq, Eq, Hash)]
2904 #[repr(transparent)]
2905 pub struct PosFieldDef {
2906 pub(crate) syntax: SyntaxNode,
2908 unsafe impl TransparentNewType for PosFieldDef {
2909 type Repr = rowan::SyntaxNode<RaTypes>;
2912 impl AstNode for PosFieldDef {
2913 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2914 match syntax.kind() {
2915 POS_FIELD_DEF => Some(PosFieldDef::from_repr(syntax.into_repr())),
2919 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2922 impl ToOwned for PosFieldDef {
2923 type Owned = TreeArc<PosFieldDef>;
2924 fn to_owned(&self) -> TreeArc<PosFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2928 impl ast::VisibilityOwner for PosFieldDef {}
2929 impl ast::AttrsOwner for PosFieldDef {}
2931 pub fn type_ref(&self) -> Option<&TypeRef> {
2932 super::child_opt(self)
2937 #[derive(Debug, PartialEq, Eq, Hash)]
2938 #[repr(transparent)]
2939 pub struct PosFieldDefList {
2940 pub(crate) syntax: SyntaxNode,
2942 unsafe impl TransparentNewType for PosFieldDefList {
2943 type Repr = rowan::SyntaxNode<RaTypes>;
2946 impl AstNode for PosFieldDefList {
2947 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2948 match syntax.kind() {
2949 POS_FIELD_DEF_LIST => Some(PosFieldDefList::from_repr(syntax.into_repr())),
2953 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2956 impl ToOwned for PosFieldDefList {
2957 type Owned = TreeArc<PosFieldDefList>;
2958 fn to_owned(&self) -> TreeArc<PosFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
2962 impl PosFieldDefList {
2963 pub fn fields(&self) -> impl Iterator<Item = &PosFieldDef> {
2964 super::children(self)
2969 #[derive(Debug, PartialEq, Eq, Hash)]
2970 #[repr(transparent)]
2971 pub struct PrefixExpr {
2972 pub(crate) syntax: SyntaxNode,
2974 unsafe impl TransparentNewType for PrefixExpr {
2975 type Repr = rowan::SyntaxNode<RaTypes>;
2978 impl AstNode for PrefixExpr {
2979 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2980 match syntax.kind() {
2981 PREFIX_EXPR => Some(PrefixExpr::from_repr(syntax.into_repr())),
2985 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2988 impl ToOwned for PrefixExpr {
2989 type Owned = TreeArc<PrefixExpr>;
2990 fn to_owned(&self) -> TreeArc<PrefixExpr> { TreeArc::cast(self.syntax.to_owned()) }
2995 pub fn expr(&self) -> Option<&Expr> {
2996 super::child_opt(self)
3001 #[derive(Debug, PartialEq, Eq, Hash)]
3002 #[repr(transparent)]
3003 pub struct RangeExpr {
3004 pub(crate) syntax: SyntaxNode,
3006 unsafe impl TransparentNewType for RangeExpr {
3007 type Repr = rowan::SyntaxNode<RaTypes>;
3010 impl AstNode for RangeExpr {
3011 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3012 match syntax.kind() {
3013 RANGE_EXPR => Some(RangeExpr::from_repr(syntax.into_repr())),
3017 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3020 impl ToOwned for RangeExpr {
3021 type Owned = TreeArc<RangeExpr>;
3022 fn to_owned(&self) -> TreeArc<RangeExpr> { TreeArc::cast(self.syntax.to_owned()) }
3029 #[derive(Debug, PartialEq, Eq, Hash)]
3030 #[repr(transparent)]
3031 pub struct RangePat {
3032 pub(crate) syntax: SyntaxNode,
3034 unsafe impl TransparentNewType for RangePat {
3035 type Repr = rowan::SyntaxNode<RaTypes>;
3038 impl AstNode for RangePat {
3039 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3040 match syntax.kind() {
3041 RANGE_PAT => Some(RangePat::from_repr(syntax.into_repr())),
3045 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3048 impl ToOwned for RangePat {
3049 type Owned = TreeArc<RangePat>;
3050 fn to_owned(&self) -> TreeArc<RangePat> { TreeArc::cast(self.syntax.to_owned()) }
3057 #[derive(Debug, PartialEq, Eq, Hash)]
3058 #[repr(transparent)]
3059 pub struct RefExpr {
3060 pub(crate) syntax: SyntaxNode,
3062 unsafe impl TransparentNewType for RefExpr {
3063 type Repr = rowan::SyntaxNode<RaTypes>;
3066 impl AstNode for RefExpr {
3067 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3068 match syntax.kind() {
3069 REF_EXPR => Some(RefExpr::from_repr(syntax.into_repr())),
3073 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3076 impl ToOwned for RefExpr {
3077 type Owned = TreeArc<RefExpr>;
3078 fn to_owned(&self) -> TreeArc<RefExpr> { TreeArc::cast(self.syntax.to_owned()) }
3083 pub fn expr(&self) -> Option<&Expr> {
3084 super::child_opt(self)
3089 #[derive(Debug, PartialEq, Eq, Hash)]
3090 #[repr(transparent)]
3092 pub(crate) syntax: SyntaxNode,
3094 unsafe impl TransparentNewType for RefPat {
3095 type Repr = rowan::SyntaxNode<RaTypes>;
3098 impl AstNode for RefPat {
3099 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3100 match syntax.kind() {
3101 REF_PAT => Some(RefPat::from_repr(syntax.into_repr())),
3105 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3108 impl ToOwned for RefPat {
3109 type Owned = TreeArc<RefPat>;
3110 fn to_owned(&self) -> TreeArc<RefPat> { TreeArc::cast(self.syntax.to_owned()) }
3115 pub fn pat(&self) -> Option<&Pat> {
3116 super::child_opt(self)
3121 #[derive(Debug, PartialEq, Eq, Hash)]
3122 #[repr(transparent)]
3123 pub struct ReferenceType {
3124 pub(crate) syntax: SyntaxNode,
3126 unsafe impl TransparentNewType for ReferenceType {
3127 type Repr = rowan::SyntaxNode<RaTypes>;
3130 impl AstNode for ReferenceType {
3131 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3132 match syntax.kind() {
3133 REFERENCE_TYPE => Some(ReferenceType::from_repr(syntax.into_repr())),
3137 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3140 impl ToOwned for ReferenceType {
3141 type Owned = TreeArc<ReferenceType>;
3142 fn to_owned(&self) -> TreeArc<ReferenceType> { TreeArc::cast(self.syntax.to_owned()) }
3146 impl ReferenceType {
3147 pub fn type_ref(&self) -> Option<&TypeRef> {
3148 super::child_opt(self)
3153 #[derive(Debug, PartialEq, Eq, Hash)]
3154 #[repr(transparent)]
3155 pub struct RetType {
3156 pub(crate) syntax: SyntaxNode,
3158 unsafe impl TransparentNewType for RetType {
3159 type Repr = rowan::SyntaxNode<RaTypes>;
3162 impl AstNode for RetType {
3163 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3164 match syntax.kind() {
3165 RET_TYPE => Some(RetType::from_repr(syntax.into_repr())),
3169 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3172 impl ToOwned for RetType {
3173 type Owned = TreeArc<RetType>;
3174 fn to_owned(&self) -> TreeArc<RetType> { TreeArc::cast(self.syntax.to_owned()) }
3179 pub fn type_ref(&self) -> Option<&TypeRef> {
3180 super::child_opt(self)
3185 #[derive(Debug, PartialEq, Eq, Hash)]
3186 #[repr(transparent)]
3187 pub struct ReturnExpr {
3188 pub(crate) syntax: SyntaxNode,
3190 unsafe impl TransparentNewType for ReturnExpr {
3191 type Repr = rowan::SyntaxNode<RaTypes>;
3194 impl AstNode for ReturnExpr {
3195 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3196 match syntax.kind() {
3197 RETURN_EXPR => Some(ReturnExpr::from_repr(syntax.into_repr())),
3201 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3204 impl ToOwned for ReturnExpr {
3205 type Owned = TreeArc<ReturnExpr>;
3206 fn to_owned(&self) -> TreeArc<ReturnExpr> { TreeArc::cast(self.syntax.to_owned()) }
3211 pub fn expr(&self) -> Option<&Expr> {
3212 super::child_opt(self)
3217 #[derive(Debug, PartialEq, Eq, Hash)]
3218 #[repr(transparent)]
3219 pub struct SelfParam {
3220 pub(crate) syntax: SyntaxNode,
3222 unsafe impl TransparentNewType for SelfParam {
3223 type Repr = rowan::SyntaxNode<RaTypes>;
3226 impl AstNode for SelfParam {
3227 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3228 match syntax.kind() {
3229 SELF_PARAM => Some(SelfParam::from_repr(syntax.into_repr())),
3233 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3236 impl ToOwned for SelfParam {
3237 type Owned = TreeArc<SelfParam>;
3238 fn to_owned(&self) -> TreeArc<SelfParam> { TreeArc::cast(self.syntax.to_owned()) }
3242 impl ast::TypeAscriptionOwner for SelfParam {}
3246 #[derive(Debug, PartialEq, Eq, Hash)]
3247 #[repr(transparent)]
3248 pub struct SlicePat {
3249 pub(crate) syntax: SyntaxNode,
3251 unsafe impl TransparentNewType for SlicePat {
3252 type Repr = rowan::SyntaxNode<RaTypes>;
3255 impl AstNode for SlicePat {
3256 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3257 match syntax.kind() {
3258 SLICE_PAT => Some(SlicePat::from_repr(syntax.into_repr())),
3262 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3265 impl ToOwned for SlicePat {
3266 type Owned = TreeArc<SlicePat>;
3267 fn to_owned(&self) -> TreeArc<SlicePat> { TreeArc::cast(self.syntax.to_owned()) }
3274 #[derive(Debug, PartialEq, Eq, Hash)]
3275 #[repr(transparent)]
3276 pub struct SliceType {
3277 pub(crate) syntax: SyntaxNode,
3279 unsafe impl TransparentNewType for SliceType {
3280 type Repr = rowan::SyntaxNode<RaTypes>;
3283 impl AstNode for SliceType {
3284 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3285 match syntax.kind() {
3286 SLICE_TYPE => Some(SliceType::from_repr(syntax.into_repr())),
3290 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3293 impl ToOwned for SliceType {
3294 type Owned = TreeArc<SliceType>;
3295 fn to_owned(&self) -> TreeArc<SliceType> { TreeArc::cast(self.syntax.to_owned()) }
3300 pub fn type_ref(&self) -> Option<&TypeRef> {
3301 super::child_opt(self)
3306 #[derive(Debug, PartialEq, Eq, Hash)]
3307 #[repr(transparent)]
3308 pub struct SourceFile {
3309 pub(crate) syntax: SyntaxNode,
3311 unsafe impl TransparentNewType for SourceFile {
3312 type Repr = rowan::SyntaxNode<RaTypes>;
3315 impl AstNode for SourceFile {
3316 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3317 match syntax.kind() {
3318 SOURCE_FILE => Some(SourceFile::from_repr(syntax.into_repr())),
3322 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3325 impl ToOwned for SourceFile {
3326 type Owned = TreeArc<SourceFile>;
3327 fn to_owned(&self) -> TreeArc<SourceFile> { TreeArc::cast(self.syntax.to_owned()) }
3331 impl ast::ModuleItemOwner for SourceFile {}
3332 impl ast::FnDefOwner for SourceFile {}
3334 pub fn modules(&self) -> impl Iterator<Item = &Module> {
3335 super::children(self)
3340 #[derive(Debug, PartialEq, Eq, Hash)]
3341 #[repr(transparent)]
3342 pub struct StaticDef {
3343 pub(crate) syntax: SyntaxNode,
3345 unsafe impl TransparentNewType for StaticDef {
3346 type Repr = rowan::SyntaxNode<RaTypes>;
3349 impl AstNode for StaticDef {
3350 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3351 match syntax.kind() {
3352 STATIC_DEF => Some(StaticDef::from_repr(syntax.into_repr())),
3356 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3359 impl ToOwned for StaticDef {
3360 type Owned = TreeArc<StaticDef>;
3361 fn to_owned(&self) -> TreeArc<StaticDef> { TreeArc::cast(self.syntax.to_owned()) }
3365 impl ast::VisibilityOwner for StaticDef {}
3366 impl ast::NameOwner for StaticDef {}
3367 impl ast::TypeParamsOwner for StaticDef {}
3368 impl ast::AttrsOwner for StaticDef {}
3369 impl ast::DocCommentsOwner for StaticDef {}
3370 impl ast::TypeAscriptionOwner for StaticDef {}
3372 pub fn body(&self) -> Option<&Expr> {
3373 super::child_opt(self)
3378 #[derive(Debug, PartialEq, Eq, Hash)]
3379 #[repr(transparent)]
3381 pub(crate) syntax: SyntaxNode,
3383 unsafe impl TransparentNewType for Stmt {
3384 type Repr = rowan::SyntaxNode<RaTypes>;
3387 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3388 pub enum StmtKind<'a> {
3389 ExprStmt(&'a ExprStmt),
3390 LetStmt(&'a LetStmt),
3392 impl<'a> From<&'a ExprStmt> for &'a Stmt {
3393 fn from(n: &'a ExprStmt) -> &'a Stmt {
3394 Stmt::cast(&n.syntax).unwrap()
3397 impl<'a> From<&'a LetStmt> for &'a Stmt {
3398 fn from(n: &'a LetStmt) -> &'a Stmt {
3399 Stmt::cast(&n.syntax).unwrap()
3404 impl AstNode for Stmt {
3405 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3406 match syntax.kind() {
3408 | LET_STMT => Some(Stmt::from_repr(syntax.into_repr())),
3412 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3415 impl ToOwned for Stmt {
3416 type Owned = TreeArc<Stmt>;
3417 fn to_owned(&self) -> TreeArc<Stmt> { TreeArc::cast(self.syntax.to_owned()) }
3421 pub fn kind(&self) -> StmtKind {
3422 match self.syntax.kind() {
3423 EXPR_STMT => StmtKind::ExprStmt(ExprStmt::cast(&self.syntax).unwrap()),
3424 LET_STMT => StmtKind::LetStmt(LetStmt::cast(&self.syntax).unwrap()),
3425 _ => unreachable!(),
3433 #[derive(Debug, PartialEq, Eq, Hash)]
3434 #[repr(transparent)]
3435 pub struct StructDef {
3436 pub(crate) syntax: SyntaxNode,
3438 unsafe impl TransparentNewType for StructDef {
3439 type Repr = rowan::SyntaxNode<RaTypes>;
3442 impl AstNode for StructDef {
3443 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3444 match syntax.kind() {
3445 STRUCT_DEF => Some(StructDef::from_repr(syntax.into_repr())),
3449 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3452 impl ToOwned for StructDef {
3453 type Owned = TreeArc<StructDef>;
3454 fn to_owned(&self) -> TreeArc<StructDef> { TreeArc::cast(self.syntax.to_owned()) }
3458 impl ast::VisibilityOwner for StructDef {}
3459 impl ast::NameOwner for StructDef {}
3460 impl ast::TypeParamsOwner for StructDef {}
3461 impl ast::AttrsOwner for StructDef {}
3462 impl ast::DocCommentsOwner for StructDef {}
3466 #[derive(Debug, PartialEq, Eq, Hash)]
3467 #[repr(transparent)]
3468 pub struct StructLit {
3469 pub(crate) syntax: SyntaxNode,
3471 unsafe impl TransparentNewType for StructLit {
3472 type Repr = rowan::SyntaxNode<RaTypes>;
3475 impl AstNode for StructLit {
3476 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3477 match syntax.kind() {
3478 STRUCT_LIT => Some(StructLit::from_repr(syntax.into_repr())),
3482 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3485 impl ToOwned for StructLit {
3486 type Owned = TreeArc<StructLit>;
3487 fn to_owned(&self) -> TreeArc<StructLit> { TreeArc::cast(self.syntax.to_owned()) }
3492 pub fn path(&self) -> Option<&Path> {
3493 super::child_opt(self)
3496 pub fn named_field_list(&self) -> Option<&NamedFieldList> {
3497 super::child_opt(self)
3500 pub fn spread(&self) -> Option<&Expr> {
3501 super::child_opt(self)
3506 #[derive(Debug, PartialEq, Eq, Hash)]
3507 #[repr(transparent)]
3508 pub struct StructPat {
3509 pub(crate) syntax: SyntaxNode,
3511 unsafe impl TransparentNewType for StructPat {
3512 type Repr = rowan::SyntaxNode<RaTypes>;
3515 impl AstNode for StructPat {
3516 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3517 match syntax.kind() {
3518 STRUCT_PAT => Some(StructPat::from_repr(syntax.into_repr())),
3522 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3525 impl ToOwned for StructPat {
3526 type Owned = TreeArc<StructPat>;
3527 fn to_owned(&self) -> TreeArc<StructPat> { TreeArc::cast(self.syntax.to_owned()) }
3532 pub fn field_pat_list(&self) -> Option<&FieldPatList> {
3533 super::child_opt(self)
3536 pub fn path(&self) -> Option<&Path> {
3537 super::child_opt(self)
3542 #[derive(Debug, PartialEq, Eq, Hash)]
3543 #[repr(transparent)]
3544 pub struct TokenTree {
3545 pub(crate) syntax: SyntaxNode,
3547 unsafe impl TransparentNewType for TokenTree {
3548 type Repr = rowan::SyntaxNode<RaTypes>;
3551 impl AstNode for TokenTree {
3552 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3553 match syntax.kind() {
3554 TOKEN_TREE => Some(TokenTree::from_repr(syntax.into_repr())),
3558 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3561 impl ToOwned for TokenTree {
3562 type Owned = TreeArc<TokenTree>;
3563 fn to_owned(&self) -> TreeArc<TokenTree> { TreeArc::cast(self.syntax.to_owned()) }
3570 #[derive(Debug, PartialEq, Eq, Hash)]
3571 #[repr(transparent)]
3572 pub struct TraitDef {
3573 pub(crate) syntax: SyntaxNode,
3575 unsafe impl TransparentNewType for TraitDef {
3576 type Repr = rowan::SyntaxNode<RaTypes>;
3579 impl AstNode for TraitDef {
3580 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3581 match syntax.kind() {
3582 TRAIT_DEF => Some(TraitDef::from_repr(syntax.into_repr())),
3586 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3589 impl ToOwned for TraitDef {
3590 type Owned = TreeArc<TraitDef>;
3591 fn to_owned(&self) -> TreeArc<TraitDef> { TreeArc::cast(self.syntax.to_owned()) }
3595 impl ast::VisibilityOwner for TraitDef {}
3596 impl ast::NameOwner for TraitDef {}
3597 impl ast::AttrsOwner for TraitDef {}
3598 impl ast::DocCommentsOwner for TraitDef {}
3599 impl ast::TypeParamsOwner for TraitDef {}
3600 impl ast::TypeBoundsOwner for TraitDef {}
3602 pub fn item_list(&self) -> Option<&ItemList> {
3603 super::child_opt(self)
3608 #[derive(Debug, PartialEq, Eq, Hash)]
3609 #[repr(transparent)]
3610 pub struct TryExpr {
3611 pub(crate) syntax: SyntaxNode,
3613 unsafe impl TransparentNewType for TryExpr {
3614 type Repr = rowan::SyntaxNode<RaTypes>;
3617 impl AstNode for TryExpr {
3618 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3619 match syntax.kind() {
3620 TRY_EXPR => Some(TryExpr::from_repr(syntax.into_repr())),
3624 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3627 impl ToOwned for TryExpr {
3628 type Owned = TreeArc<TryExpr>;
3629 fn to_owned(&self) -> TreeArc<TryExpr> { TreeArc::cast(self.syntax.to_owned()) }
3634 pub fn expr(&self) -> Option<&Expr> {
3635 super::child_opt(self)
3640 #[derive(Debug, PartialEq, Eq, Hash)]
3641 #[repr(transparent)]
3642 pub struct TupleExpr {
3643 pub(crate) syntax: SyntaxNode,
3645 unsafe impl TransparentNewType for TupleExpr {
3646 type Repr = rowan::SyntaxNode<RaTypes>;
3649 impl AstNode for TupleExpr {
3650 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3651 match syntax.kind() {
3652 TUPLE_EXPR => Some(TupleExpr::from_repr(syntax.into_repr())),
3656 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3659 impl ToOwned for TupleExpr {
3660 type Owned = TreeArc<TupleExpr>;
3661 fn to_owned(&self) -> TreeArc<TupleExpr> { TreeArc::cast(self.syntax.to_owned()) }
3666 pub fn exprs(&self) -> impl Iterator<Item = &Expr> {
3667 super::children(self)
3672 #[derive(Debug, PartialEq, Eq, Hash)]
3673 #[repr(transparent)]
3674 pub struct TuplePat {
3675 pub(crate) syntax: SyntaxNode,
3677 unsafe impl TransparentNewType for TuplePat {
3678 type Repr = rowan::SyntaxNode<RaTypes>;
3681 impl AstNode for TuplePat {
3682 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3683 match syntax.kind() {
3684 TUPLE_PAT => Some(TuplePat::from_repr(syntax.into_repr())),
3688 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3691 impl ToOwned for TuplePat {
3692 type Owned = TreeArc<TuplePat>;
3693 fn to_owned(&self) -> TreeArc<TuplePat> { TreeArc::cast(self.syntax.to_owned()) }
3698 pub fn args(&self) -> impl Iterator<Item = &Pat> {
3699 super::children(self)
3704 #[derive(Debug, PartialEq, Eq, Hash)]
3705 #[repr(transparent)]
3706 pub struct TupleStructPat {
3707 pub(crate) syntax: SyntaxNode,
3709 unsafe impl TransparentNewType for TupleStructPat {
3710 type Repr = rowan::SyntaxNode<RaTypes>;
3713 impl AstNode for TupleStructPat {
3714 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3715 match syntax.kind() {
3716 TUPLE_STRUCT_PAT => Some(TupleStructPat::from_repr(syntax.into_repr())),
3720 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3723 impl ToOwned for TupleStructPat {
3724 type Owned = TreeArc<TupleStructPat>;
3725 fn to_owned(&self) -> TreeArc<TupleStructPat> { TreeArc::cast(self.syntax.to_owned()) }
3729 impl TupleStructPat {
3730 pub fn args(&self) -> impl Iterator<Item = &Pat> {
3731 super::children(self)
3734 pub fn path(&self) -> Option<&Path> {
3735 super::child_opt(self)
3740 #[derive(Debug, PartialEq, Eq, Hash)]
3741 #[repr(transparent)]
3742 pub struct TupleType {
3743 pub(crate) syntax: SyntaxNode,
3745 unsafe impl TransparentNewType for TupleType {
3746 type Repr = rowan::SyntaxNode<RaTypes>;
3749 impl AstNode for TupleType {
3750 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3751 match syntax.kind() {
3752 TUPLE_TYPE => Some(TupleType::from_repr(syntax.into_repr())),
3756 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3759 impl ToOwned for TupleType {
3760 type Owned = TreeArc<TupleType>;
3761 fn to_owned(&self) -> TreeArc<TupleType> { TreeArc::cast(self.syntax.to_owned()) }
3766 pub fn fields(&self) -> impl Iterator<Item = &TypeRef> {
3767 super::children(self)
3772 #[derive(Debug, PartialEq, Eq, Hash)]
3773 #[repr(transparent)]
3774 pub struct TypeAliasDef {
3775 pub(crate) syntax: SyntaxNode,
3777 unsafe impl TransparentNewType for TypeAliasDef {
3778 type Repr = rowan::SyntaxNode<RaTypes>;
3781 impl AstNode for TypeAliasDef {
3782 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3783 match syntax.kind() {
3784 TYPE_ALIAS_DEF => Some(TypeAliasDef::from_repr(syntax.into_repr())),
3788 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3791 impl ToOwned for TypeAliasDef {
3792 type Owned = TreeArc<TypeAliasDef>;
3793 fn to_owned(&self) -> TreeArc<TypeAliasDef> { TreeArc::cast(self.syntax.to_owned()) }
3797 impl ast::VisibilityOwner for TypeAliasDef {}
3798 impl ast::NameOwner for TypeAliasDef {}
3799 impl ast::TypeParamsOwner for TypeAliasDef {}
3800 impl ast::AttrsOwner for TypeAliasDef {}
3801 impl ast::DocCommentsOwner for TypeAliasDef {}
3802 impl ast::TypeBoundsOwner for TypeAliasDef {}
3804 pub fn type_ref(&self) -> Option<&TypeRef> {
3805 super::child_opt(self)
3810 #[derive(Debug, PartialEq, Eq, Hash)]
3811 #[repr(transparent)]
3812 pub struct TypeArg {
3813 pub(crate) syntax: SyntaxNode,
3815 unsafe impl TransparentNewType for TypeArg {
3816 type Repr = rowan::SyntaxNode<RaTypes>;
3819 impl AstNode for TypeArg {
3820 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3821 match syntax.kind() {
3822 TYPE_ARG => Some(TypeArg::from_repr(syntax.into_repr())),
3826 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3829 impl ToOwned for TypeArg {
3830 type Owned = TreeArc<TypeArg>;
3831 fn to_owned(&self) -> TreeArc<TypeArg> { TreeArc::cast(self.syntax.to_owned()) }
3836 pub fn type_ref(&self) -> Option<&TypeRef> {
3837 super::child_opt(self)
3842 #[derive(Debug, PartialEq, Eq, Hash)]
3843 #[repr(transparent)]
3844 pub struct TypeArgList {
3845 pub(crate) syntax: SyntaxNode,
3847 unsafe impl TransparentNewType for TypeArgList {
3848 type Repr = rowan::SyntaxNode<RaTypes>;
3851 impl AstNode for TypeArgList {
3852 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3853 match syntax.kind() {
3854 TYPE_ARG_LIST => Some(TypeArgList::from_repr(syntax.into_repr())),
3858 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3861 impl ToOwned for TypeArgList {
3862 type Owned = TreeArc<TypeArgList>;
3863 fn to_owned(&self) -> TreeArc<TypeArgList> { TreeArc::cast(self.syntax.to_owned()) }
3868 pub fn type_args(&self) -> impl Iterator<Item = &TypeArg> {
3869 super::children(self)
3872 pub fn lifetime_args(&self) -> impl Iterator<Item = &LifetimeArg> {
3873 super::children(self)
3876 pub fn assoc_type_args(&self) -> impl Iterator<Item = &AssocTypeArg> {
3877 super::children(self)
3882 #[derive(Debug, PartialEq, Eq, Hash)]
3883 #[repr(transparent)]
3884 pub struct TypeBound {
3885 pub(crate) syntax: SyntaxNode,
3887 unsafe impl TransparentNewType for TypeBound {
3888 type Repr = rowan::SyntaxNode<RaTypes>;
3891 impl AstNode for TypeBound {
3892 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3893 match syntax.kind() {
3894 TYPE_BOUND => Some(TypeBound::from_repr(syntax.into_repr())),
3898 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3901 impl ToOwned for TypeBound {
3902 type Owned = TreeArc<TypeBound>;
3903 fn to_owned(&self) -> TreeArc<TypeBound> { TreeArc::cast(self.syntax.to_owned()) }
3908 pub fn type_ref(&self) -> Option<&TypeRef> {
3909 super::child_opt(self)
3914 #[derive(Debug, PartialEq, Eq, Hash)]
3915 #[repr(transparent)]
3916 pub struct TypeBoundList {
3917 pub(crate) syntax: SyntaxNode,
3919 unsafe impl TransparentNewType for TypeBoundList {
3920 type Repr = rowan::SyntaxNode<RaTypes>;
3923 impl AstNode for TypeBoundList {
3924 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3925 match syntax.kind() {
3926 TYPE_BOUND_LIST => Some(TypeBoundList::from_repr(syntax.into_repr())),
3930 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3933 impl ToOwned for TypeBoundList {
3934 type Owned = TreeArc<TypeBoundList>;
3935 fn to_owned(&self) -> TreeArc<TypeBoundList> { TreeArc::cast(self.syntax.to_owned()) }
3939 impl TypeBoundList {
3940 pub fn bounds(&self) -> impl Iterator<Item = &TypeBound> {
3941 super::children(self)
3946 #[derive(Debug, PartialEq, Eq, Hash)]
3947 #[repr(transparent)]
3948 pub struct TypeParam {
3949 pub(crate) syntax: SyntaxNode,
3951 unsafe impl TransparentNewType for TypeParam {
3952 type Repr = rowan::SyntaxNode<RaTypes>;
3955 impl AstNode for TypeParam {
3956 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3957 match syntax.kind() {
3958 TYPE_PARAM => Some(TypeParam::from_repr(syntax.into_repr())),
3962 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3965 impl ToOwned for TypeParam {
3966 type Owned = TreeArc<TypeParam>;
3967 fn to_owned(&self) -> TreeArc<TypeParam> { TreeArc::cast(self.syntax.to_owned()) }
3971 impl ast::NameOwner for TypeParam {}
3972 impl ast::AttrsOwner for TypeParam {}
3973 impl ast::TypeBoundsOwner for TypeParam {}
3977 #[derive(Debug, PartialEq, Eq, Hash)]
3978 #[repr(transparent)]
3979 pub struct TypeParamList {
3980 pub(crate) syntax: SyntaxNode,
3982 unsafe impl TransparentNewType for TypeParamList {
3983 type Repr = rowan::SyntaxNode<RaTypes>;
3986 impl AstNode for TypeParamList {
3987 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3988 match syntax.kind() {
3989 TYPE_PARAM_LIST => Some(TypeParamList::from_repr(syntax.into_repr())),
3993 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3996 impl ToOwned for TypeParamList {
3997 type Owned = TreeArc<TypeParamList>;
3998 fn to_owned(&self) -> TreeArc<TypeParamList> { TreeArc::cast(self.syntax.to_owned()) }
4002 impl TypeParamList {
4003 pub fn type_params(&self) -> impl Iterator<Item = &TypeParam> {
4004 super::children(self)
4007 pub fn lifetime_params(&self) -> impl Iterator<Item = &LifetimeParam> {
4008 super::children(self)
4013 #[derive(Debug, PartialEq, Eq, Hash)]
4014 #[repr(transparent)]
4015 pub struct TypeRef {
4016 pub(crate) syntax: SyntaxNode,
4018 unsafe impl TransparentNewType for TypeRef {
4019 type Repr = rowan::SyntaxNode<RaTypes>;
4022 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4023 pub enum TypeRefKind<'a> {
4024 ParenType(&'a ParenType),
4025 TupleType(&'a TupleType),
4026 NeverType(&'a NeverType),
4027 PathType(&'a PathType),
4028 PointerType(&'a PointerType),
4029 ArrayType(&'a ArrayType),
4030 SliceType(&'a SliceType),
4031 ReferenceType(&'a ReferenceType),
4032 PlaceholderType(&'a PlaceholderType),
4033 FnPointerType(&'a FnPointerType),
4034 ForType(&'a ForType),
4035 ImplTraitType(&'a ImplTraitType),
4036 DynTraitType(&'a DynTraitType),
4038 impl<'a> From<&'a ParenType> for &'a TypeRef {
4039 fn from(n: &'a ParenType) -> &'a TypeRef {
4040 TypeRef::cast(&n.syntax).unwrap()
4043 impl<'a> From<&'a TupleType> for &'a TypeRef {
4044 fn from(n: &'a TupleType) -> &'a TypeRef {
4045 TypeRef::cast(&n.syntax).unwrap()
4048 impl<'a> From<&'a NeverType> for &'a TypeRef {
4049 fn from(n: &'a NeverType) -> &'a TypeRef {
4050 TypeRef::cast(&n.syntax).unwrap()
4053 impl<'a> From<&'a PathType> for &'a TypeRef {
4054 fn from(n: &'a PathType) -> &'a TypeRef {
4055 TypeRef::cast(&n.syntax).unwrap()
4058 impl<'a> From<&'a PointerType> for &'a TypeRef {
4059 fn from(n: &'a PointerType) -> &'a TypeRef {
4060 TypeRef::cast(&n.syntax).unwrap()
4063 impl<'a> From<&'a ArrayType> for &'a TypeRef {
4064 fn from(n: &'a ArrayType) -> &'a TypeRef {
4065 TypeRef::cast(&n.syntax).unwrap()
4068 impl<'a> From<&'a SliceType> for &'a TypeRef {
4069 fn from(n: &'a SliceType) -> &'a TypeRef {
4070 TypeRef::cast(&n.syntax).unwrap()
4073 impl<'a> From<&'a ReferenceType> for &'a TypeRef {
4074 fn from(n: &'a ReferenceType) -> &'a TypeRef {
4075 TypeRef::cast(&n.syntax).unwrap()
4078 impl<'a> From<&'a PlaceholderType> for &'a TypeRef {
4079 fn from(n: &'a PlaceholderType) -> &'a TypeRef {
4080 TypeRef::cast(&n.syntax).unwrap()
4083 impl<'a> From<&'a FnPointerType> for &'a TypeRef {
4084 fn from(n: &'a FnPointerType) -> &'a TypeRef {
4085 TypeRef::cast(&n.syntax).unwrap()
4088 impl<'a> From<&'a ForType> for &'a TypeRef {
4089 fn from(n: &'a ForType) -> &'a TypeRef {
4090 TypeRef::cast(&n.syntax).unwrap()
4093 impl<'a> From<&'a ImplTraitType> for &'a TypeRef {
4094 fn from(n: &'a ImplTraitType) -> &'a TypeRef {
4095 TypeRef::cast(&n.syntax).unwrap()
4098 impl<'a> From<&'a DynTraitType> for &'a TypeRef {
4099 fn from(n: &'a DynTraitType) -> &'a TypeRef {
4100 TypeRef::cast(&n.syntax).unwrap()
4105 impl AstNode for TypeRef {
4106 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4107 match syntax.kind() {
4120 | DYN_TRAIT_TYPE => Some(TypeRef::from_repr(syntax.into_repr())),
4124 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4127 impl ToOwned for TypeRef {
4128 type Owned = TreeArc<TypeRef>;
4129 fn to_owned(&self) -> TreeArc<TypeRef> { TreeArc::cast(self.syntax.to_owned()) }
4133 pub fn kind(&self) -> TypeRefKind {
4134 match self.syntax.kind() {
4135 PAREN_TYPE => TypeRefKind::ParenType(ParenType::cast(&self.syntax).unwrap()),
4136 TUPLE_TYPE => TypeRefKind::TupleType(TupleType::cast(&self.syntax).unwrap()),
4137 NEVER_TYPE => TypeRefKind::NeverType(NeverType::cast(&self.syntax).unwrap()),
4138 PATH_TYPE => TypeRefKind::PathType(PathType::cast(&self.syntax).unwrap()),
4139 POINTER_TYPE => TypeRefKind::PointerType(PointerType::cast(&self.syntax).unwrap()),
4140 ARRAY_TYPE => TypeRefKind::ArrayType(ArrayType::cast(&self.syntax).unwrap()),
4141 SLICE_TYPE => TypeRefKind::SliceType(SliceType::cast(&self.syntax).unwrap()),
4142 REFERENCE_TYPE => TypeRefKind::ReferenceType(ReferenceType::cast(&self.syntax).unwrap()),
4143 PLACEHOLDER_TYPE => TypeRefKind::PlaceholderType(PlaceholderType::cast(&self.syntax).unwrap()),
4144 FN_POINTER_TYPE => TypeRefKind::FnPointerType(FnPointerType::cast(&self.syntax).unwrap()),
4145 FOR_TYPE => TypeRefKind::ForType(ForType::cast(&self.syntax).unwrap()),
4146 IMPL_TRAIT_TYPE => TypeRefKind::ImplTraitType(ImplTraitType::cast(&self.syntax).unwrap()),
4147 DYN_TRAIT_TYPE => TypeRefKind::DynTraitType(DynTraitType::cast(&self.syntax).unwrap()),
4148 _ => unreachable!(),
4156 #[derive(Debug, PartialEq, Eq, Hash)]
4157 #[repr(transparent)]
4158 pub struct UseItem {
4159 pub(crate) syntax: SyntaxNode,
4161 unsafe impl TransparentNewType for UseItem {
4162 type Repr = rowan::SyntaxNode<RaTypes>;
4165 impl AstNode for UseItem {
4166 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4167 match syntax.kind() {
4168 USE_ITEM => Some(UseItem::from_repr(syntax.into_repr())),
4172 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4175 impl ToOwned for UseItem {
4176 type Owned = TreeArc<UseItem>;
4177 fn to_owned(&self) -> TreeArc<UseItem> { TreeArc::cast(self.syntax.to_owned()) }
4181 impl ast::AttrsOwner for UseItem {}
4183 pub fn use_tree(&self) -> Option<&UseTree> {
4184 super::child_opt(self)
4189 #[derive(Debug, PartialEq, Eq, Hash)]
4190 #[repr(transparent)]
4191 pub struct UseTree {
4192 pub(crate) syntax: SyntaxNode,
4194 unsafe impl TransparentNewType for UseTree {
4195 type Repr = rowan::SyntaxNode<RaTypes>;
4198 impl AstNode for UseTree {
4199 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4200 match syntax.kind() {
4201 USE_TREE => Some(UseTree::from_repr(syntax.into_repr())),
4205 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4208 impl ToOwned for UseTree {
4209 type Owned = TreeArc<UseTree>;
4210 fn to_owned(&self) -> TreeArc<UseTree> { TreeArc::cast(self.syntax.to_owned()) }
4215 pub fn path(&self) -> Option<&Path> {
4216 super::child_opt(self)
4219 pub fn use_tree_list(&self) -> Option<&UseTreeList> {
4220 super::child_opt(self)
4223 pub fn alias(&self) -> Option<&Alias> {
4224 super::child_opt(self)
4229 #[derive(Debug, PartialEq, Eq, Hash)]
4230 #[repr(transparent)]
4231 pub struct UseTreeList {
4232 pub(crate) syntax: SyntaxNode,
4234 unsafe impl TransparentNewType for UseTreeList {
4235 type Repr = rowan::SyntaxNode<RaTypes>;
4238 impl AstNode for UseTreeList {
4239 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4240 match syntax.kind() {
4241 USE_TREE_LIST => Some(UseTreeList::from_repr(syntax.into_repr())),
4245 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4248 impl ToOwned for UseTreeList {
4249 type Owned = TreeArc<UseTreeList>;
4250 fn to_owned(&self) -> TreeArc<UseTreeList> { TreeArc::cast(self.syntax.to_owned()) }
4255 pub fn use_trees(&self) -> impl Iterator<Item = &UseTree> {
4256 super::children(self)
4261 #[derive(Debug, PartialEq, Eq, Hash)]
4262 #[repr(transparent)]
4263 pub struct Visibility {
4264 pub(crate) syntax: SyntaxNode,
4266 unsafe impl TransparentNewType for Visibility {
4267 type Repr = rowan::SyntaxNode<RaTypes>;
4270 impl AstNode for Visibility {
4271 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4272 match syntax.kind() {
4273 VISIBILITY => Some(Visibility::from_repr(syntax.into_repr())),
4277 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4280 impl ToOwned for Visibility {
4281 type Owned = TreeArc<Visibility>;
4282 fn to_owned(&self) -> TreeArc<Visibility> { TreeArc::cast(self.syntax.to_owned()) }
4289 #[derive(Debug, PartialEq, Eq, Hash)]
4290 #[repr(transparent)]
4291 pub struct WhereClause {
4292 pub(crate) syntax: SyntaxNode,
4294 unsafe impl TransparentNewType for WhereClause {
4295 type Repr = rowan::SyntaxNode<RaTypes>;
4298 impl AstNode for WhereClause {
4299 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4300 match syntax.kind() {
4301 WHERE_CLAUSE => Some(WhereClause::from_repr(syntax.into_repr())),
4305 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4308 impl ToOwned for WhereClause {
4309 type Owned = TreeArc<WhereClause>;
4310 fn to_owned(&self) -> TreeArc<WhereClause> { TreeArc::cast(self.syntax.to_owned()) }
4315 pub fn predicates(&self) -> impl Iterator<Item = &WherePred> {
4316 super::children(self)
4321 #[derive(Debug, PartialEq, Eq, Hash)]
4322 #[repr(transparent)]
4323 pub struct WherePred {
4324 pub(crate) syntax: SyntaxNode,
4326 unsafe impl TransparentNewType for WherePred {
4327 type Repr = rowan::SyntaxNode<RaTypes>;
4330 impl AstNode for WherePred {
4331 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4332 match syntax.kind() {
4333 WHERE_PRED => Some(WherePred::from_repr(syntax.into_repr())),
4337 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4340 impl ToOwned for WherePred {
4341 type Owned = TreeArc<WherePred>;
4342 fn to_owned(&self) -> TreeArc<WherePred> { TreeArc::cast(self.syntax.to_owned()) }
4346 impl ast::TypeBoundsOwner for WherePred {}
4348 pub fn type_ref(&self) -> Option<&TypeRef> {
4349 super::child_opt(self)
4354 #[derive(Debug, PartialEq, Eq, Hash)]
4355 #[repr(transparent)]
4356 pub struct WhileExpr {
4357 pub(crate) syntax: SyntaxNode,
4359 unsafe impl TransparentNewType for WhileExpr {
4360 type Repr = rowan::SyntaxNode<RaTypes>;
4363 impl AstNode for WhileExpr {
4364 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4365 match syntax.kind() {
4366 WHILE_EXPR => Some(WhileExpr::from_repr(syntax.into_repr())),
4370 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4373 impl ToOwned for WhileExpr {
4374 type Owned = TreeArc<WhileExpr>;
4375 fn to_owned(&self) -> TreeArc<WhileExpr> { TreeArc::cast(self.syntax.to_owned()) }
4379 impl ast::LoopBodyOwner for WhileExpr {}
4381 pub fn condition(&self) -> Option<&Condition> {
4382 super::child_opt(self)