1 // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run
2 // Do not edit manually
4 //! This module contains auto-generated Rust AST. Like `SyntaxNode`s, AST nodes
5 //! are generic over ownership: `X<'a>` things are `Copy` references, `XNode`
6 //! are Arc-based. You can switch between the two variants using `.owned` and
7 //! `.borrowed` functions. Most of the code works with borowed mode, and only
8 //! this mode has all AST accessors.
10 #![cfg_attr(rustfmt, rustfmt_skip)]
12 use rowan::TransparentNewType;
15 SyntaxNode, SyntaxKind::*,
16 syntax_node::{RaTypes, TreeArc},
21 #[derive(Debug, PartialEq, Eq, Hash)]
24 pub(crate) syntax: SyntaxNode,
26 unsafe impl TransparentNewType for Alias {
27 type Repr = rowan::SyntaxNode<RaTypes>;
30 impl AstNode for Alias {
31 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
33 ALIAS => Some(Alias::from_repr(syntax.into_repr())),
37 fn syntax(&self) -> &SyntaxNode { &self.syntax }
40 impl ToOwned for Alias {
41 type Owned = TreeArc<Alias>;
42 fn to_owned(&self) -> TreeArc<Alias> { TreeArc::cast(self.syntax.to_owned()) }
46 impl ast::NameOwner for Alias {}
50 #[derive(Debug, PartialEq, Eq, Hash)]
53 pub(crate) syntax: SyntaxNode,
55 unsafe impl TransparentNewType for ArgList {
56 type Repr = rowan::SyntaxNode<RaTypes>;
59 impl AstNode for ArgList {
60 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
62 ARG_LIST => Some(ArgList::from_repr(syntax.into_repr())),
66 fn syntax(&self) -> &SyntaxNode { &self.syntax }
69 impl ToOwned for ArgList {
70 type Owned = TreeArc<ArgList>;
71 fn to_owned(&self) -> TreeArc<ArgList> { TreeArc::cast(self.syntax.to_owned()) }
76 pub fn args(&self) -> impl Iterator<Item = &Expr> {
82 #[derive(Debug, PartialEq, Eq, Hash)]
84 pub struct ArrayExpr {
85 pub(crate) syntax: SyntaxNode,
87 unsafe impl TransparentNewType for ArrayExpr {
88 type Repr = rowan::SyntaxNode<RaTypes>;
91 impl AstNode for ArrayExpr {
92 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
94 ARRAY_EXPR => Some(ArrayExpr::from_repr(syntax.into_repr())),
98 fn syntax(&self) -> &SyntaxNode { &self.syntax }
101 impl ToOwned for ArrayExpr {
102 type Owned = TreeArc<ArrayExpr>;
103 fn to_owned(&self) -> TreeArc<ArrayExpr> { TreeArc::cast(self.syntax.to_owned()) }
108 pub fn exprs(&self) -> impl Iterator<Item = &Expr> {
109 super::children(self)
114 #[derive(Debug, PartialEq, Eq, Hash)]
116 pub struct ArrayType {
117 pub(crate) syntax: SyntaxNode,
119 unsafe impl TransparentNewType for ArrayType {
120 type Repr = rowan::SyntaxNode<RaTypes>;
123 impl AstNode for ArrayType {
124 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
125 match syntax.kind() {
126 ARRAY_TYPE => Some(ArrayType::from_repr(syntax.into_repr())),
130 fn syntax(&self) -> &SyntaxNode { &self.syntax }
133 impl ToOwned for ArrayType {
134 type Owned = TreeArc<ArrayType>;
135 fn to_owned(&self) -> TreeArc<ArrayType> { TreeArc::cast(self.syntax.to_owned()) }
140 pub fn type_ref(&self) -> Option<&TypeRef> {
141 super::child_opt(self)
144 pub fn expr(&self) -> Option<&Expr> {
145 super::child_opt(self)
150 #[derive(Debug, PartialEq, Eq, Hash)]
152 pub struct AssocTypeArg {
153 pub(crate) syntax: SyntaxNode,
155 unsafe impl TransparentNewType for AssocTypeArg {
156 type Repr = rowan::SyntaxNode<RaTypes>;
159 impl AstNode for AssocTypeArg {
160 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
161 match syntax.kind() {
162 ASSOC_TYPE_ARG => Some(AssocTypeArg::from_repr(syntax.into_repr())),
166 fn syntax(&self) -> &SyntaxNode { &self.syntax }
169 impl ToOwned for AssocTypeArg {
170 type Owned = TreeArc<AssocTypeArg>;
171 fn to_owned(&self) -> TreeArc<AssocTypeArg> { TreeArc::cast(self.syntax.to_owned()) }
176 pub fn name_ref(&self) -> Option<&NameRef> {
177 super::child_opt(self)
180 pub fn type_ref(&self) -> Option<&TypeRef> {
181 super::child_opt(self)
186 #[derive(Debug, PartialEq, Eq, Hash)]
189 pub(crate) syntax: SyntaxNode,
191 unsafe impl TransparentNewType for Attr {
192 type Repr = rowan::SyntaxNode<RaTypes>;
195 impl AstNode for Attr {
196 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
197 match syntax.kind() {
198 ATTR => Some(Attr::from_repr(syntax.into_repr())),
202 fn syntax(&self) -> &SyntaxNode { &self.syntax }
205 impl ToOwned for Attr {
206 type Owned = TreeArc<Attr>;
207 fn to_owned(&self) -> TreeArc<Attr> { TreeArc::cast(self.syntax.to_owned()) }
212 pub fn value(&self) -> Option<&TokenTree> {
213 super::child_opt(self)
218 #[derive(Debug, PartialEq, Eq, Hash)]
221 pub(crate) syntax: SyntaxNode,
223 unsafe impl TransparentNewType for BinExpr {
224 type Repr = rowan::SyntaxNode<RaTypes>;
227 impl AstNode for BinExpr {
228 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
229 match syntax.kind() {
230 BIN_EXPR => Some(BinExpr::from_repr(syntax.into_repr())),
234 fn syntax(&self) -> &SyntaxNode { &self.syntax }
237 impl ToOwned for BinExpr {
238 type Owned = TreeArc<BinExpr>;
239 fn to_owned(&self) -> TreeArc<BinExpr> { TreeArc::cast(self.syntax.to_owned()) }
246 #[derive(Debug, PartialEq, Eq, Hash)]
249 pub(crate) syntax: SyntaxNode,
251 unsafe impl TransparentNewType for BindPat {
252 type Repr = rowan::SyntaxNode<RaTypes>;
255 impl AstNode for BindPat {
256 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
257 match syntax.kind() {
258 BIND_PAT => Some(BindPat::from_repr(syntax.into_repr())),
262 fn syntax(&self) -> &SyntaxNode { &self.syntax }
265 impl ToOwned for BindPat {
266 type Owned = TreeArc<BindPat>;
267 fn to_owned(&self) -> TreeArc<BindPat> { TreeArc::cast(self.syntax.to_owned()) }
271 impl ast::NameOwner for BindPat {}
273 pub fn pat(&self) -> Option<&Pat> {
274 super::child_opt(self)
279 #[derive(Debug, PartialEq, Eq, Hash)]
282 pub(crate) syntax: SyntaxNode,
284 unsafe impl TransparentNewType for Block {
285 type Repr = rowan::SyntaxNode<RaTypes>;
288 impl AstNode for Block {
289 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
290 match syntax.kind() {
291 BLOCK => Some(Block::from_repr(syntax.into_repr())),
295 fn syntax(&self) -> &SyntaxNode { &self.syntax }
298 impl ToOwned for Block {
299 type Owned = TreeArc<Block>;
300 fn to_owned(&self) -> TreeArc<Block> { TreeArc::cast(self.syntax.to_owned()) }
304 impl ast::AttrsOwner for Block {}
306 pub fn statements(&self) -> impl Iterator<Item = &Stmt> {
307 super::children(self)
310 pub fn expr(&self) -> Option<&Expr> {
311 super::child_opt(self)
316 #[derive(Debug, PartialEq, Eq, Hash)]
318 pub struct BlockExpr {
319 pub(crate) syntax: SyntaxNode,
321 unsafe impl TransparentNewType for BlockExpr {
322 type Repr = rowan::SyntaxNode<RaTypes>;
325 impl AstNode for BlockExpr {
326 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
327 match syntax.kind() {
328 BLOCK_EXPR => Some(BlockExpr::from_repr(syntax.into_repr())),
332 fn syntax(&self) -> &SyntaxNode { &self.syntax }
335 impl ToOwned for BlockExpr {
336 type Owned = TreeArc<BlockExpr>;
337 fn to_owned(&self) -> TreeArc<BlockExpr> { TreeArc::cast(self.syntax.to_owned()) }
342 pub fn block(&self) -> Option<&Block> {
343 super::child_opt(self)
348 #[derive(Debug, PartialEq, Eq, Hash)]
350 pub struct BreakExpr {
351 pub(crate) syntax: SyntaxNode,
353 unsafe impl TransparentNewType for BreakExpr {
354 type Repr = rowan::SyntaxNode<RaTypes>;
357 impl AstNode for BreakExpr {
358 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
359 match syntax.kind() {
360 BREAK_EXPR => Some(BreakExpr::from_repr(syntax.into_repr())),
364 fn syntax(&self) -> &SyntaxNode { &self.syntax }
367 impl ToOwned for BreakExpr {
368 type Owned = TreeArc<BreakExpr>;
369 fn to_owned(&self) -> TreeArc<BreakExpr> { TreeArc::cast(self.syntax.to_owned()) }
374 pub fn expr(&self) -> Option<&Expr> {
375 super::child_opt(self)
380 #[derive(Debug, PartialEq, Eq, Hash)]
382 pub struct CallExpr {
383 pub(crate) syntax: SyntaxNode,
385 unsafe impl TransparentNewType for CallExpr {
386 type Repr = rowan::SyntaxNode<RaTypes>;
389 impl AstNode for CallExpr {
390 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
391 match syntax.kind() {
392 CALL_EXPR => Some(CallExpr::from_repr(syntax.into_repr())),
396 fn syntax(&self) -> &SyntaxNode { &self.syntax }
399 impl ToOwned for CallExpr {
400 type Owned = TreeArc<CallExpr>;
401 fn to_owned(&self) -> TreeArc<CallExpr> { TreeArc::cast(self.syntax.to_owned()) }
405 impl ast::ArgListOwner for CallExpr {}
407 pub fn expr(&self) -> Option<&Expr> {
408 super::child_opt(self)
413 #[derive(Debug, PartialEq, Eq, Hash)]
415 pub struct CastExpr {
416 pub(crate) syntax: SyntaxNode,
418 unsafe impl TransparentNewType for CastExpr {
419 type Repr = rowan::SyntaxNode<RaTypes>;
422 impl AstNode for CastExpr {
423 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
424 match syntax.kind() {
425 CAST_EXPR => Some(CastExpr::from_repr(syntax.into_repr())),
429 fn syntax(&self) -> &SyntaxNode { &self.syntax }
432 impl ToOwned for CastExpr {
433 type Owned = TreeArc<CastExpr>;
434 fn to_owned(&self) -> TreeArc<CastExpr> { TreeArc::cast(self.syntax.to_owned()) }
439 pub fn expr(&self) -> Option<&Expr> {
440 super::child_opt(self)
443 pub fn type_ref(&self) -> Option<&TypeRef> {
444 super::child_opt(self)
449 #[derive(Debug, PartialEq, Eq, Hash)]
451 pub struct Condition {
452 pub(crate) syntax: SyntaxNode,
454 unsafe impl TransparentNewType for Condition {
455 type Repr = rowan::SyntaxNode<RaTypes>;
458 impl AstNode for Condition {
459 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
460 match syntax.kind() {
461 CONDITION => Some(Condition::from_repr(syntax.into_repr())),
465 fn syntax(&self) -> &SyntaxNode { &self.syntax }
468 impl ToOwned for Condition {
469 type Owned = TreeArc<Condition>;
470 fn to_owned(&self) -> TreeArc<Condition> { TreeArc::cast(self.syntax.to_owned()) }
475 pub fn pat(&self) -> Option<&Pat> {
476 super::child_opt(self)
479 pub fn expr(&self) -> Option<&Expr> {
480 super::child_opt(self)
485 #[derive(Debug, PartialEq, Eq, Hash)]
487 pub struct ConstDef {
488 pub(crate) syntax: SyntaxNode,
490 unsafe impl TransparentNewType for ConstDef {
491 type Repr = rowan::SyntaxNode<RaTypes>;
494 impl AstNode for ConstDef {
495 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
496 match syntax.kind() {
497 CONST_DEF => Some(ConstDef::from_repr(syntax.into_repr())),
501 fn syntax(&self) -> &SyntaxNode { &self.syntax }
504 impl ToOwned for ConstDef {
505 type Owned = TreeArc<ConstDef>;
506 fn to_owned(&self) -> TreeArc<ConstDef> { TreeArc::cast(self.syntax.to_owned()) }
510 impl ast::VisibilityOwner for ConstDef {}
511 impl ast::NameOwner for ConstDef {}
512 impl ast::TypeParamsOwner for ConstDef {}
513 impl ast::AttrsOwner for ConstDef {}
514 impl ast::DocCommentsOwner for ConstDef {}
515 impl ast::TypeAscriptionOwner for ConstDef {}
519 #[derive(Debug, PartialEq, Eq, Hash)]
521 pub struct ContinueExpr {
522 pub(crate) syntax: SyntaxNode,
524 unsafe impl TransparentNewType for ContinueExpr {
525 type Repr = rowan::SyntaxNode<RaTypes>;
528 impl AstNode for ContinueExpr {
529 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
530 match syntax.kind() {
531 CONTINUE_EXPR => Some(ContinueExpr::from_repr(syntax.into_repr())),
535 fn syntax(&self) -> &SyntaxNode { &self.syntax }
538 impl ToOwned for ContinueExpr {
539 type Owned = TreeArc<ContinueExpr>;
540 fn to_owned(&self) -> TreeArc<ContinueExpr> { TreeArc::cast(self.syntax.to_owned()) }
547 #[derive(Debug, PartialEq, Eq, Hash)]
549 pub struct DynTraitType {
550 pub(crate) syntax: SyntaxNode,
552 unsafe impl TransparentNewType for DynTraitType {
553 type Repr = rowan::SyntaxNode<RaTypes>;
556 impl AstNode for DynTraitType {
557 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
558 match syntax.kind() {
559 DYN_TRAIT_TYPE => Some(DynTraitType::from_repr(syntax.into_repr())),
563 fn syntax(&self) -> &SyntaxNode { &self.syntax }
566 impl ToOwned for DynTraitType {
567 type Owned = TreeArc<DynTraitType>;
568 fn to_owned(&self) -> TreeArc<DynTraitType> { TreeArc::cast(self.syntax.to_owned()) }
572 impl ast::TypeBoundsOwner for DynTraitType {}
576 #[derive(Debug, PartialEq, Eq, Hash)]
579 pub(crate) syntax: SyntaxNode,
581 unsafe impl TransparentNewType for EnumDef {
582 type Repr = rowan::SyntaxNode<RaTypes>;
585 impl AstNode for EnumDef {
586 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
587 match syntax.kind() {
588 ENUM_DEF => Some(EnumDef::from_repr(syntax.into_repr())),
592 fn syntax(&self) -> &SyntaxNode { &self.syntax }
595 impl ToOwned for EnumDef {
596 type Owned = TreeArc<EnumDef>;
597 fn to_owned(&self) -> TreeArc<EnumDef> { TreeArc::cast(self.syntax.to_owned()) }
601 impl ast::VisibilityOwner for EnumDef {}
602 impl ast::NameOwner for EnumDef {}
603 impl ast::TypeParamsOwner for EnumDef {}
604 impl ast::AttrsOwner for EnumDef {}
605 impl ast::DocCommentsOwner for EnumDef {}
607 pub fn variant_list(&self) -> Option<&EnumVariantList> {
608 super::child_opt(self)
613 #[derive(Debug, PartialEq, Eq, Hash)]
615 pub struct EnumVariant {
616 pub(crate) syntax: SyntaxNode,
618 unsafe impl TransparentNewType for EnumVariant {
619 type Repr = rowan::SyntaxNode<RaTypes>;
622 impl AstNode for EnumVariant {
623 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
624 match syntax.kind() {
625 ENUM_VARIANT => Some(EnumVariant::from_repr(syntax.into_repr())),
629 fn syntax(&self) -> &SyntaxNode { &self.syntax }
632 impl ToOwned for EnumVariant {
633 type Owned = TreeArc<EnumVariant>;
634 fn to_owned(&self) -> TreeArc<EnumVariant> { TreeArc::cast(self.syntax.to_owned()) }
638 impl ast::NameOwner for EnumVariant {}
639 impl ast::DocCommentsOwner for EnumVariant {}
640 impl ast::AttrsOwner for EnumVariant {}
642 pub fn expr(&self) -> Option<&Expr> {
643 super::child_opt(self)
648 #[derive(Debug, PartialEq, Eq, Hash)]
650 pub struct EnumVariantList {
651 pub(crate) syntax: SyntaxNode,
653 unsafe impl TransparentNewType for EnumVariantList {
654 type Repr = rowan::SyntaxNode<RaTypes>;
657 impl AstNode for EnumVariantList {
658 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
659 match syntax.kind() {
660 ENUM_VARIANT_LIST => Some(EnumVariantList::from_repr(syntax.into_repr())),
664 fn syntax(&self) -> &SyntaxNode { &self.syntax }
667 impl ToOwned for EnumVariantList {
668 type Owned = TreeArc<EnumVariantList>;
669 fn to_owned(&self) -> TreeArc<EnumVariantList> { TreeArc::cast(self.syntax.to_owned()) }
673 impl EnumVariantList {
674 pub fn variants(&self) -> impl Iterator<Item = &EnumVariant> {
675 super::children(self)
680 #[derive(Debug, PartialEq, Eq, Hash)]
683 pub(crate) syntax: SyntaxNode,
685 unsafe impl TransparentNewType for Expr {
686 type Repr = rowan::SyntaxNode<RaTypes>;
689 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
690 pub enum ExprKind<'a> {
691 TupleExpr(&'a TupleExpr),
692 ArrayExpr(&'a ArrayExpr),
693 ParenExpr(&'a ParenExpr),
694 PathExpr(&'a PathExpr),
695 LambdaExpr(&'a LambdaExpr),
697 LoopExpr(&'a LoopExpr),
698 ForExpr(&'a ForExpr),
699 WhileExpr(&'a WhileExpr),
700 ContinueExpr(&'a ContinueExpr),
701 BreakExpr(&'a BreakExpr),
703 BlockExpr(&'a BlockExpr),
704 ReturnExpr(&'a ReturnExpr),
705 MatchExpr(&'a MatchExpr),
706 StructLit(&'a StructLit),
707 CallExpr(&'a CallExpr),
708 IndexExpr(&'a IndexExpr),
709 MethodCallExpr(&'a MethodCallExpr),
710 FieldExpr(&'a FieldExpr),
711 TryExpr(&'a TryExpr),
712 CastExpr(&'a CastExpr),
713 RefExpr(&'a RefExpr),
714 PrefixExpr(&'a PrefixExpr),
715 RangeExpr(&'a RangeExpr),
716 BinExpr(&'a BinExpr),
717 Literal(&'a Literal),
719 impl<'a> From<&'a TupleExpr> for &'a Expr {
720 fn from(n: &'a TupleExpr) -> &'a Expr {
721 Expr::cast(&n.syntax).unwrap()
724 impl<'a> From<&'a ArrayExpr> for &'a Expr {
725 fn from(n: &'a ArrayExpr) -> &'a Expr {
726 Expr::cast(&n.syntax).unwrap()
729 impl<'a> From<&'a ParenExpr> for &'a Expr {
730 fn from(n: &'a ParenExpr) -> &'a Expr {
731 Expr::cast(&n.syntax).unwrap()
734 impl<'a> From<&'a PathExpr> for &'a Expr {
735 fn from(n: &'a PathExpr) -> &'a Expr {
736 Expr::cast(&n.syntax).unwrap()
739 impl<'a> From<&'a LambdaExpr> for &'a Expr {
740 fn from(n: &'a LambdaExpr) -> &'a Expr {
741 Expr::cast(&n.syntax).unwrap()
744 impl<'a> From<&'a IfExpr> for &'a Expr {
745 fn from(n: &'a IfExpr) -> &'a Expr {
746 Expr::cast(&n.syntax).unwrap()
749 impl<'a> From<&'a LoopExpr> for &'a Expr {
750 fn from(n: &'a LoopExpr) -> &'a Expr {
751 Expr::cast(&n.syntax).unwrap()
754 impl<'a> From<&'a ForExpr> for &'a Expr {
755 fn from(n: &'a ForExpr) -> &'a Expr {
756 Expr::cast(&n.syntax).unwrap()
759 impl<'a> From<&'a WhileExpr> for &'a Expr {
760 fn from(n: &'a WhileExpr) -> &'a Expr {
761 Expr::cast(&n.syntax).unwrap()
764 impl<'a> From<&'a ContinueExpr> for &'a Expr {
765 fn from(n: &'a ContinueExpr) -> &'a Expr {
766 Expr::cast(&n.syntax).unwrap()
769 impl<'a> From<&'a BreakExpr> for &'a Expr {
770 fn from(n: &'a BreakExpr) -> &'a Expr {
771 Expr::cast(&n.syntax).unwrap()
774 impl<'a> From<&'a Label> for &'a Expr {
775 fn from(n: &'a Label) -> &'a Expr {
776 Expr::cast(&n.syntax).unwrap()
779 impl<'a> From<&'a BlockExpr> for &'a Expr {
780 fn from(n: &'a BlockExpr) -> &'a Expr {
781 Expr::cast(&n.syntax).unwrap()
784 impl<'a> From<&'a ReturnExpr> for &'a Expr {
785 fn from(n: &'a ReturnExpr) -> &'a Expr {
786 Expr::cast(&n.syntax).unwrap()
789 impl<'a> From<&'a MatchExpr> for &'a Expr {
790 fn from(n: &'a MatchExpr) -> &'a Expr {
791 Expr::cast(&n.syntax).unwrap()
794 impl<'a> From<&'a StructLit> for &'a Expr {
795 fn from(n: &'a StructLit) -> &'a Expr {
796 Expr::cast(&n.syntax).unwrap()
799 impl<'a> From<&'a CallExpr> for &'a Expr {
800 fn from(n: &'a CallExpr) -> &'a Expr {
801 Expr::cast(&n.syntax).unwrap()
804 impl<'a> From<&'a IndexExpr> for &'a Expr {
805 fn from(n: &'a IndexExpr) -> &'a Expr {
806 Expr::cast(&n.syntax).unwrap()
809 impl<'a> From<&'a MethodCallExpr> for &'a Expr {
810 fn from(n: &'a MethodCallExpr) -> &'a Expr {
811 Expr::cast(&n.syntax).unwrap()
814 impl<'a> From<&'a FieldExpr> for &'a Expr {
815 fn from(n: &'a FieldExpr) -> &'a Expr {
816 Expr::cast(&n.syntax).unwrap()
819 impl<'a> From<&'a TryExpr> for &'a Expr {
820 fn from(n: &'a TryExpr) -> &'a Expr {
821 Expr::cast(&n.syntax).unwrap()
824 impl<'a> From<&'a CastExpr> for &'a Expr {
825 fn from(n: &'a CastExpr) -> &'a Expr {
826 Expr::cast(&n.syntax).unwrap()
829 impl<'a> From<&'a RefExpr> for &'a Expr {
830 fn from(n: &'a RefExpr) -> &'a Expr {
831 Expr::cast(&n.syntax).unwrap()
834 impl<'a> From<&'a PrefixExpr> for &'a Expr {
835 fn from(n: &'a PrefixExpr) -> &'a Expr {
836 Expr::cast(&n.syntax).unwrap()
839 impl<'a> From<&'a RangeExpr> for &'a Expr {
840 fn from(n: &'a RangeExpr) -> &'a Expr {
841 Expr::cast(&n.syntax).unwrap()
844 impl<'a> From<&'a BinExpr> for &'a Expr {
845 fn from(n: &'a BinExpr) -> &'a Expr {
846 Expr::cast(&n.syntax).unwrap()
849 impl<'a> From<&'a Literal> for &'a Expr {
850 fn from(n: &'a Literal) -> &'a Expr {
851 Expr::cast(&n.syntax).unwrap()
856 impl AstNode for Expr {
857 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
858 match syntax.kind() {
885 | LITERAL => Some(Expr::from_repr(syntax.into_repr())),
889 fn syntax(&self) -> &SyntaxNode { &self.syntax }
892 impl ToOwned for Expr {
893 type Owned = TreeArc<Expr>;
894 fn to_owned(&self) -> TreeArc<Expr> { TreeArc::cast(self.syntax.to_owned()) }
898 pub fn kind(&self) -> ExprKind {
899 match self.syntax.kind() {
900 TUPLE_EXPR => ExprKind::TupleExpr(TupleExpr::cast(&self.syntax).unwrap()),
901 ARRAY_EXPR => ExprKind::ArrayExpr(ArrayExpr::cast(&self.syntax).unwrap()),
902 PAREN_EXPR => ExprKind::ParenExpr(ParenExpr::cast(&self.syntax).unwrap()),
903 PATH_EXPR => ExprKind::PathExpr(PathExpr::cast(&self.syntax).unwrap()),
904 LAMBDA_EXPR => ExprKind::LambdaExpr(LambdaExpr::cast(&self.syntax).unwrap()),
905 IF_EXPR => ExprKind::IfExpr(IfExpr::cast(&self.syntax).unwrap()),
906 LOOP_EXPR => ExprKind::LoopExpr(LoopExpr::cast(&self.syntax).unwrap()),
907 FOR_EXPR => ExprKind::ForExpr(ForExpr::cast(&self.syntax).unwrap()),
908 WHILE_EXPR => ExprKind::WhileExpr(WhileExpr::cast(&self.syntax).unwrap()),
909 CONTINUE_EXPR => ExprKind::ContinueExpr(ContinueExpr::cast(&self.syntax).unwrap()),
910 BREAK_EXPR => ExprKind::BreakExpr(BreakExpr::cast(&self.syntax).unwrap()),
911 LABEL => ExprKind::Label(Label::cast(&self.syntax).unwrap()),
912 BLOCK_EXPR => ExprKind::BlockExpr(BlockExpr::cast(&self.syntax).unwrap()),
913 RETURN_EXPR => ExprKind::ReturnExpr(ReturnExpr::cast(&self.syntax).unwrap()),
914 MATCH_EXPR => ExprKind::MatchExpr(MatchExpr::cast(&self.syntax).unwrap()),
915 STRUCT_LIT => ExprKind::StructLit(StructLit::cast(&self.syntax).unwrap()),
916 CALL_EXPR => ExprKind::CallExpr(CallExpr::cast(&self.syntax).unwrap()),
917 INDEX_EXPR => ExprKind::IndexExpr(IndexExpr::cast(&self.syntax).unwrap()),
918 METHOD_CALL_EXPR => ExprKind::MethodCallExpr(MethodCallExpr::cast(&self.syntax).unwrap()),
919 FIELD_EXPR => ExprKind::FieldExpr(FieldExpr::cast(&self.syntax).unwrap()),
920 TRY_EXPR => ExprKind::TryExpr(TryExpr::cast(&self.syntax).unwrap()),
921 CAST_EXPR => ExprKind::CastExpr(CastExpr::cast(&self.syntax).unwrap()),
922 REF_EXPR => ExprKind::RefExpr(RefExpr::cast(&self.syntax).unwrap()),
923 PREFIX_EXPR => ExprKind::PrefixExpr(PrefixExpr::cast(&self.syntax).unwrap()),
924 RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(&self.syntax).unwrap()),
925 BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(&self.syntax).unwrap()),
926 LITERAL => ExprKind::Literal(Literal::cast(&self.syntax).unwrap()),
935 #[derive(Debug, PartialEq, Eq, Hash)]
937 pub struct ExprStmt {
938 pub(crate) syntax: SyntaxNode,
940 unsafe impl TransparentNewType for ExprStmt {
941 type Repr = rowan::SyntaxNode<RaTypes>;
944 impl AstNode for ExprStmt {
945 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
946 match syntax.kind() {
947 EXPR_STMT => Some(ExprStmt::from_repr(syntax.into_repr())),
951 fn syntax(&self) -> &SyntaxNode { &self.syntax }
954 impl ToOwned for ExprStmt {
955 type Owned = TreeArc<ExprStmt>;
956 fn to_owned(&self) -> TreeArc<ExprStmt> { TreeArc::cast(self.syntax.to_owned()) }
961 pub fn expr(&self) -> Option<&Expr> {
962 super::child_opt(self)
967 #[derive(Debug, PartialEq, Eq, Hash)]
969 pub struct ExternCrateItem {
970 pub(crate) syntax: SyntaxNode,
972 unsafe impl TransparentNewType for ExternCrateItem {
973 type Repr = rowan::SyntaxNode<RaTypes>;
976 impl AstNode for ExternCrateItem {
977 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
978 match syntax.kind() {
979 EXTERN_CRATE_ITEM => Some(ExternCrateItem::from_repr(syntax.into_repr())),
983 fn syntax(&self) -> &SyntaxNode { &self.syntax }
986 impl ToOwned for ExternCrateItem {
987 type Owned = TreeArc<ExternCrateItem>;
988 fn to_owned(&self) -> TreeArc<ExternCrateItem> { TreeArc::cast(self.syntax.to_owned()) }
992 impl ExternCrateItem {
993 pub fn name_ref(&self) -> Option<&NameRef> {
994 super::child_opt(self)
997 pub fn alias(&self) -> Option<&Alias> {
998 super::child_opt(self)
1003 #[derive(Debug, PartialEq, Eq, Hash)]
1004 #[repr(transparent)]
1005 pub struct FieldExpr {
1006 pub(crate) syntax: SyntaxNode,
1008 unsafe impl TransparentNewType for FieldExpr {
1009 type Repr = rowan::SyntaxNode<RaTypes>;
1012 impl AstNode for FieldExpr {
1013 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1014 match syntax.kind() {
1015 FIELD_EXPR => Some(FieldExpr::from_repr(syntax.into_repr())),
1019 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1022 impl ToOwned for FieldExpr {
1023 type Owned = TreeArc<FieldExpr>;
1024 fn to_owned(&self) -> TreeArc<FieldExpr> { TreeArc::cast(self.syntax.to_owned()) }
1029 pub fn expr(&self) -> Option<&Expr> {
1030 super::child_opt(self)
1033 pub fn name_ref(&self) -> Option<&NameRef> {
1034 super::child_opt(self)
1039 #[derive(Debug, PartialEq, Eq, Hash)]
1040 #[repr(transparent)]
1041 pub struct FieldPat {
1042 pub(crate) syntax: SyntaxNode,
1044 unsafe impl TransparentNewType for FieldPat {
1045 type Repr = rowan::SyntaxNode<RaTypes>;
1048 impl AstNode for FieldPat {
1049 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1050 match syntax.kind() {
1051 FIELD_PAT => Some(FieldPat::from_repr(syntax.into_repr())),
1055 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1058 impl ToOwned for FieldPat {
1059 type Owned = TreeArc<FieldPat>;
1060 fn to_owned(&self) -> TreeArc<FieldPat> { TreeArc::cast(self.syntax.to_owned()) }
1064 impl ast::NameOwner for FieldPat {}
1066 pub fn pat(&self) -> Option<&Pat> {
1067 super::child_opt(self)
1072 #[derive(Debug, PartialEq, Eq, Hash)]
1073 #[repr(transparent)]
1074 pub struct FieldPatList {
1075 pub(crate) syntax: SyntaxNode,
1077 unsafe impl TransparentNewType for FieldPatList {
1078 type Repr = rowan::SyntaxNode<RaTypes>;
1081 impl AstNode for FieldPatList {
1082 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1083 match syntax.kind() {
1084 FIELD_PAT_LIST => Some(FieldPatList::from_repr(syntax.into_repr())),
1088 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1091 impl ToOwned for FieldPatList {
1092 type Owned = TreeArc<FieldPatList>;
1093 fn to_owned(&self) -> TreeArc<FieldPatList> { TreeArc::cast(self.syntax.to_owned()) }
1098 pub fn field_pats(&self) -> impl Iterator<Item = &FieldPat> {
1099 super::children(self)
1102 pub fn bind_pats(&self) -> impl Iterator<Item = &BindPat> {
1103 super::children(self)
1108 #[derive(Debug, PartialEq, Eq, Hash)]
1109 #[repr(transparent)]
1111 pub(crate) syntax: SyntaxNode,
1113 unsafe impl TransparentNewType for FnDef {
1114 type Repr = rowan::SyntaxNode<RaTypes>;
1117 impl AstNode for FnDef {
1118 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1119 match syntax.kind() {
1120 FN_DEF => Some(FnDef::from_repr(syntax.into_repr())),
1124 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1127 impl ToOwned for FnDef {
1128 type Owned = TreeArc<FnDef>;
1129 fn to_owned(&self) -> TreeArc<FnDef> { TreeArc::cast(self.syntax.to_owned()) }
1133 impl ast::VisibilityOwner for FnDef {}
1134 impl ast::NameOwner for FnDef {}
1135 impl ast::TypeParamsOwner for FnDef {}
1136 impl ast::AttrsOwner for FnDef {}
1137 impl ast::DocCommentsOwner for FnDef {}
1139 pub fn param_list(&self) -> Option<&ParamList> {
1140 super::child_opt(self)
1143 pub fn body(&self) -> Option<&Block> {
1144 super::child_opt(self)
1147 pub fn ret_type(&self) -> Option<&RetType> {
1148 super::child_opt(self)
1153 #[derive(Debug, PartialEq, Eq, Hash)]
1154 #[repr(transparent)]
1155 pub struct FnPointerType {
1156 pub(crate) syntax: SyntaxNode,
1158 unsafe impl TransparentNewType for FnPointerType {
1159 type Repr = rowan::SyntaxNode<RaTypes>;
1162 impl AstNode for FnPointerType {
1163 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1164 match syntax.kind() {
1165 FN_POINTER_TYPE => Some(FnPointerType::from_repr(syntax.into_repr())),
1169 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1172 impl ToOwned for FnPointerType {
1173 type Owned = TreeArc<FnPointerType>;
1174 fn to_owned(&self) -> TreeArc<FnPointerType> { TreeArc::cast(self.syntax.to_owned()) }
1178 impl FnPointerType {
1179 pub fn param_list(&self) -> Option<&ParamList> {
1180 super::child_opt(self)
1183 pub fn ret_type(&self) -> Option<&RetType> {
1184 super::child_opt(self)
1189 #[derive(Debug, PartialEq, Eq, Hash)]
1190 #[repr(transparent)]
1191 pub struct ForExpr {
1192 pub(crate) syntax: SyntaxNode,
1194 unsafe impl TransparentNewType for ForExpr {
1195 type Repr = rowan::SyntaxNode<RaTypes>;
1198 impl AstNode for ForExpr {
1199 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1200 match syntax.kind() {
1201 FOR_EXPR => Some(ForExpr::from_repr(syntax.into_repr())),
1205 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1208 impl ToOwned for ForExpr {
1209 type Owned = TreeArc<ForExpr>;
1210 fn to_owned(&self) -> TreeArc<ForExpr> { TreeArc::cast(self.syntax.to_owned()) }
1214 impl ast::LoopBodyOwner for ForExpr {}
1216 pub fn pat(&self) -> Option<&Pat> {
1217 super::child_opt(self)
1220 pub fn iterable(&self) -> Option<&Expr> {
1221 super::child_opt(self)
1226 #[derive(Debug, PartialEq, Eq, Hash)]
1227 #[repr(transparent)]
1228 pub struct ForType {
1229 pub(crate) syntax: SyntaxNode,
1231 unsafe impl TransparentNewType for ForType {
1232 type Repr = rowan::SyntaxNode<RaTypes>;
1235 impl AstNode for ForType {
1236 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1237 match syntax.kind() {
1238 FOR_TYPE => Some(ForType::from_repr(syntax.into_repr())),
1242 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1245 impl ToOwned for ForType {
1246 type Owned = TreeArc<ForType>;
1247 fn to_owned(&self) -> TreeArc<ForType> { TreeArc::cast(self.syntax.to_owned()) }
1252 pub fn type_ref(&self) -> Option<&TypeRef> {
1253 super::child_opt(self)
1258 #[derive(Debug, PartialEq, Eq, Hash)]
1259 #[repr(transparent)]
1261 pub(crate) syntax: SyntaxNode,
1263 unsafe impl TransparentNewType for IfExpr {
1264 type Repr = rowan::SyntaxNode<RaTypes>;
1267 impl AstNode for IfExpr {
1268 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1269 match syntax.kind() {
1270 IF_EXPR => Some(IfExpr::from_repr(syntax.into_repr())),
1274 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1277 impl ToOwned for IfExpr {
1278 type Owned = TreeArc<IfExpr>;
1279 fn to_owned(&self) -> TreeArc<IfExpr> { TreeArc::cast(self.syntax.to_owned()) }
1284 pub fn condition(&self) -> Option<&Condition> {
1285 super::child_opt(self)
1290 #[derive(Debug, PartialEq, Eq, Hash)]
1291 #[repr(transparent)]
1292 pub struct ImplBlock {
1293 pub(crate) syntax: SyntaxNode,
1295 unsafe impl TransparentNewType for ImplBlock {
1296 type Repr = rowan::SyntaxNode<RaTypes>;
1299 impl AstNode for ImplBlock {
1300 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1301 match syntax.kind() {
1302 IMPL_BLOCK => Some(ImplBlock::from_repr(syntax.into_repr())),
1306 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1309 impl ToOwned for ImplBlock {
1310 type Owned = TreeArc<ImplBlock>;
1311 fn to_owned(&self) -> TreeArc<ImplBlock> { TreeArc::cast(self.syntax.to_owned()) }
1315 impl ast::TypeParamsOwner for ImplBlock {}
1317 pub fn item_list(&self) -> Option<&ItemList> {
1318 super::child_opt(self)
1323 #[derive(Debug, PartialEq, Eq, Hash)]
1324 #[repr(transparent)]
1325 pub struct ImplItem {
1326 pub(crate) syntax: SyntaxNode,
1328 unsafe impl TransparentNewType for ImplItem {
1329 type Repr = rowan::SyntaxNode<RaTypes>;
1332 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1333 pub enum ImplItemKind<'a> {
1335 TypeAliasDef(&'a TypeAliasDef),
1336 ConstDef(&'a ConstDef),
1338 impl<'a> From<&'a FnDef> for &'a ImplItem {
1339 fn from(n: &'a FnDef) -> &'a ImplItem {
1340 ImplItem::cast(&n.syntax).unwrap()
1343 impl<'a> From<&'a TypeAliasDef> for &'a ImplItem {
1344 fn from(n: &'a TypeAliasDef) -> &'a ImplItem {
1345 ImplItem::cast(&n.syntax).unwrap()
1348 impl<'a> From<&'a ConstDef> for &'a ImplItem {
1349 fn from(n: &'a ConstDef) -> &'a ImplItem {
1350 ImplItem::cast(&n.syntax).unwrap()
1355 impl AstNode for ImplItem {
1356 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1357 match syntax.kind() {
1360 | CONST_DEF => Some(ImplItem::from_repr(syntax.into_repr())),
1364 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1367 impl ToOwned for ImplItem {
1368 type Owned = TreeArc<ImplItem>;
1369 fn to_owned(&self) -> TreeArc<ImplItem> { TreeArc::cast(self.syntax.to_owned()) }
1373 pub fn kind(&self) -> ImplItemKind {
1374 match self.syntax.kind() {
1375 FN_DEF => ImplItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
1376 TYPE_ALIAS_DEF => ImplItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
1377 CONST_DEF => ImplItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
1378 _ => unreachable!(),
1386 #[derive(Debug, PartialEq, Eq, Hash)]
1387 #[repr(transparent)]
1388 pub struct ImplTraitType {
1389 pub(crate) syntax: SyntaxNode,
1391 unsafe impl TransparentNewType for ImplTraitType {
1392 type Repr = rowan::SyntaxNode<RaTypes>;
1395 impl AstNode for ImplTraitType {
1396 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1397 match syntax.kind() {
1398 IMPL_TRAIT_TYPE => Some(ImplTraitType::from_repr(syntax.into_repr())),
1402 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1405 impl ToOwned for ImplTraitType {
1406 type Owned = TreeArc<ImplTraitType>;
1407 fn to_owned(&self) -> TreeArc<ImplTraitType> { TreeArc::cast(self.syntax.to_owned()) }
1411 impl ast::TypeBoundsOwner for ImplTraitType {}
1412 impl ImplTraitType {}
1415 #[derive(Debug, PartialEq, Eq, Hash)]
1416 #[repr(transparent)]
1417 pub struct IndexExpr {
1418 pub(crate) syntax: SyntaxNode,
1420 unsafe impl TransparentNewType for IndexExpr {
1421 type Repr = rowan::SyntaxNode<RaTypes>;
1424 impl AstNode for IndexExpr {
1425 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1426 match syntax.kind() {
1427 INDEX_EXPR => Some(IndexExpr::from_repr(syntax.into_repr())),
1431 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1434 impl ToOwned for IndexExpr {
1435 type Owned = TreeArc<IndexExpr>;
1436 fn to_owned(&self) -> TreeArc<IndexExpr> { TreeArc::cast(self.syntax.to_owned()) }
1443 #[derive(Debug, PartialEq, Eq, Hash)]
1444 #[repr(transparent)]
1445 pub struct ItemList {
1446 pub(crate) syntax: SyntaxNode,
1448 unsafe impl TransparentNewType for ItemList {
1449 type Repr = rowan::SyntaxNode<RaTypes>;
1452 impl AstNode for ItemList {
1453 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1454 match syntax.kind() {
1455 ITEM_LIST => Some(ItemList::from_repr(syntax.into_repr())),
1459 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1462 impl ToOwned for ItemList {
1463 type Owned = TreeArc<ItemList>;
1464 fn to_owned(&self) -> TreeArc<ItemList> { TreeArc::cast(self.syntax.to_owned()) }
1468 impl ast::FnDefOwner for ItemList {}
1469 impl ast::ModuleItemOwner for ItemList {}
1471 pub fn impl_items(&self) -> impl Iterator<Item = &ImplItem> {
1472 super::children(self)
1477 #[derive(Debug, PartialEq, Eq, Hash)]
1478 #[repr(transparent)]
1480 pub(crate) syntax: SyntaxNode,
1482 unsafe impl TransparentNewType for Label {
1483 type Repr = rowan::SyntaxNode<RaTypes>;
1486 impl AstNode for Label {
1487 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1488 match syntax.kind() {
1489 LABEL => Some(Label::from_repr(syntax.into_repr())),
1493 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1496 impl ToOwned for Label {
1497 type Owned = TreeArc<Label>;
1498 fn to_owned(&self) -> TreeArc<Label> { TreeArc::cast(self.syntax.to_owned()) }
1505 #[derive(Debug, PartialEq, Eq, Hash)]
1506 #[repr(transparent)]
1507 pub struct LambdaExpr {
1508 pub(crate) syntax: SyntaxNode,
1510 unsafe impl TransparentNewType for LambdaExpr {
1511 type Repr = rowan::SyntaxNode<RaTypes>;
1514 impl AstNode for LambdaExpr {
1515 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1516 match syntax.kind() {
1517 LAMBDA_EXPR => Some(LambdaExpr::from_repr(syntax.into_repr())),
1521 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1524 impl ToOwned for LambdaExpr {
1525 type Owned = TreeArc<LambdaExpr>;
1526 fn to_owned(&self) -> TreeArc<LambdaExpr> { TreeArc::cast(self.syntax.to_owned()) }
1531 pub fn param_list(&self) -> Option<&ParamList> {
1532 super::child_opt(self)
1535 pub fn body(&self) -> Option<&Expr> {
1536 super::child_opt(self)
1541 #[derive(Debug, PartialEq, Eq, Hash)]
1542 #[repr(transparent)]
1543 pub struct LetStmt {
1544 pub(crate) syntax: SyntaxNode,
1546 unsafe impl TransparentNewType for LetStmt {
1547 type Repr = rowan::SyntaxNode<RaTypes>;
1550 impl AstNode for LetStmt {
1551 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1552 match syntax.kind() {
1553 LET_STMT => Some(LetStmt::from_repr(syntax.into_repr())),
1557 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1560 impl ToOwned for LetStmt {
1561 type Owned = TreeArc<LetStmt>;
1562 fn to_owned(&self) -> TreeArc<LetStmt> { TreeArc::cast(self.syntax.to_owned()) }
1566 impl ast::TypeAscriptionOwner for LetStmt {}
1568 pub fn pat(&self) -> Option<&Pat> {
1569 super::child_opt(self)
1572 pub fn initializer(&self) -> Option<&Expr> {
1573 super::child_opt(self)
1578 #[derive(Debug, PartialEq, Eq, Hash)]
1579 #[repr(transparent)]
1580 pub struct LifetimeArg {
1581 pub(crate) syntax: SyntaxNode,
1583 unsafe impl TransparentNewType for LifetimeArg {
1584 type Repr = rowan::SyntaxNode<RaTypes>;
1587 impl AstNode for LifetimeArg {
1588 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1589 match syntax.kind() {
1590 LIFETIME_ARG => Some(LifetimeArg::from_repr(syntax.into_repr())),
1594 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1597 impl ToOwned for LifetimeArg {
1598 type Owned = TreeArc<LifetimeArg>;
1599 fn to_owned(&self) -> TreeArc<LifetimeArg> { TreeArc::cast(self.syntax.to_owned()) }
1606 #[derive(Debug, PartialEq, Eq, Hash)]
1607 #[repr(transparent)]
1608 pub struct LifetimeParam {
1609 pub(crate) syntax: SyntaxNode,
1611 unsafe impl TransparentNewType for LifetimeParam {
1612 type Repr = rowan::SyntaxNode<RaTypes>;
1615 impl AstNode for LifetimeParam {
1616 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1617 match syntax.kind() {
1618 LIFETIME_PARAM => Some(LifetimeParam::from_repr(syntax.into_repr())),
1622 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1625 impl ToOwned for LifetimeParam {
1626 type Owned = TreeArc<LifetimeParam>;
1627 fn to_owned(&self) -> TreeArc<LifetimeParam> { TreeArc::cast(self.syntax.to_owned()) }
1631 impl ast::AttrsOwner for LifetimeParam {}
1632 impl LifetimeParam {}
1635 #[derive(Debug, PartialEq, Eq, Hash)]
1636 #[repr(transparent)]
1637 pub struct Literal {
1638 pub(crate) syntax: SyntaxNode,
1640 unsafe impl TransparentNewType for Literal {
1641 type Repr = rowan::SyntaxNode<RaTypes>;
1644 impl AstNode for Literal {
1645 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1646 match syntax.kind() {
1647 LITERAL => Some(Literal::from_repr(syntax.into_repr())),
1651 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1654 impl ToOwned for Literal {
1655 type Owned = TreeArc<Literal>;
1656 fn to_owned(&self) -> TreeArc<Literal> { TreeArc::cast(self.syntax.to_owned()) }
1663 #[derive(Debug, PartialEq, Eq, Hash)]
1664 #[repr(transparent)]
1665 pub struct LiteralPat {
1666 pub(crate) syntax: SyntaxNode,
1668 unsafe impl TransparentNewType for LiteralPat {
1669 type Repr = rowan::SyntaxNode<RaTypes>;
1672 impl AstNode for LiteralPat {
1673 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1674 match syntax.kind() {
1675 LITERAL_PAT => Some(LiteralPat::from_repr(syntax.into_repr())),
1679 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1682 impl ToOwned for LiteralPat {
1683 type Owned = TreeArc<LiteralPat>;
1684 fn to_owned(&self) -> TreeArc<LiteralPat> { TreeArc::cast(self.syntax.to_owned()) }
1689 pub fn literal(&self) -> Option<&Literal> {
1690 super::child_opt(self)
1695 #[derive(Debug, PartialEq, Eq, Hash)]
1696 #[repr(transparent)]
1697 pub struct LoopExpr {
1698 pub(crate) syntax: SyntaxNode,
1700 unsafe impl TransparentNewType for LoopExpr {
1701 type Repr = rowan::SyntaxNode<RaTypes>;
1704 impl AstNode for LoopExpr {
1705 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1706 match syntax.kind() {
1707 LOOP_EXPR => Some(LoopExpr::from_repr(syntax.into_repr())),
1711 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1714 impl ToOwned for LoopExpr {
1715 type Owned = TreeArc<LoopExpr>;
1716 fn to_owned(&self) -> TreeArc<LoopExpr> { TreeArc::cast(self.syntax.to_owned()) }
1720 impl ast::LoopBodyOwner for LoopExpr {}
1724 #[derive(Debug, PartialEq, Eq, Hash)]
1725 #[repr(transparent)]
1726 pub struct MacroCall {
1727 pub(crate) syntax: SyntaxNode,
1729 unsafe impl TransparentNewType for MacroCall {
1730 type Repr = rowan::SyntaxNode<RaTypes>;
1733 impl AstNode for MacroCall {
1734 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1735 match syntax.kind() {
1736 MACRO_CALL => Some(MacroCall::from_repr(syntax.into_repr())),
1740 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1743 impl ToOwned for MacroCall {
1744 type Owned = TreeArc<MacroCall>;
1745 fn to_owned(&self) -> TreeArc<MacroCall> { TreeArc::cast(self.syntax.to_owned()) }
1749 impl ast::NameOwner for MacroCall {}
1750 impl ast::AttrsOwner for MacroCall {}
1752 pub fn token_tree(&self) -> Option<&TokenTree> {
1753 super::child_opt(self)
1756 pub fn path(&self) -> Option<&Path> {
1757 super::child_opt(self)
1762 #[derive(Debug, PartialEq, Eq, Hash)]
1763 #[repr(transparent)]
1764 pub struct MatchArm {
1765 pub(crate) syntax: SyntaxNode,
1767 unsafe impl TransparentNewType for MatchArm {
1768 type Repr = rowan::SyntaxNode<RaTypes>;
1771 impl AstNode for MatchArm {
1772 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1773 match syntax.kind() {
1774 MATCH_ARM => Some(MatchArm::from_repr(syntax.into_repr())),
1778 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1781 impl ToOwned for MatchArm {
1782 type Owned = TreeArc<MatchArm>;
1783 fn to_owned(&self) -> TreeArc<MatchArm> { TreeArc::cast(self.syntax.to_owned()) }
1787 impl ast::AttrsOwner for MatchArm {}
1789 pub fn pats(&self) -> impl Iterator<Item = &Pat> {
1790 super::children(self)
1793 pub fn guard(&self) -> Option<&MatchGuard> {
1794 super::child_opt(self)
1797 pub fn expr(&self) -> Option<&Expr> {
1798 super::child_opt(self)
1803 #[derive(Debug, PartialEq, Eq, Hash)]
1804 #[repr(transparent)]
1805 pub struct MatchArmList {
1806 pub(crate) syntax: SyntaxNode,
1808 unsafe impl TransparentNewType for MatchArmList {
1809 type Repr = rowan::SyntaxNode<RaTypes>;
1812 impl AstNode for MatchArmList {
1813 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1814 match syntax.kind() {
1815 MATCH_ARM_LIST => Some(MatchArmList::from_repr(syntax.into_repr())),
1819 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1822 impl ToOwned for MatchArmList {
1823 type Owned = TreeArc<MatchArmList>;
1824 fn to_owned(&self) -> TreeArc<MatchArmList> { TreeArc::cast(self.syntax.to_owned()) }
1828 impl ast::AttrsOwner for MatchArmList {}
1830 pub fn arms(&self) -> impl Iterator<Item = &MatchArm> {
1831 super::children(self)
1836 #[derive(Debug, PartialEq, Eq, Hash)]
1837 #[repr(transparent)]
1838 pub struct MatchExpr {
1839 pub(crate) syntax: SyntaxNode,
1841 unsafe impl TransparentNewType for MatchExpr {
1842 type Repr = rowan::SyntaxNode<RaTypes>;
1845 impl AstNode for MatchExpr {
1846 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1847 match syntax.kind() {
1848 MATCH_EXPR => Some(MatchExpr::from_repr(syntax.into_repr())),
1852 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1855 impl ToOwned for MatchExpr {
1856 type Owned = TreeArc<MatchExpr>;
1857 fn to_owned(&self) -> TreeArc<MatchExpr> { TreeArc::cast(self.syntax.to_owned()) }
1862 pub fn expr(&self) -> Option<&Expr> {
1863 super::child_opt(self)
1866 pub fn match_arm_list(&self) -> Option<&MatchArmList> {
1867 super::child_opt(self)
1872 #[derive(Debug, PartialEq, Eq, Hash)]
1873 #[repr(transparent)]
1874 pub struct MatchGuard {
1875 pub(crate) syntax: SyntaxNode,
1877 unsafe impl TransparentNewType for MatchGuard {
1878 type Repr = rowan::SyntaxNode<RaTypes>;
1881 impl AstNode for MatchGuard {
1882 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1883 match syntax.kind() {
1884 MATCH_GUARD => Some(MatchGuard::from_repr(syntax.into_repr())),
1888 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1891 impl ToOwned for MatchGuard {
1892 type Owned = TreeArc<MatchGuard>;
1893 fn to_owned(&self) -> TreeArc<MatchGuard> { TreeArc::cast(self.syntax.to_owned()) }
1898 pub fn expr(&self) -> Option<&Expr> {
1899 super::child_opt(self)
1904 #[derive(Debug, PartialEq, Eq, Hash)]
1905 #[repr(transparent)]
1906 pub struct MethodCallExpr {
1907 pub(crate) syntax: SyntaxNode,
1909 unsafe impl TransparentNewType for MethodCallExpr {
1910 type Repr = rowan::SyntaxNode<RaTypes>;
1913 impl AstNode for MethodCallExpr {
1914 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1915 match syntax.kind() {
1916 METHOD_CALL_EXPR => Some(MethodCallExpr::from_repr(syntax.into_repr())),
1920 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1923 impl ToOwned for MethodCallExpr {
1924 type Owned = TreeArc<MethodCallExpr>;
1925 fn to_owned(&self) -> TreeArc<MethodCallExpr> { TreeArc::cast(self.syntax.to_owned()) }
1929 impl ast::ArgListOwner for MethodCallExpr {}
1930 impl MethodCallExpr {
1931 pub fn expr(&self) -> Option<&Expr> {
1932 super::child_opt(self)
1935 pub fn name_ref(&self) -> Option<&NameRef> {
1936 super::child_opt(self)
1939 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
1940 super::child_opt(self)
1945 #[derive(Debug, PartialEq, Eq, Hash)]
1946 #[repr(transparent)]
1948 pub(crate) syntax: SyntaxNode,
1950 unsafe impl TransparentNewType for Module {
1951 type Repr = rowan::SyntaxNode<RaTypes>;
1954 impl AstNode for Module {
1955 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1956 match syntax.kind() {
1957 MODULE => Some(Module::from_repr(syntax.into_repr())),
1961 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1964 impl ToOwned for Module {
1965 type Owned = TreeArc<Module>;
1966 fn to_owned(&self) -> TreeArc<Module> { TreeArc::cast(self.syntax.to_owned()) }
1970 impl ast::VisibilityOwner for Module {}
1971 impl ast::NameOwner for Module {}
1972 impl ast::AttrsOwner for Module {}
1973 impl ast::DocCommentsOwner for Module {}
1975 pub fn item_list(&self) -> Option<&ItemList> {
1976 super::child_opt(self)
1981 #[derive(Debug, PartialEq, Eq, Hash)]
1982 #[repr(transparent)]
1983 pub struct ModuleItem {
1984 pub(crate) syntax: SyntaxNode,
1986 unsafe impl TransparentNewType for ModuleItem {
1987 type Repr = rowan::SyntaxNode<RaTypes>;
1990 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1991 pub enum ModuleItemKind<'a> {
1992 StructDef(&'a StructDef),
1993 EnumDef(&'a EnumDef),
1995 TraitDef(&'a TraitDef),
1996 TypeAliasDef(&'a TypeAliasDef),
1997 ImplBlock(&'a ImplBlock),
1998 UseItem(&'a UseItem),
1999 ExternCrateItem(&'a ExternCrateItem),
2000 ConstDef(&'a ConstDef),
2001 StaticDef(&'a StaticDef),
2004 impl<'a> From<&'a StructDef> for &'a ModuleItem {
2005 fn from(n: &'a StructDef) -> &'a ModuleItem {
2006 ModuleItem::cast(&n.syntax).unwrap()
2009 impl<'a> From<&'a EnumDef> for &'a ModuleItem {
2010 fn from(n: &'a EnumDef) -> &'a ModuleItem {
2011 ModuleItem::cast(&n.syntax).unwrap()
2014 impl<'a> From<&'a FnDef> for &'a ModuleItem {
2015 fn from(n: &'a FnDef) -> &'a ModuleItem {
2016 ModuleItem::cast(&n.syntax).unwrap()
2019 impl<'a> From<&'a TraitDef> for &'a ModuleItem {
2020 fn from(n: &'a TraitDef) -> &'a ModuleItem {
2021 ModuleItem::cast(&n.syntax).unwrap()
2024 impl<'a> From<&'a TypeAliasDef> for &'a ModuleItem {
2025 fn from(n: &'a TypeAliasDef) -> &'a ModuleItem {
2026 ModuleItem::cast(&n.syntax).unwrap()
2029 impl<'a> From<&'a ImplBlock> for &'a ModuleItem {
2030 fn from(n: &'a ImplBlock) -> &'a ModuleItem {
2031 ModuleItem::cast(&n.syntax).unwrap()
2034 impl<'a> From<&'a UseItem> for &'a ModuleItem {
2035 fn from(n: &'a UseItem) -> &'a ModuleItem {
2036 ModuleItem::cast(&n.syntax).unwrap()
2039 impl<'a> From<&'a ExternCrateItem> for &'a ModuleItem {
2040 fn from(n: &'a ExternCrateItem) -> &'a ModuleItem {
2041 ModuleItem::cast(&n.syntax).unwrap()
2044 impl<'a> From<&'a ConstDef> for &'a ModuleItem {
2045 fn from(n: &'a ConstDef) -> &'a ModuleItem {
2046 ModuleItem::cast(&n.syntax).unwrap()
2049 impl<'a> From<&'a StaticDef> for &'a ModuleItem {
2050 fn from(n: &'a StaticDef) -> &'a ModuleItem {
2051 ModuleItem::cast(&n.syntax).unwrap()
2054 impl<'a> From<&'a Module> for &'a ModuleItem {
2055 fn from(n: &'a Module) -> &'a ModuleItem {
2056 ModuleItem::cast(&n.syntax).unwrap()
2061 impl AstNode for ModuleItem {
2062 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2063 match syntax.kind() {
2074 | MODULE => Some(ModuleItem::from_repr(syntax.into_repr())),
2078 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2081 impl ToOwned for ModuleItem {
2082 type Owned = TreeArc<ModuleItem>;
2083 fn to_owned(&self) -> TreeArc<ModuleItem> { TreeArc::cast(self.syntax.to_owned()) }
2087 pub fn kind(&self) -> ModuleItemKind {
2088 match self.syntax.kind() {
2089 STRUCT_DEF => ModuleItemKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2090 ENUM_DEF => ModuleItemKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2091 FN_DEF => ModuleItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
2092 TRAIT_DEF => ModuleItemKind::TraitDef(TraitDef::cast(&self.syntax).unwrap()),
2093 TYPE_ALIAS_DEF => ModuleItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
2094 IMPL_BLOCK => ModuleItemKind::ImplBlock(ImplBlock::cast(&self.syntax).unwrap()),
2095 USE_ITEM => ModuleItemKind::UseItem(UseItem::cast(&self.syntax).unwrap()),
2096 EXTERN_CRATE_ITEM => ModuleItemKind::ExternCrateItem(ExternCrateItem::cast(&self.syntax).unwrap()),
2097 CONST_DEF => ModuleItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
2098 STATIC_DEF => ModuleItemKind::StaticDef(StaticDef::cast(&self.syntax).unwrap()),
2099 MODULE => ModuleItemKind::Module(Module::cast(&self.syntax).unwrap()),
2100 _ => unreachable!(),
2108 #[derive(Debug, PartialEq, Eq, Hash)]
2109 #[repr(transparent)]
2111 pub(crate) syntax: SyntaxNode,
2113 unsafe impl TransparentNewType for Name {
2114 type Repr = rowan::SyntaxNode<RaTypes>;
2117 impl AstNode for Name {
2118 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2119 match syntax.kind() {
2120 NAME => Some(Name::from_repr(syntax.into_repr())),
2124 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2127 impl ToOwned for Name {
2128 type Owned = TreeArc<Name>;
2129 fn to_owned(&self) -> TreeArc<Name> { TreeArc::cast(self.syntax.to_owned()) }
2136 #[derive(Debug, PartialEq, Eq, Hash)]
2137 #[repr(transparent)]
2138 pub struct NameRef {
2139 pub(crate) syntax: SyntaxNode,
2141 unsafe impl TransparentNewType for NameRef {
2142 type Repr = rowan::SyntaxNode<RaTypes>;
2145 impl AstNode for NameRef {
2146 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2147 match syntax.kind() {
2148 NAME_REF => Some(NameRef::from_repr(syntax.into_repr())),
2152 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2155 impl ToOwned for NameRef {
2156 type Owned = TreeArc<NameRef>;
2157 fn to_owned(&self) -> TreeArc<NameRef> { TreeArc::cast(self.syntax.to_owned()) }
2164 #[derive(Debug, PartialEq, Eq, Hash)]
2165 #[repr(transparent)]
2166 pub struct NamedField {
2167 pub(crate) syntax: SyntaxNode,
2169 unsafe impl TransparentNewType for NamedField {
2170 type Repr = rowan::SyntaxNode<RaTypes>;
2173 impl AstNode for NamedField {
2174 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2175 match syntax.kind() {
2176 NAMED_FIELD => Some(NamedField::from_repr(syntax.into_repr())),
2180 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2183 impl ToOwned for NamedField {
2184 type Owned = TreeArc<NamedField>;
2185 fn to_owned(&self) -> TreeArc<NamedField> { TreeArc::cast(self.syntax.to_owned()) }
2190 pub fn name_ref(&self) -> Option<&NameRef> {
2191 super::child_opt(self)
2194 pub fn expr(&self) -> Option<&Expr> {
2195 super::child_opt(self)
2200 #[derive(Debug, PartialEq, Eq, Hash)]
2201 #[repr(transparent)]
2202 pub struct NamedFieldDef {
2203 pub(crate) syntax: SyntaxNode,
2205 unsafe impl TransparentNewType for NamedFieldDef {
2206 type Repr = rowan::SyntaxNode<RaTypes>;
2209 impl AstNode for NamedFieldDef {
2210 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2211 match syntax.kind() {
2212 NAMED_FIELD_DEF => Some(NamedFieldDef::from_repr(syntax.into_repr())),
2216 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2219 impl ToOwned for NamedFieldDef {
2220 type Owned = TreeArc<NamedFieldDef>;
2221 fn to_owned(&self) -> TreeArc<NamedFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2225 impl ast::VisibilityOwner for NamedFieldDef {}
2226 impl ast::NameOwner for NamedFieldDef {}
2227 impl ast::AttrsOwner for NamedFieldDef {}
2228 impl ast::DocCommentsOwner for NamedFieldDef {}
2229 impl ast::TypeAscriptionOwner for NamedFieldDef {}
2230 impl NamedFieldDef {}
2232 // NamedFieldDefList
2233 #[derive(Debug, PartialEq, Eq, Hash)]
2234 #[repr(transparent)]
2235 pub struct NamedFieldDefList {
2236 pub(crate) syntax: SyntaxNode,
2238 unsafe impl TransparentNewType for NamedFieldDefList {
2239 type Repr = rowan::SyntaxNode<RaTypes>;
2242 impl AstNode for NamedFieldDefList {
2243 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2244 match syntax.kind() {
2245 NAMED_FIELD_DEF_LIST => Some(NamedFieldDefList::from_repr(syntax.into_repr())),
2249 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2252 impl ToOwned for NamedFieldDefList {
2253 type Owned = TreeArc<NamedFieldDefList>;
2254 fn to_owned(&self) -> TreeArc<NamedFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
2258 impl NamedFieldDefList {
2259 pub fn fields(&self) -> impl Iterator<Item = &NamedFieldDef> {
2260 super::children(self)
2265 #[derive(Debug, PartialEq, Eq, Hash)]
2266 #[repr(transparent)]
2267 pub struct NamedFieldList {
2268 pub(crate) syntax: SyntaxNode,
2270 unsafe impl TransparentNewType for NamedFieldList {
2271 type Repr = rowan::SyntaxNode<RaTypes>;
2274 impl AstNode for NamedFieldList {
2275 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2276 match syntax.kind() {
2277 NAMED_FIELD_LIST => Some(NamedFieldList::from_repr(syntax.into_repr())),
2281 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2284 impl ToOwned for NamedFieldList {
2285 type Owned = TreeArc<NamedFieldList>;
2286 fn to_owned(&self) -> TreeArc<NamedFieldList> { TreeArc::cast(self.syntax.to_owned()) }
2290 impl NamedFieldList {
2291 pub fn fields(&self) -> impl Iterator<Item = &NamedField> {
2292 super::children(self)
2297 #[derive(Debug, PartialEq, Eq, Hash)]
2298 #[repr(transparent)]
2299 pub struct NeverType {
2300 pub(crate) syntax: SyntaxNode,
2302 unsafe impl TransparentNewType for NeverType {
2303 type Repr = rowan::SyntaxNode<RaTypes>;
2306 impl AstNode for NeverType {
2307 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2308 match syntax.kind() {
2309 NEVER_TYPE => Some(NeverType::from_repr(syntax.into_repr())),
2313 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2316 impl ToOwned for NeverType {
2317 type Owned = TreeArc<NeverType>;
2318 fn to_owned(&self) -> TreeArc<NeverType> { TreeArc::cast(self.syntax.to_owned()) }
2325 #[derive(Debug, PartialEq, Eq, Hash)]
2326 #[repr(transparent)]
2327 pub struct NominalDef {
2328 pub(crate) syntax: SyntaxNode,
2330 unsafe impl TransparentNewType for NominalDef {
2331 type Repr = rowan::SyntaxNode<RaTypes>;
2334 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2335 pub enum NominalDefKind<'a> {
2336 StructDef(&'a StructDef),
2337 EnumDef(&'a EnumDef),
2339 impl<'a> From<&'a StructDef> for &'a NominalDef {
2340 fn from(n: &'a StructDef) -> &'a NominalDef {
2341 NominalDef::cast(&n.syntax).unwrap()
2344 impl<'a> From<&'a EnumDef> for &'a NominalDef {
2345 fn from(n: &'a EnumDef) -> &'a NominalDef {
2346 NominalDef::cast(&n.syntax).unwrap()
2351 impl AstNode for NominalDef {
2352 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2353 match syntax.kind() {
2355 | ENUM_DEF => Some(NominalDef::from_repr(syntax.into_repr())),
2359 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2362 impl ToOwned for NominalDef {
2363 type Owned = TreeArc<NominalDef>;
2364 fn to_owned(&self) -> TreeArc<NominalDef> { TreeArc::cast(self.syntax.to_owned()) }
2368 pub fn kind(&self) -> NominalDefKind {
2369 match self.syntax.kind() {
2370 STRUCT_DEF => NominalDefKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2371 ENUM_DEF => NominalDefKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2372 _ => unreachable!(),
2377 impl ast::NameOwner for NominalDef {}
2378 impl ast::TypeParamsOwner for NominalDef {}
2379 impl ast::AttrsOwner for NominalDef {}
2383 #[derive(Debug, PartialEq, Eq, Hash)]
2384 #[repr(transparent)]
2386 pub(crate) syntax: SyntaxNode,
2388 unsafe impl TransparentNewType for Param {
2389 type Repr = rowan::SyntaxNode<RaTypes>;
2392 impl AstNode for Param {
2393 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2394 match syntax.kind() {
2395 PARAM => Some(Param::from_repr(syntax.into_repr())),
2399 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2402 impl ToOwned for Param {
2403 type Owned = TreeArc<Param>;
2404 fn to_owned(&self) -> TreeArc<Param> { TreeArc::cast(self.syntax.to_owned()) }
2408 impl ast::TypeAscriptionOwner for Param {}
2410 pub fn pat(&self) -> Option<&Pat> {
2411 super::child_opt(self)
2416 #[derive(Debug, PartialEq, Eq, Hash)]
2417 #[repr(transparent)]
2418 pub struct ParamList {
2419 pub(crate) syntax: SyntaxNode,
2421 unsafe impl TransparentNewType for ParamList {
2422 type Repr = rowan::SyntaxNode<RaTypes>;
2425 impl AstNode for ParamList {
2426 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2427 match syntax.kind() {
2428 PARAM_LIST => Some(ParamList::from_repr(syntax.into_repr())),
2432 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2435 impl ToOwned for ParamList {
2436 type Owned = TreeArc<ParamList>;
2437 fn to_owned(&self) -> TreeArc<ParamList> { TreeArc::cast(self.syntax.to_owned()) }
2442 pub fn params(&self) -> impl Iterator<Item = &Param> {
2443 super::children(self)
2446 pub fn self_param(&self) -> Option<&SelfParam> {
2447 super::child_opt(self)
2452 #[derive(Debug, PartialEq, Eq, Hash)]
2453 #[repr(transparent)]
2454 pub struct ParenExpr {
2455 pub(crate) syntax: SyntaxNode,
2457 unsafe impl TransparentNewType for ParenExpr {
2458 type Repr = rowan::SyntaxNode<RaTypes>;
2461 impl AstNode for ParenExpr {
2462 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2463 match syntax.kind() {
2464 PAREN_EXPR => Some(ParenExpr::from_repr(syntax.into_repr())),
2468 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2471 impl ToOwned for ParenExpr {
2472 type Owned = TreeArc<ParenExpr>;
2473 fn to_owned(&self) -> TreeArc<ParenExpr> { TreeArc::cast(self.syntax.to_owned()) }
2478 pub fn expr(&self) -> Option<&Expr> {
2479 super::child_opt(self)
2484 #[derive(Debug, PartialEq, Eq, Hash)]
2485 #[repr(transparent)]
2486 pub struct ParenType {
2487 pub(crate) syntax: SyntaxNode,
2489 unsafe impl TransparentNewType for ParenType {
2490 type Repr = rowan::SyntaxNode<RaTypes>;
2493 impl AstNode for ParenType {
2494 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2495 match syntax.kind() {
2496 PAREN_TYPE => Some(ParenType::from_repr(syntax.into_repr())),
2500 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2503 impl ToOwned for ParenType {
2504 type Owned = TreeArc<ParenType>;
2505 fn to_owned(&self) -> TreeArc<ParenType> { TreeArc::cast(self.syntax.to_owned()) }
2510 pub fn type_ref(&self) -> Option<&TypeRef> {
2511 super::child_opt(self)
2516 #[derive(Debug, PartialEq, Eq, Hash)]
2517 #[repr(transparent)]
2519 pub(crate) syntax: SyntaxNode,
2521 unsafe impl TransparentNewType for Pat {
2522 type Repr = rowan::SyntaxNode<RaTypes>;
2525 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2526 pub enum PatKind<'a> {
2528 BindPat(&'a BindPat),
2529 PlaceholderPat(&'a PlaceholderPat),
2530 PathPat(&'a PathPat),
2531 StructPat(&'a StructPat),
2532 TupleStructPat(&'a TupleStructPat),
2533 TuplePat(&'a TuplePat),
2534 SlicePat(&'a SlicePat),
2535 RangePat(&'a RangePat),
2536 LiteralPat(&'a LiteralPat),
2538 impl<'a> From<&'a RefPat> for &'a Pat {
2539 fn from(n: &'a RefPat) -> &'a Pat {
2540 Pat::cast(&n.syntax).unwrap()
2543 impl<'a> From<&'a BindPat> for &'a Pat {
2544 fn from(n: &'a BindPat) -> &'a Pat {
2545 Pat::cast(&n.syntax).unwrap()
2548 impl<'a> From<&'a PlaceholderPat> for &'a Pat {
2549 fn from(n: &'a PlaceholderPat) -> &'a Pat {
2550 Pat::cast(&n.syntax).unwrap()
2553 impl<'a> From<&'a PathPat> for &'a Pat {
2554 fn from(n: &'a PathPat) -> &'a Pat {
2555 Pat::cast(&n.syntax).unwrap()
2558 impl<'a> From<&'a StructPat> for &'a Pat {
2559 fn from(n: &'a StructPat) -> &'a Pat {
2560 Pat::cast(&n.syntax).unwrap()
2563 impl<'a> From<&'a TupleStructPat> for &'a Pat {
2564 fn from(n: &'a TupleStructPat) -> &'a Pat {
2565 Pat::cast(&n.syntax).unwrap()
2568 impl<'a> From<&'a TuplePat> for &'a Pat {
2569 fn from(n: &'a TuplePat) -> &'a Pat {
2570 Pat::cast(&n.syntax).unwrap()
2573 impl<'a> From<&'a SlicePat> for &'a Pat {
2574 fn from(n: &'a SlicePat) -> &'a Pat {
2575 Pat::cast(&n.syntax).unwrap()
2578 impl<'a> From<&'a RangePat> for &'a Pat {
2579 fn from(n: &'a RangePat) -> &'a Pat {
2580 Pat::cast(&n.syntax).unwrap()
2583 impl<'a> From<&'a LiteralPat> for &'a Pat {
2584 fn from(n: &'a LiteralPat) -> &'a Pat {
2585 Pat::cast(&n.syntax).unwrap()
2590 impl AstNode for Pat {
2591 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2592 match syntax.kind() {
2602 | LITERAL_PAT => Some(Pat::from_repr(syntax.into_repr())),
2606 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2609 impl ToOwned for Pat {
2610 type Owned = TreeArc<Pat>;
2611 fn to_owned(&self) -> TreeArc<Pat> { TreeArc::cast(self.syntax.to_owned()) }
2615 pub fn kind(&self) -> PatKind {
2616 match self.syntax.kind() {
2617 REF_PAT => PatKind::RefPat(RefPat::cast(&self.syntax).unwrap()),
2618 BIND_PAT => PatKind::BindPat(BindPat::cast(&self.syntax).unwrap()),
2619 PLACEHOLDER_PAT => PatKind::PlaceholderPat(PlaceholderPat::cast(&self.syntax).unwrap()),
2620 PATH_PAT => PatKind::PathPat(PathPat::cast(&self.syntax).unwrap()),
2621 STRUCT_PAT => PatKind::StructPat(StructPat::cast(&self.syntax).unwrap()),
2622 TUPLE_STRUCT_PAT => PatKind::TupleStructPat(TupleStructPat::cast(&self.syntax).unwrap()),
2623 TUPLE_PAT => PatKind::TuplePat(TuplePat::cast(&self.syntax).unwrap()),
2624 SLICE_PAT => PatKind::SlicePat(SlicePat::cast(&self.syntax).unwrap()),
2625 RANGE_PAT => PatKind::RangePat(RangePat::cast(&self.syntax).unwrap()),
2626 LITERAL_PAT => PatKind::LiteralPat(LiteralPat::cast(&self.syntax).unwrap()),
2627 _ => unreachable!(),
2635 #[derive(Debug, PartialEq, Eq, Hash)]
2636 #[repr(transparent)]
2638 pub(crate) syntax: SyntaxNode,
2640 unsafe impl TransparentNewType for Path {
2641 type Repr = rowan::SyntaxNode<RaTypes>;
2644 impl AstNode for Path {
2645 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2646 match syntax.kind() {
2647 PATH => Some(Path::from_repr(syntax.into_repr())),
2651 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2654 impl ToOwned for Path {
2655 type Owned = TreeArc<Path>;
2656 fn to_owned(&self) -> TreeArc<Path> { TreeArc::cast(self.syntax.to_owned()) }
2661 pub fn segment(&self) -> Option<&PathSegment> {
2662 super::child_opt(self)
2665 pub fn qualifier(&self) -> Option<&Path> {
2666 super::child_opt(self)
2671 #[derive(Debug, PartialEq, Eq, Hash)]
2672 #[repr(transparent)]
2673 pub struct PathExpr {
2674 pub(crate) syntax: SyntaxNode,
2676 unsafe impl TransparentNewType for PathExpr {
2677 type Repr = rowan::SyntaxNode<RaTypes>;
2680 impl AstNode for PathExpr {
2681 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2682 match syntax.kind() {
2683 PATH_EXPR => Some(PathExpr::from_repr(syntax.into_repr())),
2687 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2690 impl ToOwned for PathExpr {
2691 type Owned = TreeArc<PathExpr>;
2692 fn to_owned(&self) -> TreeArc<PathExpr> { TreeArc::cast(self.syntax.to_owned()) }
2697 pub fn path(&self) -> Option<&Path> {
2698 super::child_opt(self)
2703 #[derive(Debug, PartialEq, Eq, Hash)]
2704 #[repr(transparent)]
2705 pub struct PathPat {
2706 pub(crate) syntax: SyntaxNode,
2708 unsafe impl TransparentNewType for PathPat {
2709 type Repr = rowan::SyntaxNode<RaTypes>;
2712 impl AstNode for PathPat {
2713 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2714 match syntax.kind() {
2715 PATH_PAT => Some(PathPat::from_repr(syntax.into_repr())),
2719 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2722 impl ToOwned for PathPat {
2723 type Owned = TreeArc<PathPat>;
2724 fn to_owned(&self) -> TreeArc<PathPat> { TreeArc::cast(self.syntax.to_owned()) }
2729 pub fn path(&self) -> Option<&Path> {
2730 super::child_opt(self)
2735 #[derive(Debug, PartialEq, Eq, Hash)]
2736 #[repr(transparent)]
2737 pub struct PathSegment {
2738 pub(crate) syntax: SyntaxNode,
2740 unsafe impl TransparentNewType for PathSegment {
2741 type Repr = rowan::SyntaxNode<RaTypes>;
2744 impl AstNode for PathSegment {
2745 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2746 match syntax.kind() {
2747 PATH_SEGMENT => Some(PathSegment::from_repr(syntax.into_repr())),
2751 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2754 impl ToOwned for PathSegment {
2755 type Owned = TreeArc<PathSegment>;
2756 fn to_owned(&self) -> TreeArc<PathSegment> { TreeArc::cast(self.syntax.to_owned()) }
2761 pub fn name_ref(&self) -> Option<&NameRef> {
2762 super::child_opt(self)
2765 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
2766 super::child_opt(self)
2771 #[derive(Debug, PartialEq, Eq, Hash)]
2772 #[repr(transparent)]
2773 pub struct PathType {
2774 pub(crate) syntax: SyntaxNode,
2776 unsafe impl TransparentNewType for PathType {
2777 type Repr = rowan::SyntaxNode<RaTypes>;
2780 impl AstNode for PathType {
2781 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2782 match syntax.kind() {
2783 PATH_TYPE => Some(PathType::from_repr(syntax.into_repr())),
2787 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2790 impl ToOwned for PathType {
2791 type Owned = TreeArc<PathType>;
2792 fn to_owned(&self) -> TreeArc<PathType> { TreeArc::cast(self.syntax.to_owned()) }
2797 pub fn path(&self) -> Option<&Path> {
2798 super::child_opt(self)
2803 #[derive(Debug, PartialEq, Eq, Hash)]
2804 #[repr(transparent)]
2805 pub struct PlaceholderPat {
2806 pub(crate) syntax: SyntaxNode,
2808 unsafe impl TransparentNewType for PlaceholderPat {
2809 type Repr = rowan::SyntaxNode<RaTypes>;
2812 impl AstNode for PlaceholderPat {
2813 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2814 match syntax.kind() {
2815 PLACEHOLDER_PAT => Some(PlaceholderPat::from_repr(syntax.into_repr())),
2819 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2822 impl ToOwned for PlaceholderPat {
2823 type Owned = TreeArc<PlaceholderPat>;
2824 fn to_owned(&self) -> TreeArc<PlaceholderPat> { TreeArc::cast(self.syntax.to_owned()) }
2828 impl PlaceholderPat {}
2831 #[derive(Debug, PartialEq, Eq, Hash)]
2832 #[repr(transparent)]
2833 pub struct PlaceholderType {
2834 pub(crate) syntax: SyntaxNode,
2836 unsafe impl TransparentNewType for PlaceholderType {
2837 type Repr = rowan::SyntaxNode<RaTypes>;
2840 impl AstNode for PlaceholderType {
2841 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2842 match syntax.kind() {
2843 PLACEHOLDER_TYPE => Some(PlaceholderType::from_repr(syntax.into_repr())),
2847 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2850 impl ToOwned for PlaceholderType {
2851 type Owned = TreeArc<PlaceholderType>;
2852 fn to_owned(&self) -> TreeArc<PlaceholderType> { TreeArc::cast(self.syntax.to_owned()) }
2856 impl PlaceholderType {}
2859 #[derive(Debug, PartialEq, Eq, Hash)]
2860 #[repr(transparent)]
2861 pub struct PointerType {
2862 pub(crate) syntax: SyntaxNode,
2864 unsafe impl TransparentNewType for PointerType {
2865 type Repr = rowan::SyntaxNode<RaTypes>;
2868 impl AstNode for PointerType {
2869 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2870 match syntax.kind() {
2871 POINTER_TYPE => Some(PointerType::from_repr(syntax.into_repr())),
2875 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2878 impl ToOwned for PointerType {
2879 type Owned = TreeArc<PointerType>;
2880 fn to_owned(&self) -> TreeArc<PointerType> { TreeArc::cast(self.syntax.to_owned()) }
2885 pub fn type_ref(&self) -> Option<&TypeRef> {
2886 super::child_opt(self)
2891 #[derive(Debug, PartialEq, Eq, Hash)]
2892 #[repr(transparent)]
2893 pub struct PosFieldDef {
2894 pub(crate) syntax: SyntaxNode,
2896 unsafe impl TransparentNewType for PosFieldDef {
2897 type Repr = rowan::SyntaxNode<RaTypes>;
2900 impl AstNode for PosFieldDef {
2901 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2902 match syntax.kind() {
2903 POS_FIELD_DEF => Some(PosFieldDef::from_repr(syntax.into_repr())),
2907 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2910 impl ToOwned for PosFieldDef {
2911 type Owned = TreeArc<PosFieldDef>;
2912 fn to_owned(&self) -> TreeArc<PosFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2916 impl ast::VisibilityOwner for PosFieldDef {}
2917 impl ast::AttrsOwner for PosFieldDef {}
2919 pub fn type_ref(&self) -> Option<&TypeRef> {
2920 super::child_opt(self)
2925 #[derive(Debug, PartialEq, Eq, Hash)]
2926 #[repr(transparent)]
2927 pub struct PosFieldDefList {
2928 pub(crate) syntax: SyntaxNode,
2930 unsafe impl TransparentNewType for PosFieldDefList {
2931 type Repr = rowan::SyntaxNode<RaTypes>;
2934 impl AstNode for PosFieldDefList {
2935 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2936 match syntax.kind() {
2937 POS_FIELD_DEF_LIST => Some(PosFieldDefList::from_repr(syntax.into_repr())),
2941 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2944 impl ToOwned for PosFieldDefList {
2945 type Owned = TreeArc<PosFieldDefList>;
2946 fn to_owned(&self) -> TreeArc<PosFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
2950 impl PosFieldDefList {
2951 pub fn fields(&self) -> impl Iterator<Item = &PosFieldDef> {
2952 super::children(self)
2957 #[derive(Debug, PartialEq, Eq, Hash)]
2958 #[repr(transparent)]
2959 pub struct PrefixExpr {
2960 pub(crate) syntax: SyntaxNode,
2962 unsafe impl TransparentNewType for PrefixExpr {
2963 type Repr = rowan::SyntaxNode<RaTypes>;
2966 impl AstNode for PrefixExpr {
2967 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2968 match syntax.kind() {
2969 PREFIX_EXPR => Some(PrefixExpr::from_repr(syntax.into_repr())),
2973 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2976 impl ToOwned for PrefixExpr {
2977 type Owned = TreeArc<PrefixExpr>;
2978 fn to_owned(&self) -> TreeArc<PrefixExpr> { TreeArc::cast(self.syntax.to_owned()) }
2983 pub fn expr(&self) -> Option<&Expr> {
2984 super::child_opt(self)
2989 #[derive(Debug, PartialEq, Eq, Hash)]
2990 #[repr(transparent)]
2991 pub struct RangeExpr {
2992 pub(crate) syntax: SyntaxNode,
2994 unsafe impl TransparentNewType for RangeExpr {
2995 type Repr = rowan::SyntaxNode<RaTypes>;
2998 impl AstNode for RangeExpr {
2999 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3000 match syntax.kind() {
3001 RANGE_EXPR => Some(RangeExpr::from_repr(syntax.into_repr())),
3005 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3008 impl ToOwned for RangeExpr {
3009 type Owned = TreeArc<RangeExpr>;
3010 fn to_owned(&self) -> TreeArc<RangeExpr> { TreeArc::cast(self.syntax.to_owned()) }
3017 #[derive(Debug, PartialEq, Eq, Hash)]
3018 #[repr(transparent)]
3019 pub struct RangePat {
3020 pub(crate) syntax: SyntaxNode,
3022 unsafe impl TransparentNewType for RangePat {
3023 type Repr = rowan::SyntaxNode<RaTypes>;
3026 impl AstNode for RangePat {
3027 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3028 match syntax.kind() {
3029 RANGE_PAT => Some(RangePat::from_repr(syntax.into_repr())),
3033 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3036 impl ToOwned for RangePat {
3037 type Owned = TreeArc<RangePat>;
3038 fn to_owned(&self) -> TreeArc<RangePat> { TreeArc::cast(self.syntax.to_owned()) }
3045 #[derive(Debug, PartialEq, Eq, Hash)]
3046 #[repr(transparent)]
3047 pub struct RefExpr {
3048 pub(crate) syntax: SyntaxNode,
3050 unsafe impl TransparentNewType for RefExpr {
3051 type Repr = rowan::SyntaxNode<RaTypes>;
3054 impl AstNode for RefExpr {
3055 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3056 match syntax.kind() {
3057 REF_EXPR => Some(RefExpr::from_repr(syntax.into_repr())),
3061 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3064 impl ToOwned for RefExpr {
3065 type Owned = TreeArc<RefExpr>;
3066 fn to_owned(&self) -> TreeArc<RefExpr> { TreeArc::cast(self.syntax.to_owned()) }
3071 pub fn expr(&self) -> Option<&Expr> {
3072 super::child_opt(self)
3077 #[derive(Debug, PartialEq, Eq, Hash)]
3078 #[repr(transparent)]
3080 pub(crate) syntax: SyntaxNode,
3082 unsafe impl TransparentNewType for RefPat {
3083 type Repr = rowan::SyntaxNode<RaTypes>;
3086 impl AstNode for RefPat {
3087 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3088 match syntax.kind() {
3089 REF_PAT => Some(RefPat::from_repr(syntax.into_repr())),
3093 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3096 impl ToOwned for RefPat {
3097 type Owned = TreeArc<RefPat>;
3098 fn to_owned(&self) -> TreeArc<RefPat> { TreeArc::cast(self.syntax.to_owned()) }
3103 pub fn pat(&self) -> Option<&Pat> {
3104 super::child_opt(self)
3109 #[derive(Debug, PartialEq, Eq, Hash)]
3110 #[repr(transparent)]
3111 pub struct ReferenceType {
3112 pub(crate) syntax: SyntaxNode,
3114 unsafe impl TransparentNewType for ReferenceType {
3115 type Repr = rowan::SyntaxNode<RaTypes>;
3118 impl AstNode for ReferenceType {
3119 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3120 match syntax.kind() {
3121 REFERENCE_TYPE => Some(ReferenceType::from_repr(syntax.into_repr())),
3125 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3128 impl ToOwned for ReferenceType {
3129 type Owned = TreeArc<ReferenceType>;
3130 fn to_owned(&self) -> TreeArc<ReferenceType> { TreeArc::cast(self.syntax.to_owned()) }
3134 impl ReferenceType {
3135 pub fn type_ref(&self) -> Option<&TypeRef> {
3136 super::child_opt(self)
3141 #[derive(Debug, PartialEq, Eq, Hash)]
3142 #[repr(transparent)]
3143 pub struct RetType {
3144 pub(crate) syntax: SyntaxNode,
3146 unsafe impl TransparentNewType for RetType {
3147 type Repr = rowan::SyntaxNode<RaTypes>;
3150 impl AstNode for RetType {
3151 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3152 match syntax.kind() {
3153 RET_TYPE => Some(RetType::from_repr(syntax.into_repr())),
3157 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3160 impl ToOwned for RetType {
3161 type Owned = TreeArc<RetType>;
3162 fn to_owned(&self) -> TreeArc<RetType> { TreeArc::cast(self.syntax.to_owned()) }
3167 pub fn type_ref(&self) -> Option<&TypeRef> {
3168 super::child_opt(self)
3173 #[derive(Debug, PartialEq, Eq, Hash)]
3174 #[repr(transparent)]
3175 pub struct ReturnExpr {
3176 pub(crate) syntax: SyntaxNode,
3178 unsafe impl TransparentNewType for ReturnExpr {
3179 type Repr = rowan::SyntaxNode<RaTypes>;
3182 impl AstNode for ReturnExpr {
3183 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3184 match syntax.kind() {
3185 RETURN_EXPR => Some(ReturnExpr::from_repr(syntax.into_repr())),
3189 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3192 impl ToOwned for ReturnExpr {
3193 type Owned = TreeArc<ReturnExpr>;
3194 fn to_owned(&self) -> TreeArc<ReturnExpr> { TreeArc::cast(self.syntax.to_owned()) }
3199 pub fn expr(&self) -> Option<&Expr> {
3200 super::child_opt(self)
3205 #[derive(Debug, PartialEq, Eq, Hash)]
3206 #[repr(transparent)]
3207 pub struct SelfParam {
3208 pub(crate) syntax: SyntaxNode,
3210 unsafe impl TransparentNewType for SelfParam {
3211 type Repr = rowan::SyntaxNode<RaTypes>;
3214 impl AstNode for SelfParam {
3215 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3216 match syntax.kind() {
3217 SELF_PARAM => Some(SelfParam::from_repr(syntax.into_repr())),
3221 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3224 impl ToOwned for SelfParam {
3225 type Owned = TreeArc<SelfParam>;
3226 fn to_owned(&self) -> TreeArc<SelfParam> { TreeArc::cast(self.syntax.to_owned()) }
3230 impl ast::TypeAscriptionOwner for SelfParam {}
3234 #[derive(Debug, PartialEq, Eq, Hash)]
3235 #[repr(transparent)]
3236 pub struct SlicePat {
3237 pub(crate) syntax: SyntaxNode,
3239 unsafe impl TransparentNewType for SlicePat {
3240 type Repr = rowan::SyntaxNode<RaTypes>;
3243 impl AstNode for SlicePat {
3244 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3245 match syntax.kind() {
3246 SLICE_PAT => Some(SlicePat::from_repr(syntax.into_repr())),
3250 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3253 impl ToOwned for SlicePat {
3254 type Owned = TreeArc<SlicePat>;
3255 fn to_owned(&self) -> TreeArc<SlicePat> { TreeArc::cast(self.syntax.to_owned()) }
3262 #[derive(Debug, PartialEq, Eq, Hash)]
3263 #[repr(transparent)]
3264 pub struct SliceType {
3265 pub(crate) syntax: SyntaxNode,
3267 unsafe impl TransparentNewType for SliceType {
3268 type Repr = rowan::SyntaxNode<RaTypes>;
3271 impl AstNode for SliceType {
3272 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3273 match syntax.kind() {
3274 SLICE_TYPE => Some(SliceType::from_repr(syntax.into_repr())),
3278 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3281 impl ToOwned for SliceType {
3282 type Owned = TreeArc<SliceType>;
3283 fn to_owned(&self) -> TreeArc<SliceType> { TreeArc::cast(self.syntax.to_owned()) }
3288 pub fn type_ref(&self) -> Option<&TypeRef> {
3289 super::child_opt(self)
3294 #[derive(Debug, PartialEq, Eq, Hash)]
3295 #[repr(transparent)]
3296 pub struct SourceFile {
3297 pub(crate) syntax: SyntaxNode,
3299 unsafe impl TransparentNewType for SourceFile {
3300 type Repr = rowan::SyntaxNode<RaTypes>;
3303 impl AstNode for SourceFile {
3304 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3305 match syntax.kind() {
3306 SOURCE_FILE => Some(SourceFile::from_repr(syntax.into_repr())),
3310 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3313 impl ToOwned for SourceFile {
3314 type Owned = TreeArc<SourceFile>;
3315 fn to_owned(&self) -> TreeArc<SourceFile> { TreeArc::cast(self.syntax.to_owned()) }
3319 impl ast::ModuleItemOwner for SourceFile {}
3320 impl ast::FnDefOwner for SourceFile {}
3322 pub fn modules(&self) -> impl Iterator<Item = &Module> {
3323 super::children(self)
3328 #[derive(Debug, PartialEq, Eq, Hash)]
3329 #[repr(transparent)]
3330 pub struct StaticDef {
3331 pub(crate) syntax: SyntaxNode,
3333 unsafe impl TransparentNewType for StaticDef {
3334 type Repr = rowan::SyntaxNode<RaTypes>;
3337 impl AstNode for StaticDef {
3338 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3339 match syntax.kind() {
3340 STATIC_DEF => Some(StaticDef::from_repr(syntax.into_repr())),
3344 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3347 impl ToOwned for StaticDef {
3348 type Owned = TreeArc<StaticDef>;
3349 fn to_owned(&self) -> TreeArc<StaticDef> { TreeArc::cast(self.syntax.to_owned()) }
3353 impl ast::VisibilityOwner for StaticDef {}
3354 impl ast::NameOwner for StaticDef {}
3355 impl ast::TypeParamsOwner for StaticDef {}
3356 impl ast::AttrsOwner for StaticDef {}
3357 impl ast::DocCommentsOwner for StaticDef {}
3358 impl ast::TypeAscriptionOwner for StaticDef {}
3362 #[derive(Debug, PartialEq, Eq, Hash)]
3363 #[repr(transparent)]
3365 pub(crate) syntax: SyntaxNode,
3367 unsafe impl TransparentNewType for Stmt {
3368 type Repr = rowan::SyntaxNode<RaTypes>;
3371 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3372 pub enum StmtKind<'a> {
3373 ExprStmt(&'a ExprStmt),
3374 LetStmt(&'a LetStmt),
3376 impl<'a> From<&'a ExprStmt> for &'a Stmt {
3377 fn from(n: &'a ExprStmt) -> &'a Stmt {
3378 Stmt::cast(&n.syntax).unwrap()
3381 impl<'a> From<&'a LetStmt> for &'a Stmt {
3382 fn from(n: &'a LetStmt) -> &'a Stmt {
3383 Stmt::cast(&n.syntax).unwrap()
3388 impl AstNode for Stmt {
3389 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3390 match syntax.kind() {
3392 | LET_STMT => Some(Stmt::from_repr(syntax.into_repr())),
3396 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3399 impl ToOwned for Stmt {
3400 type Owned = TreeArc<Stmt>;
3401 fn to_owned(&self) -> TreeArc<Stmt> { TreeArc::cast(self.syntax.to_owned()) }
3405 pub fn kind(&self) -> StmtKind {
3406 match self.syntax.kind() {
3407 EXPR_STMT => StmtKind::ExprStmt(ExprStmt::cast(&self.syntax).unwrap()),
3408 LET_STMT => StmtKind::LetStmt(LetStmt::cast(&self.syntax).unwrap()),
3409 _ => unreachable!(),
3417 #[derive(Debug, PartialEq, Eq, Hash)]
3418 #[repr(transparent)]
3419 pub struct StructDef {
3420 pub(crate) syntax: SyntaxNode,
3422 unsafe impl TransparentNewType for StructDef {
3423 type Repr = rowan::SyntaxNode<RaTypes>;
3426 impl AstNode for StructDef {
3427 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3428 match syntax.kind() {
3429 STRUCT_DEF => Some(StructDef::from_repr(syntax.into_repr())),
3433 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3436 impl ToOwned for StructDef {
3437 type Owned = TreeArc<StructDef>;
3438 fn to_owned(&self) -> TreeArc<StructDef> { TreeArc::cast(self.syntax.to_owned()) }
3442 impl ast::VisibilityOwner for StructDef {}
3443 impl ast::NameOwner for StructDef {}
3444 impl ast::TypeParamsOwner for StructDef {}
3445 impl ast::AttrsOwner for StructDef {}
3446 impl ast::DocCommentsOwner for StructDef {}
3450 #[derive(Debug, PartialEq, Eq, Hash)]
3451 #[repr(transparent)]
3452 pub struct StructLit {
3453 pub(crate) syntax: SyntaxNode,
3455 unsafe impl TransparentNewType for StructLit {
3456 type Repr = rowan::SyntaxNode<RaTypes>;
3459 impl AstNode for StructLit {
3460 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3461 match syntax.kind() {
3462 STRUCT_LIT => Some(StructLit::from_repr(syntax.into_repr())),
3466 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3469 impl ToOwned for StructLit {
3470 type Owned = TreeArc<StructLit>;
3471 fn to_owned(&self) -> TreeArc<StructLit> { TreeArc::cast(self.syntax.to_owned()) }
3476 pub fn path(&self) -> Option<&Path> {
3477 super::child_opt(self)
3480 pub fn named_field_list(&self) -> Option<&NamedFieldList> {
3481 super::child_opt(self)
3484 pub fn spread(&self) -> Option<&Expr> {
3485 super::child_opt(self)
3490 #[derive(Debug, PartialEq, Eq, Hash)]
3491 #[repr(transparent)]
3492 pub struct StructPat {
3493 pub(crate) syntax: SyntaxNode,
3495 unsafe impl TransparentNewType for StructPat {
3496 type Repr = rowan::SyntaxNode<RaTypes>;
3499 impl AstNode for StructPat {
3500 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3501 match syntax.kind() {
3502 STRUCT_PAT => Some(StructPat::from_repr(syntax.into_repr())),
3506 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3509 impl ToOwned for StructPat {
3510 type Owned = TreeArc<StructPat>;
3511 fn to_owned(&self) -> TreeArc<StructPat> { TreeArc::cast(self.syntax.to_owned()) }
3516 pub fn field_pat_list(&self) -> Option<&FieldPatList> {
3517 super::child_opt(self)
3520 pub fn path(&self) -> Option<&Path> {
3521 super::child_opt(self)
3526 #[derive(Debug, PartialEq, Eq, Hash)]
3527 #[repr(transparent)]
3528 pub struct TokenTree {
3529 pub(crate) syntax: SyntaxNode,
3531 unsafe impl TransparentNewType for TokenTree {
3532 type Repr = rowan::SyntaxNode<RaTypes>;
3535 impl AstNode for TokenTree {
3536 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3537 match syntax.kind() {
3538 TOKEN_TREE => Some(TokenTree::from_repr(syntax.into_repr())),
3542 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3545 impl ToOwned for TokenTree {
3546 type Owned = TreeArc<TokenTree>;
3547 fn to_owned(&self) -> TreeArc<TokenTree> { TreeArc::cast(self.syntax.to_owned()) }
3554 #[derive(Debug, PartialEq, Eq, Hash)]
3555 #[repr(transparent)]
3556 pub struct TraitDef {
3557 pub(crate) syntax: SyntaxNode,
3559 unsafe impl TransparentNewType for TraitDef {
3560 type Repr = rowan::SyntaxNode<RaTypes>;
3563 impl AstNode for TraitDef {
3564 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3565 match syntax.kind() {
3566 TRAIT_DEF => Some(TraitDef::from_repr(syntax.into_repr())),
3570 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3573 impl ToOwned for TraitDef {
3574 type Owned = TreeArc<TraitDef>;
3575 fn to_owned(&self) -> TreeArc<TraitDef> { TreeArc::cast(self.syntax.to_owned()) }
3579 impl ast::VisibilityOwner for TraitDef {}
3580 impl ast::NameOwner for TraitDef {}
3581 impl ast::AttrsOwner for TraitDef {}
3582 impl ast::DocCommentsOwner for TraitDef {}
3583 impl ast::TypeParamsOwner for TraitDef {}
3584 impl ast::TypeBoundsOwner for TraitDef {}
3586 pub fn item_list(&self) -> Option<&ItemList> {
3587 super::child_opt(self)
3592 #[derive(Debug, PartialEq, Eq, Hash)]
3593 #[repr(transparent)]
3594 pub struct TryExpr {
3595 pub(crate) syntax: SyntaxNode,
3597 unsafe impl TransparentNewType for TryExpr {
3598 type Repr = rowan::SyntaxNode<RaTypes>;
3601 impl AstNode for TryExpr {
3602 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3603 match syntax.kind() {
3604 TRY_EXPR => Some(TryExpr::from_repr(syntax.into_repr())),
3608 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3611 impl ToOwned for TryExpr {
3612 type Owned = TreeArc<TryExpr>;
3613 fn to_owned(&self) -> TreeArc<TryExpr> { TreeArc::cast(self.syntax.to_owned()) }
3618 pub fn expr(&self) -> Option<&Expr> {
3619 super::child_opt(self)
3624 #[derive(Debug, PartialEq, Eq, Hash)]
3625 #[repr(transparent)]
3626 pub struct TupleExpr {
3627 pub(crate) syntax: SyntaxNode,
3629 unsafe impl TransparentNewType for TupleExpr {
3630 type Repr = rowan::SyntaxNode<RaTypes>;
3633 impl AstNode for TupleExpr {
3634 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3635 match syntax.kind() {
3636 TUPLE_EXPR => Some(TupleExpr::from_repr(syntax.into_repr())),
3640 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3643 impl ToOwned for TupleExpr {
3644 type Owned = TreeArc<TupleExpr>;
3645 fn to_owned(&self) -> TreeArc<TupleExpr> { TreeArc::cast(self.syntax.to_owned()) }
3650 pub fn exprs(&self) -> impl Iterator<Item = &Expr> {
3651 super::children(self)
3656 #[derive(Debug, PartialEq, Eq, Hash)]
3657 #[repr(transparent)]
3658 pub struct TuplePat {
3659 pub(crate) syntax: SyntaxNode,
3661 unsafe impl TransparentNewType for TuplePat {
3662 type Repr = rowan::SyntaxNode<RaTypes>;
3665 impl AstNode for TuplePat {
3666 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3667 match syntax.kind() {
3668 TUPLE_PAT => Some(TuplePat::from_repr(syntax.into_repr())),
3672 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3675 impl ToOwned for TuplePat {
3676 type Owned = TreeArc<TuplePat>;
3677 fn to_owned(&self) -> TreeArc<TuplePat> { TreeArc::cast(self.syntax.to_owned()) }
3682 pub fn args(&self) -> impl Iterator<Item = &Pat> {
3683 super::children(self)
3688 #[derive(Debug, PartialEq, Eq, Hash)]
3689 #[repr(transparent)]
3690 pub struct TupleStructPat {
3691 pub(crate) syntax: SyntaxNode,
3693 unsafe impl TransparentNewType for TupleStructPat {
3694 type Repr = rowan::SyntaxNode<RaTypes>;
3697 impl AstNode for TupleStructPat {
3698 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3699 match syntax.kind() {
3700 TUPLE_STRUCT_PAT => Some(TupleStructPat::from_repr(syntax.into_repr())),
3704 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3707 impl ToOwned for TupleStructPat {
3708 type Owned = TreeArc<TupleStructPat>;
3709 fn to_owned(&self) -> TreeArc<TupleStructPat> { TreeArc::cast(self.syntax.to_owned()) }
3713 impl TupleStructPat {
3714 pub fn args(&self) -> impl Iterator<Item = &Pat> {
3715 super::children(self)
3718 pub fn path(&self) -> Option<&Path> {
3719 super::child_opt(self)
3724 #[derive(Debug, PartialEq, Eq, Hash)]
3725 #[repr(transparent)]
3726 pub struct TupleType {
3727 pub(crate) syntax: SyntaxNode,
3729 unsafe impl TransparentNewType for TupleType {
3730 type Repr = rowan::SyntaxNode<RaTypes>;
3733 impl AstNode for TupleType {
3734 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3735 match syntax.kind() {
3736 TUPLE_TYPE => Some(TupleType::from_repr(syntax.into_repr())),
3740 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3743 impl ToOwned for TupleType {
3744 type Owned = TreeArc<TupleType>;
3745 fn to_owned(&self) -> TreeArc<TupleType> { TreeArc::cast(self.syntax.to_owned()) }
3750 pub fn fields(&self) -> impl Iterator<Item = &TypeRef> {
3751 super::children(self)
3756 #[derive(Debug, PartialEq, Eq, Hash)]
3757 #[repr(transparent)]
3758 pub struct TypeAliasDef {
3759 pub(crate) syntax: SyntaxNode,
3761 unsafe impl TransparentNewType for TypeAliasDef {
3762 type Repr = rowan::SyntaxNode<RaTypes>;
3765 impl AstNode for TypeAliasDef {
3766 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3767 match syntax.kind() {
3768 TYPE_ALIAS_DEF => Some(TypeAliasDef::from_repr(syntax.into_repr())),
3772 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3775 impl ToOwned for TypeAliasDef {
3776 type Owned = TreeArc<TypeAliasDef>;
3777 fn to_owned(&self) -> TreeArc<TypeAliasDef> { TreeArc::cast(self.syntax.to_owned()) }
3781 impl ast::VisibilityOwner for TypeAliasDef {}
3782 impl ast::NameOwner for TypeAliasDef {}
3783 impl ast::TypeParamsOwner for TypeAliasDef {}
3784 impl ast::AttrsOwner for TypeAliasDef {}
3785 impl ast::DocCommentsOwner for TypeAliasDef {}
3786 impl ast::TypeBoundsOwner for TypeAliasDef {}
3788 pub fn type_ref(&self) -> Option<&TypeRef> {
3789 super::child_opt(self)
3794 #[derive(Debug, PartialEq, Eq, Hash)]
3795 #[repr(transparent)]
3796 pub struct TypeArg {
3797 pub(crate) syntax: SyntaxNode,
3799 unsafe impl TransparentNewType for TypeArg {
3800 type Repr = rowan::SyntaxNode<RaTypes>;
3803 impl AstNode for TypeArg {
3804 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3805 match syntax.kind() {
3806 TYPE_ARG => Some(TypeArg::from_repr(syntax.into_repr())),
3810 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3813 impl ToOwned for TypeArg {
3814 type Owned = TreeArc<TypeArg>;
3815 fn to_owned(&self) -> TreeArc<TypeArg> { TreeArc::cast(self.syntax.to_owned()) }
3820 pub fn type_ref(&self) -> Option<&TypeRef> {
3821 super::child_opt(self)
3826 #[derive(Debug, PartialEq, Eq, Hash)]
3827 #[repr(transparent)]
3828 pub struct TypeArgList {
3829 pub(crate) syntax: SyntaxNode,
3831 unsafe impl TransparentNewType for TypeArgList {
3832 type Repr = rowan::SyntaxNode<RaTypes>;
3835 impl AstNode for TypeArgList {
3836 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3837 match syntax.kind() {
3838 TYPE_ARG_LIST => Some(TypeArgList::from_repr(syntax.into_repr())),
3842 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3845 impl ToOwned for TypeArgList {
3846 type Owned = TreeArc<TypeArgList>;
3847 fn to_owned(&self) -> TreeArc<TypeArgList> { TreeArc::cast(self.syntax.to_owned()) }
3852 pub fn type_args(&self) -> impl Iterator<Item = &TypeArg> {
3853 super::children(self)
3856 pub fn lifetime_args(&self) -> impl Iterator<Item = &LifetimeArg> {
3857 super::children(self)
3860 pub fn assoc_type_args(&self) -> impl Iterator<Item = &AssocTypeArg> {
3861 super::children(self)
3866 #[derive(Debug, PartialEq, Eq, Hash)]
3867 #[repr(transparent)]
3868 pub struct TypeBound {
3869 pub(crate) syntax: SyntaxNode,
3871 unsafe impl TransparentNewType for TypeBound {
3872 type Repr = rowan::SyntaxNode<RaTypes>;
3875 impl AstNode for TypeBound {
3876 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3877 match syntax.kind() {
3878 TYPE_BOUND => Some(TypeBound::from_repr(syntax.into_repr())),
3882 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3885 impl ToOwned for TypeBound {
3886 type Owned = TreeArc<TypeBound>;
3887 fn to_owned(&self) -> TreeArc<TypeBound> { TreeArc::cast(self.syntax.to_owned()) }
3892 pub fn type_ref(&self) -> Option<&TypeRef> {
3893 super::child_opt(self)
3898 #[derive(Debug, PartialEq, Eq, Hash)]
3899 #[repr(transparent)]
3900 pub struct TypeBoundList {
3901 pub(crate) syntax: SyntaxNode,
3903 unsafe impl TransparentNewType for TypeBoundList {
3904 type Repr = rowan::SyntaxNode<RaTypes>;
3907 impl AstNode for TypeBoundList {
3908 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3909 match syntax.kind() {
3910 TYPE_BOUND_LIST => Some(TypeBoundList::from_repr(syntax.into_repr())),
3914 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3917 impl ToOwned for TypeBoundList {
3918 type Owned = TreeArc<TypeBoundList>;
3919 fn to_owned(&self) -> TreeArc<TypeBoundList> { TreeArc::cast(self.syntax.to_owned()) }
3923 impl TypeBoundList {
3924 pub fn bounds(&self) -> impl Iterator<Item = &TypeBound> {
3925 super::children(self)
3930 #[derive(Debug, PartialEq, Eq, Hash)]
3931 #[repr(transparent)]
3932 pub struct TypeParam {
3933 pub(crate) syntax: SyntaxNode,
3935 unsafe impl TransparentNewType for TypeParam {
3936 type Repr = rowan::SyntaxNode<RaTypes>;
3939 impl AstNode for TypeParam {
3940 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3941 match syntax.kind() {
3942 TYPE_PARAM => Some(TypeParam::from_repr(syntax.into_repr())),
3946 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3949 impl ToOwned for TypeParam {
3950 type Owned = TreeArc<TypeParam>;
3951 fn to_owned(&self) -> TreeArc<TypeParam> { TreeArc::cast(self.syntax.to_owned()) }
3955 impl ast::NameOwner for TypeParam {}
3956 impl ast::AttrsOwner for TypeParam {}
3957 impl ast::TypeBoundsOwner for TypeParam {}
3961 #[derive(Debug, PartialEq, Eq, Hash)]
3962 #[repr(transparent)]
3963 pub struct TypeParamList {
3964 pub(crate) syntax: SyntaxNode,
3966 unsafe impl TransparentNewType for TypeParamList {
3967 type Repr = rowan::SyntaxNode<RaTypes>;
3970 impl AstNode for TypeParamList {
3971 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3972 match syntax.kind() {
3973 TYPE_PARAM_LIST => Some(TypeParamList::from_repr(syntax.into_repr())),
3977 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3980 impl ToOwned for TypeParamList {
3981 type Owned = TreeArc<TypeParamList>;
3982 fn to_owned(&self) -> TreeArc<TypeParamList> { TreeArc::cast(self.syntax.to_owned()) }
3986 impl TypeParamList {
3987 pub fn type_params(&self) -> impl Iterator<Item = &TypeParam> {
3988 super::children(self)
3991 pub fn lifetime_params(&self) -> impl Iterator<Item = &LifetimeParam> {
3992 super::children(self)
3997 #[derive(Debug, PartialEq, Eq, Hash)]
3998 #[repr(transparent)]
3999 pub struct TypeRef {
4000 pub(crate) syntax: SyntaxNode,
4002 unsafe impl TransparentNewType for TypeRef {
4003 type Repr = rowan::SyntaxNode<RaTypes>;
4006 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4007 pub enum TypeRefKind<'a> {
4008 ParenType(&'a ParenType),
4009 TupleType(&'a TupleType),
4010 NeverType(&'a NeverType),
4011 PathType(&'a PathType),
4012 PointerType(&'a PointerType),
4013 ArrayType(&'a ArrayType),
4014 SliceType(&'a SliceType),
4015 ReferenceType(&'a ReferenceType),
4016 PlaceholderType(&'a PlaceholderType),
4017 FnPointerType(&'a FnPointerType),
4018 ForType(&'a ForType),
4019 ImplTraitType(&'a ImplTraitType),
4020 DynTraitType(&'a DynTraitType),
4022 impl<'a> From<&'a ParenType> for &'a TypeRef {
4023 fn from(n: &'a ParenType) -> &'a TypeRef {
4024 TypeRef::cast(&n.syntax).unwrap()
4027 impl<'a> From<&'a TupleType> for &'a TypeRef {
4028 fn from(n: &'a TupleType) -> &'a TypeRef {
4029 TypeRef::cast(&n.syntax).unwrap()
4032 impl<'a> From<&'a NeverType> for &'a TypeRef {
4033 fn from(n: &'a NeverType) -> &'a TypeRef {
4034 TypeRef::cast(&n.syntax).unwrap()
4037 impl<'a> From<&'a PathType> for &'a TypeRef {
4038 fn from(n: &'a PathType) -> &'a TypeRef {
4039 TypeRef::cast(&n.syntax).unwrap()
4042 impl<'a> From<&'a PointerType> for &'a TypeRef {
4043 fn from(n: &'a PointerType) -> &'a TypeRef {
4044 TypeRef::cast(&n.syntax).unwrap()
4047 impl<'a> From<&'a ArrayType> for &'a TypeRef {
4048 fn from(n: &'a ArrayType) -> &'a TypeRef {
4049 TypeRef::cast(&n.syntax).unwrap()
4052 impl<'a> From<&'a SliceType> for &'a TypeRef {
4053 fn from(n: &'a SliceType) -> &'a TypeRef {
4054 TypeRef::cast(&n.syntax).unwrap()
4057 impl<'a> From<&'a ReferenceType> for &'a TypeRef {
4058 fn from(n: &'a ReferenceType) -> &'a TypeRef {
4059 TypeRef::cast(&n.syntax).unwrap()
4062 impl<'a> From<&'a PlaceholderType> for &'a TypeRef {
4063 fn from(n: &'a PlaceholderType) -> &'a TypeRef {
4064 TypeRef::cast(&n.syntax).unwrap()
4067 impl<'a> From<&'a FnPointerType> for &'a TypeRef {
4068 fn from(n: &'a FnPointerType) -> &'a TypeRef {
4069 TypeRef::cast(&n.syntax).unwrap()
4072 impl<'a> From<&'a ForType> for &'a TypeRef {
4073 fn from(n: &'a ForType) -> &'a TypeRef {
4074 TypeRef::cast(&n.syntax).unwrap()
4077 impl<'a> From<&'a ImplTraitType> for &'a TypeRef {
4078 fn from(n: &'a ImplTraitType) -> &'a TypeRef {
4079 TypeRef::cast(&n.syntax).unwrap()
4082 impl<'a> From<&'a DynTraitType> for &'a TypeRef {
4083 fn from(n: &'a DynTraitType) -> &'a TypeRef {
4084 TypeRef::cast(&n.syntax).unwrap()
4089 impl AstNode for TypeRef {
4090 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4091 match syntax.kind() {
4104 | DYN_TRAIT_TYPE => Some(TypeRef::from_repr(syntax.into_repr())),
4108 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4111 impl ToOwned for TypeRef {
4112 type Owned = TreeArc<TypeRef>;
4113 fn to_owned(&self) -> TreeArc<TypeRef> { TreeArc::cast(self.syntax.to_owned()) }
4117 pub fn kind(&self) -> TypeRefKind {
4118 match self.syntax.kind() {
4119 PAREN_TYPE => TypeRefKind::ParenType(ParenType::cast(&self.syntax).unwrap()),
4120 TUPLE_TYPE => TypeRefKind::TupleType(TupleType::cast(&self.syntax).unwrap()),
4121 NEVER_TYPE => TypeRefKind::NeverType(NeverType::cast(&self.syntax).unwrap()),
4122 PATH_TYPE => TypeRefKind::PathType(PathType::cast(&self.syntax).unwrap()),
4123 POINTER_TYPE => TypeRefKind::PointerType(PointerType::cast(&self.syntax).unwrap()),
4124 ARRAY_TYPE => TypeRefKind::ArrayType(ArrayType::cast(&self.syntax).unwrap()),
4125 SLICE_TYPE => TypeRefKind::SliceType(SliceType::cast(&self.syntax).unwrap()),
4126 REFERENCE_TYPE => TypeRefKind::ReferenceType(ReferenceType::cast(&self.syntax).unwrap()),
4127 PLACEHOLDER_TYPE => TypeRefKind::PlaceholderType(PlaceholderType::cast(&self.syntax).unwrap()),
4128 FN_POINTER_TYPE => TypeRefKind::FnPointerType(FnPointerType::cast(&self.syntax).unwrap()),
4129 FOR_TYPE => TypeRefKind::ForType(ForType::cast(&self.syntax).unwrap()),
4130 IMPL_TRAIT_TYPE => TypeRefKind::ImplTraitType(ImplTraitType::cast(&self.syntax).unwrap()),
4131 DYN_TRAIT_TYPE => TypeRefKind::DynTraitType(DynTraitType::cast(&self.syntax).unwrap()),
4132 _ => unreachable!(),
4140 #[derive(Debug, PartialEq, Eq, Hash)]
4141 #[repr(transparent)]
4142 pub struct UseItem {
4143 pub(crate) syntax: SyntaxNode,
4145 unsafe impl TransparentNewType for UseItem {
4146 type Repr = rowan::SyntaxNode<RaTypes>;
4149 impl AstNode for UseItem {
4150 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4151 match syntax.kind() {
4152 USE_ITEM => Some(UseItem::from_repr(syntax.into_repr())),
4156 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4159 impl ToOwned for UseItem {
4160 type Owned = TreeArc<UseItem>;
4161 fn to_owned(&self) -> TreeArc<UseItem> { TreeArc::cast(self.syntax.to_owned()) }
4165 impl ast::AttrsOwner for UseItem {}
4167 pub fn use_tree(&self) -> Option<&UseTree> {
4168 super::child_opt(self)
4173 #[derive(Debug, PartialEq, Eq, Hash)]
4174 #[repr(transparent)]
4175 pub struct UseTree {
4176 pub(crate) syntax: SyntaxNode,
4178 unsafe impl TransparentNewType for UseTree {
4179 type Repr = rowan::SyntaxNode<RaTypes>;
4182 impl AstNode for UseTree {
4183 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4184 match syntax.kind() {
4185 USE_TREE => Some(UseTree::from_repr(syntax.into_repr())),
4189 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4192 impl ToOwned for UseTree {
4193 type Owned = TreeArc<UseTree>;
4194 fn to_owned(&self) -> TreeArc<UseTree> { TreeArc::cast(self.syntax.to_owned()) }
4199 pub fn path(&self) -> Option<&Path> {
4200 super::child_opt(self)
4203 pub fn use_tree_list(&self) -> Option<&UseTreeList> {
4204 super::child_opt(self)
4207 pub fn alias(&self) -> Option<&Alias> {
4208 super::child_opt(self)
4213 #[derive(Debug, PartialEq, Eq, Hash)]
4214 #[repr(transparent)]
4215 pub struct UseTreeList {
4216 pub(crate) syntax: SyntaxNode,
4218 unsafe impl TransparentNewType for UseTreeList {
4219 type Repr = rowan::SyntaxNode<RaTypes>;
4222 impl AstNode for UseTreeList {
4223 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4224 match syntax.kind() {
4225 USE_TREE_LIST => Some(UseTreeList::from_repr(syntax.into_repr())),
4229 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4232 impl ToOwned for UseTreeList {
4233 type Owned = TreeArc<UseTreeList>;
4234 fn to_owned(&self) -> TreeArc<UseTreeList> { TreeArc::cast(self.syntax.to_owned()) }
4239 pub fn use_trees(&self) -> impl Iterator<Item = &UseTree> {
4240 super::children(self)
4245 #[derive(Debug, PartialEq, Eq, Hash)]
4246 #[repr(transparent)]
4247 pub struct Visibility {
4248 pub(crate) syntax: SyntaxNode,
4250 unsafe impl TransparentNewType for Visibility {
4251 type Repr = rowan::SyntaxNode<RaTypes>;
4254 impl AstNode for Visibility {
4255 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4256 match syntax.kind() {
4257 VISIBILITY => Some(Visibility::from_repr(syntax.into_repr())),
4261 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4264 impl ToOwned for Visibility {
4265 type Owned = TreeArc<Visibility>;
4266 fn to_owned(&self) -> TreeArc<Visibility> { TreeArc::cast(self.syntax.to_owned()) }
4273 #[derive(Debug, PartialEq, Eq, Hash)]
4274 #[repr(transparent)]
4275 pub struct WhereClause {
4276 pub(crate) syntax: SyntaxNode,
4278 unsafe impl TransparentNewType for WhereClause {
4279 type Repr = rowan::SyntaxNode<RaTypes>;
4282 impl AstNode for WhereClause {
4283 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4284 match syntax.kind() {
4285 WHERE_CLAUSE => Some(WhereClause::from_repr(syntax.into_repr())),
4289 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4292 impl ToOwned for WhereClause {
4293 type Owned = TreeArc<WhereClause>;
4294 fn to_owned(&self) -> TreeArc<WhereClause> { TreeArc::cast(self.syntax.to_owned()) }
4299 pub fn predicates(&self) -> impl Iterator<Item = &WherePred> {
4300 super::children(self)
4305 #[derive(Debug, PartialEq, Eq, Hash)]
4306 #[repr(transparent)]
4307 pub struct WherePred {
4308 pub(crate) syntax: SyntaxNode,
4310 unsafe impl TransparentNewType for WherePred {
4311 type Repr = rowan::SyntaxNode<RaTypes>;
4314 impl AstNode for WherePred {
4315 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4316 match syntax.kind() {
4317 WHERE_PRED => Some(WherePred::from_repr(syntax.into_repr())),
4321 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4324 impl ToOwned for WherePred {
4325 type Owned = TreeArc<WherePred>;
4326 fn to_owned(&self) -> TreeArc<WherePred> { TreeArc::cast(self.syntax.to_owned()) }
4330 impl ast::TypeBoundsOwner for WherePred {}
4332 pub fn type_ref(&self) -> Option<&TypeRef> {
4333 super::child_opt(self)
4338 #[derive(Debug, PartialEq, Eq, Hash)]
4339 #[repr(transparent)]
4340 pub struct WhileExpr {
4341 pub(crate) syntax: SyntaxNode,
4343 unsafe impl TransparentNewType for WhileExpr {
4344 type Repr = rowan::SyntaxNode<RaTypes>;
4347 impl AstNode for WhileExpr {
4348 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4349 match syntax.kind() {
4350 WHILE_EXPR => Some(WhileExpr::from_repr(syntax.into_repr())),
4354 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4357 impl ToOwned for WhileExpr {
4358 type Owned = TreeArc<WhileExpr>;
4359 fn to_owned(&self) -> TreeArc<WhileExpr> { TreeArc::cast(self.syntax.to_owned()) }
4363 impl ast::LoopBodyOwner for WhileExpr {}
4365 pub fn condition(&self) -> Option<&Condition> {
4366 super::child_opt(self)
4371 #[derive(Debug, PartialEq, Eq, Hash)]
4372 #[repr(transparent)]
4373 pub struct Whitespace {
4374 pub(crate) syntax: SyntaxNode,
4376 unsafe impl TransparentNewType for Whitespace {
4377 type Repr = rowan::SyntaxNode<RaTypes>;
4380 impl AstNode for Whitespace {
4381 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4382 match syntax.kind() {
4383 WHITESPACE => Some(Whitespace::from_repr(syntax.into_repr())),
4387 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4390 impl ToOwned for Whitespace {
4391 type Owned = TreeArc<Whitespace>;
4392 fn to_owned(&self) -> TreeArc<Whitespace> { TreeArc::cast(self.syntax.to_owned()) }
4396 impl ast::AstToken for Whitespace {}