1 // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run
2 // Do not edit manually
4 //! This module contains auto-generated Rust AST. Like `SyntaxNode`s, AST nodes
5 //! are generic over ownership: `X<'a>` things are `Copy` references, `XNode`
6 //! are Arc-based. You can switch between the two variants using `.owned` and
7 //! `.borrowed` functions. Most of the code works with borowed mode, and only
8 //! this mode has all AST accessors.
10 #![cfg_attr(rustfmt, rustfmt_skip)]
12 use rowan::TransparentNewType;
15 SyntaxNode, SyntaxKind::*,
16 syntax_node::{TreeArc},
21 #[derive(Debug, PartialEq, Eq, Hash)]
24 pub(crate) syntax: SyntaxNode,
26 unsafe impl TransparentNewType for Alias {
27 type Repr = rowan::SyntaxNode;
30 impl AstNode for Alias {
31 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
33 ALIAS => Some(Alias::from_repr(syntax.into_repr())),
37 fn syntax(&self) -> &SyntaxNode { &self.syntax }
40 impl ToOwned for Alias {
41 type Owned = TreeArc<Alias>;
42 fn to_owned(&self) -> TreeArc<Alias> { TreeArc::cast(self.syntax.to_owned()) }
46 impl ast::NameOwner for Alias {}
50 #[derive(Debug, PartialEq, Eq, Hash)]
53 pub(crate) syntax: SyntaxNode,
55 unsafe impl TransparentNewType for ArgList {
56 type Repr = rowan::SyntaxNode;
59 impl AstNode for ArgList {
60 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
62 ARG_LIST => Some(ArgList::from_repr(syntax.into_repr())),
66 fn syntax(&self) -> &SyntaxNode { &self.syntax }
69 impl ToOwned for ArgList {
70 type Owned = TreeArc<ArgList>;
71 fn to_owned(&self) -> TreeArc<ArgList> { TreeArc::cast(self.syntax.to_owned()) }
76 pub fn args(&self) -> impl Iterator<Item = &Expr> {
82 #[derive(Debug, PartialEq, Eq, Hash)]
84 pub struct ArrayExpr {
85 pub(crate) syntax: SyntaxNode,
87 unsafe impl TransparentNewType for ArrayExpr {
88 type Repr = rowan::SyntaxNode;
91 impl AstNode for ArrayExpr {
92 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
94 ARRAY_EXPR => Some(ArrayExpr::from_repr(syntax.into_repr())),
98 fn syntax(&self) -> &SyntaxNode { &self.syntax }
101 impl ToOwned for ArrayExpr {
102 type Owned = TreeArc<ArrayExpr>;
103 fn to_owned(&self) -> TreeArc<ArrayExpr> { TreeArc::cast(self.syntax.to_owned()) }
108 pub fn exprs(&self) -> impl Iterator<Item = &Expr> {
109 super::children(self)
114 #[derive(Debug, PartialEq, Eq, Hash)]
116 pub struct ArrayType {
117 pub(crate) syntax: SyntaxNode,
119 unsafe impl TransparentNewType for ArrayType {
120 type Repr = rowan::SyntaxNode;
123 impl AstNode for ArrayType {
124 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
125 match syntax.kind() {
126 ARRAY_TYPE => Some(ArrayType::from_repr(syntax.into_repr())),
130 fn syntax(&self) -> &SyntaxNode { &self.syntax }
133 impl ToOwned for ArrayType {
134 type Owned = TreeArc<ArrayType>;
135 fn to_owned(&self) -> TreeArc<ArrayType> { TreeArc::cast(self.syntax.to_owned()) }
140 pub fn type_ref(&self) -> Option<&TypeRef> {
141 super::child_opt(self)
144 pub fn expr(&self) -> Option<&Expr> {
145 super::child_opt(self)
150 #[derive(Debug, PartialEq, Eq, Hash)]
152 pub struct AssocTypeArg {
153 pub(crate) syntax: SyntaxNode,
155 unsafe impl TransparentNewType for AssocTypeArg {
156 type Repr = rowan::SyntaxNode;
159 impl AstNode for AssocTypeArg {
160 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
161 match syntax.kind() {
162 ASSOC_TYPE_ARG => Some(AssocTypeArg::from_repr(syntax.into_repr())),
166 fn syntax(&self) -> &SyntaxNode { &self.syntax }
169 impl ToOwned for AssocTypeArg {
170 type Owned = TreeArc<AssocTypeArg>;
171 fn to_owned(&self) -> TreeArc<AssocTypeArg> { TreeArc::cast(self.syntax.to_owned()) }
176 pub fn name_ref(&self) -> Option<&NameRef> {
177 super::child_opt(self)
180 pub fn type_ref(&self) -> Option<&TypeRef> {
181 super::child_opt(self)
186 #[derive(Debug, PartialEq, Eq, Hash)]
189 pub(crate) syntax: SyntaxNode,
191 unsafe impl TransparentNewType for Attr {
192 type Repr = rowan::SyntaxNode;
195 impl AstNode for Attr {
196 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
197 match syntax.kind() {
198 ATTR => Some(Attr::from_repr(syntax.into_repr())),
202 fn syntax(&self) -> &SyntaxNode { &self.syntax }
205 impl ToOwned for Attr {
206 type Owned = TreeArc<Attr>;
207 fn to_owned(&self) -> TreeArc<Attr> { TreeArc::cast(self.syntax.to_owned()) }
212 pub fn value(&self) -> Option<&TokenTree> {
213 super::child_opt(self)
218 #[derive(Debug, PartialEq, Eq, Hash)]
221 pub(crate) syntax: SyntaxNode,
223 unsafe impl TransparentNewType for BinExpr {
224 type Repr = rowan::SyntaxNode;
227 impl AstNode for BinExpr {
228 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
229 match syntax.kind() {
230 BIN_EXPR => Some(BinExpr::from_repr(syntax.into_repr())),
234 fn syntax(&self) -> &SyntaxNode { &self.syntax }
237 impl ToOwned for BinExpr {
238 type Owned = TreeArc<BinExpr>;
239 fn to_owned(&self) -> TreeArc<BinExpr> { TreeArc::cast(self.syntax.to_owned()) }
246 #[derive(Debug, PartialEq, Eq, Hash)]
249 pub(crate) syntax: SyntaxNode,
251 unsafe impl TransparentNewType for BindPat {
252 type Repr = rowan::SyntaxNode;
255 impl AstNode for BindPat {
256 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
257 match syntax.kind() {
258 BIND_PAT => Some(BindPat::from_repr(syntax.into_repr())),
262 fn syntax(&self) -> &SyntaxNode { &self.syntax }
265 impl ToOwned for BindPat {
266 type Owned = TreeArc<BindPat>;
267 fn to_owned(&self) -> TreeArc<BindPat> { TreeArc::cast(self.syntax.to_owned()) }
271 impl ast::NameOwner for BindPat {}
273 pub fn pat(&self) -> Option<&Pat> {
274 super::child_opt(self)
279 #[derive(Debug, PartialEq, Eq, Hash)]
282 pub(crate) syntax: SyntaxNode,
284 unsafe impl TransparentNewType for Block {
285 type Repr = rowan::SyntaxNode;
288 impl AstNode for Block {
289 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
290 match syntax.kind() {
291 BLOCK => Some(Block::from_repr(syntax.into_repr())),
295 fn syntax(&self) -> &SyntaxNode { &self.syntax }
298 impl ToOwned for Block {
299 type Owned = TreeArc<Block>;
300 fn to_owned(&self) -> TreeArc<Block> { TreeArc::cast(self.syntax.to_owned()) }
304 impl ast::AttrsOwner for Block {}
306 pub fn statements(&self) -> impl Iterator<Item = &Stmt> {
307 super::children(self)
310 pub fn expr(&self) -> Option<&Expr> {
311 super::child_opt(self)
316 #[derive(Debug, PartialEq, Eq, Hash)]
318 pub struct BlockExpr {
319 pub(crate) syntax: SyntaxNode,
321 unsafe impl TransparentNewType for BlockExpr {
322 type Repr = rowan::SyntaxNode;
325 impl AstNode for BlockExpr {
326 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
327 match syntax.kind() {
328 BLOCK_EXPR => Some(BlockExpr::from_repr(syntax.into_repr())),
332 fn syntax(&self) -> &SyntaxNode { &self.syntax }
335 impl ToOwned for BlockExpr {
336 type Owned = TreeArc<BlockExpr>;
337 fn to_owned(&self) -> TreeArc<BlockExpr> { TreeArc::cast(self.syntax.to_owned()) }
342 pub fn block(&self) -> Option<&Block> {
343 super::child_opt(self)
348 #[derive(Debug, PartialEq, Eq, Hash)]
350 pub struct BreakExpr {
351 pub(crate) syntax: SyntaxNode,
353 unsafe impl TransparentNewType for BreakExpr {
354 type Repr = rowan::SyntaxNode;
357 impl AstNode for BreakExpr {
358 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
359 match syntax.kind() {
360 BREAK_EXPR => Some(BreakExpr::from_repr(syntax.into_repr())),
364 fn syntax(&self) -> &SyntaxNode { &self.syntax }
367 impl ToOwned for BreakExpr {
368 type Owned = TreeArc<BreakExpr>;
369 fn to_owned(&self) -> TreeArc<BreakExpr> { TreeArc::cast(self.syntax.to_owned()) }
374 pub fn expr(&self) -> Option<&Expr> {
375 super::child_opt(self)
380 #[derive(Debug, PartialEq, Eq, Hash)]
382 pub struct CallExpr {
383 pub(crate) syntax: SyntaxNode,
385 unsafe impl TransparentNewType for CallExpr {
386 type Repr = rowan::SyntaxNode;
389 impl AstNode for CallExpr {
390 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
391 match syntax.kind() {
392 CALL_EXPR => Some(CallExpr::from_repr(syntax.into_repr())),
396 fn syntax(&self) -> &SyntaxNode { &self.syntax }
399 impl ToOwned for CallExpr {
400 type Owned = TreeArc<CallExpr>;
401 fn to_owned(&self) -> TreeArc<CallExpr> { TreeArc::cast(self.syntax.to_owned()) }
405 impl ast::ArgListOwner for CallExpr {}
407 pub fn expr(&self) -> Option<&Expr> {
408 super::child_opt(self)
413 #[derive(Debug, PartialEq, Eq, Hash)]
415 pub struct CastExpr {
416 pub(crate) syntax: SyntaxNode,
418 unsafe impl TransparentNewType for CastExpr {
419 type Repr = rowan::SyntaxNode;
422 impl AstNode for CastExpr {
423 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
424 match syntax.kind() {
425 CAST_EXPR => Some(CastExpr::from_repr(syntax.into_repr())),
429 fn syntax(&self) -> &SyntaxNode { &self.syntax }
432 impl ToOwned for CastExpr {
433 type Owned = TreeArc<CastExpr>;
434 fn to_owned(&self) -> TreeArc<CastExpr> { TreeArc::cast(self.syntax.to_owned()) }
439 pub fn expr(&self) -> Option<&Expr> {
440 super::child_opt(self)
443 pub fn type_ref(&self) -> Option<&TypeRef> {
444 super::child_opt(self)
449 #[derive(Debug, PartialEq, Eq, Hash)]
451 pub struct Condition {
452 pub(crate) syntax: SyntaxNode,
454 unsafe impl TransparentNewType for Condition {
455 type Repr = rowan::SyntaxNode;
458 impl AstNode for Condition {
459 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
460 match syntax.kind() {
461 CONDITION => Some(Condition::from_repr(syntax.into_repr())),
465 fn syntax(&self) -> &SyntaxNode { &self.syntax }
468 impl ToOwned for Condition {
469 type Owned = TreeArc<Condition>;
470 fn to_owned(&self) -> TreeArc<Condition> { TreeArc::cast(self.syntax.to_owned()) }
475 pub fn pat(&self) -> Option<&Pat> {
476 super::child_opt(self)
479 pub fn expr(&self) -> Option<&Expr> {
480 super::child_opt(self)
485 #[derive(Debug, PartialEq, Eq, Hash)]
487 pub struct ConstDef {
488 pub(crate) syntax: SyntaxNode,
490 unsafe impl TransparentNewType for ConstDef {
491 type Repr = rowan::SyntaxNode;
494 impl AstNode for ConstDef {
495 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
496 match syntax.kind() {
497 CONST_DEF => Some(ConstDef::from_repr(syntax.into_repr())),
501 fn syntax(&self) -> &SyntaxNode { &self.syntax }
504 impl ToOwned for ConstDef {
505 type Owned = TreeArc<ConstDef>;
506 fn to_owned(&self) -> TreeArc<ConstDef> { TreeArc::cast(self.syntax.to_owned()) }
510 impl ast::VisibilityOwner for ConstDef {}
511 impl ast::NameOwner for ConstDef {}
512 impl ast::TypeParamsOwner for ConstDef {}
513 impl ast::AttrsOwner for ConstDef {}
514 impl ast::DocCommentsOwner for ConstDef {}
515 impl ast::TypeAscriptionOwner for ConstDef {}
517 pub fn body(&self) -> Option<&Expr> {
518 super::child_opt(self)
523 #[derive(Debug, PartialEq, Eq, Hash)]
525 pub struct ContinueExpr {
526 pub(crate) syntax: SyntaxNode,
528 unsafe impl TransparentNewType for ContinueExpr {
529 type Repr = rowan::SyntaxNode;
532 impl AstNode for ContinueExpr {
533 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
534 match syntax.kind() {
535 CONTINUE_EXPR => Some(ContinueExpr::from_repr(syntax.into_repr())),
539 fn syntax(&self) -> &SyntaxNode { &self.syntax }
542 impl ToOwned for ContinueExpr {
543 type Owned = TreeArc<ContinueExpr>;
544 fn to_owned(&self) -> TreeArc<ContinueExpr> { TreeArc::cast(self.syntax.to_owned()) }
551 #[derive(Debug, PartialEq, Eq, Hash)]
553 pub struct DynTraitType {
554 pub(crate) syntax: SyntaxNode,
556 unsafe impl TransparentNewType for DynTraitType {
557 type Repr = rowan::SyntaxNode;
560 impl AstNode for DynTraitType {
561 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
562 match syntax.kind() {
563 DYN_TRAIT_TYPE => Some(DynTraitType::from_repr(syntax.into_repr())),
567 fn syntax(&self) -> &SyntaxNode { &self.syntax }
570 impl ToOwned for DynTraitType {
571 type Owned = TreeArc<DynTraitType>;
572 fn to_owned(&self) -> TreeArc<DynTraitType> { TreeArc::cast(self.syntax.to_owned()) }
576 impl ast::TypeBoundsOwner for DynTraitType {}
580 #[derive(Debug, PartialEq, Eq, Hash)]
583 pub(crate) syntax: SyntaxNode,
585 unsafe impl TransparentNewType for EnumDef {
586 type Repr = rowan::SyntaxNode;
589 impl AstNode for EnumDef {
590 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
591 match syntax.kind() {
592 ENUM_DEF => Some(EnumDef::from_repr(syntax.into_repr())),
596 fn syntax(&self) -> &SyntaxNode { &self.syntax }
599 impl ToOwned for EnumDef {
600 type Owned = TreeArc<EnumDef>;
601 fn to_owned(&self) -> TreeArc<EnumDef> { TreeArc::cast(self.syntax.to_owned()) }
605 impl ast::VisibilityOwner for EnumDef {}
606 impl ast::NameOwner for EnumDef {}
607 impl ast::TypeParamsOwner for EnumDef {}
608 impl ast::AttrsOwner for EnumDef {}
609 impl ast::DocCommentsOwner for EnumDef {}
611 pub fn variant_list(&self) -> Option<&EnumVariantList> {
612 super::child_opt(self)
617 #[derive(Debug, PartialEq, Eq, Hash)]
619 pub struct EnumVariant {
620 pub(crate) syntax: SyntaxNode,
622 unsafe impl TransparentNewType for EnumVariant {
623 type Repr = rowan::SyntaxNode;
626 impl AstNode for EnumVariant {
627 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
628 match syntax.kind() {
629 ENUM_VARIANT => Some(EnumVariant::from_repr(syntax.into_repr())),
633 fn syntax(&self) -> &SyntaxNode { &self.syntax }
636 impl ToOwned for EnumVariant {
637 type Owned = TreeArc<EnumVariant>;
638 fn to_owned(&self) -> TreeArc<EnumVariant> { TreeArc::cast(self.syntax.to_owned()) }
642 impl ast::NameOwner for EnumVariant {}
643 impl ast::DocCommentsOwner for EnumVariant {}
644 impl ast::AttrsOwner for EnumVariant {}
646 pub fn expr(&self) -> Option<&Expr> {
647 super::child_opt(self)
652 #[derive(Debug, PartialEq, Eq, Hash)]
654 pub struct EnumVariantList {
655 pub(crate) syntax: SyntaxNode,
657 unsafe impl TransparentNewType for EnumVariantList {
658 type Repr = rowan::SyntaxNode;
661 impl AstNode for EnumVariantList {
662 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
663 match syntax.kind() {
664 ENUM_VARIANT_LIST => Some(EnumVariantList::from_repr(syntax.into_repr())),
668 fn syntax(&self) -> &SyntaxNode { &self.syntax }
671 impl ToOwned for EnumVariantList {
672 type Owned = TreeArc<EnumVariantList>;
673 fn to_owned(&self) -> TreeArc<EnumVariantList> { TreeArc::cast(self.syntax.to_owned()) }
677 impl EnumVariantList {
678 pub fn variants(&self) -> impl Iterator<Item = &EnumVariant> {
679 super::children(self)
684 #[derive(Debug, PartialEq, Eq, Hash)]
687 pub(crate) syntax: SyntaxNode,
689 unsafe impl TransparentNewType for Expr {
690 type Repr = rowan::SyntaxNode;
693 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
694 pub enum ExprKind<'a> {
695 TupleExpr(&'a TupleExpr),
696 ArrayExpr(&'a ArrayExpr),
697 ParenExpr(&'a ParenExpr),
698 PathExpr(&'a PathExpr),
699 LambdaExpr(&'a LambdaExpr),
701 LoopExpr(&'a LoopExpr),
702 ForExpr(&'a ForExpr),
703 WhileExpr(&'a WhileExpr),
704 ContinueExpr(&'a ContinueExpr),
705 BreakExpr(&'a BreakExpr),
707 BlockExpr(&'a BlockExpr),
708 ReturnExpr(&'a ReturnExpr),
709 MatchExpr(&'a MatchExpr),
710 StructLit(&'a StructLit),
711 CallExpr(&'a CallExpr),
712 IndexExpr(&'a IndexExpr),
713 MethodCallExpr(&'a MethodCallExpr),
714 FieldExpr(&'a FieldExpr),
715 TryExpr(&'a TryExpr),
716 CastExpr(&'a CastExpr),
717 RefExpr(&'a RefExpr),
718 PrefixExpr(&'a PrefixExpr),
719 RangeExpr(&'a RangeExpr),
720 BinExpr(&'a BinExpr),
721 Literal(&'a Literal),
722 MacroCall(&'a MacroCall),
724 impl<'a> From<&'a TupleExpr> for &'a Expr {
725 fn from(n: &'a TupleExpr) -> &'a Expr {
726 Expr::cast(&n.syntax).unwrap()
729 impl<'a> From<&'a ArrayExpr> for &'a Expr {
730 fn from(n: &'a ArrayExpr) -> &'a Expr {
731 Expr::cast(&n.syntax).unwrap()
734 impl<'a> From<&'a ParenExpr> for &'a Expr {
735 fn from(n: &'a ParenExpr) -> &'a Expr {
736 Expr::cast(&n.syntax).unwrap()
739 impl<'a> From<&'a PathExpr> for &'a Expr {
740 fn from(n: &'a PathExpr) -> &'a Expr {
741 Expr::cast(&n.syntax).unwrap()
744 impl<'a> From<&'a LambdaExpr> for &'a Expr {
745 fn from(n: &'a LambdaExpr) -> &'a Expr {
746 Expr::cast(&n.syntax).unwrap()
749 impl<'a> From<&'a IfExpr> for &'a Expr {
750 fn from(n: &'a IfExpr) -> &'a Expr {
751 Expr::cast(&n.syntax).unwrap()
754 impl<'a> From<&'a LoopExpr> for &'a Expr {
755 fn from(n: &'a LoopExpr) -> &'a Expr {
756 Expr::cast(&n.syntax).unwrap()
759 impl<'a> From<&'a ForExpr> for &'a Expr {
760 fn from(n: &'a ForExpr) -> &'a Expr {
761 Expr::cast(&n.syntax).unwrap()
764 impl<'a> From<&'a WhileExpr> for &'a Expr {
765 fn from(n: &'a WhileExpr) -> &'a Expr {
766 Expr::cast(&n.syntax).unwrap()
769 impl<'a> From<&'a ContinueExpr> for &'a Expr {
770 fn from(n: &'a ContinueExpr) -> &'a Expr {
771 Expr::cast(&n.syntax).unwrap()
774 impl<'a> From<&'a BreakExpr> for &'a Expr {
775 fn from(n: &'a BreakExpr) -> &'a Expr {
776 Expr::cast(&n.syntax).unwrap()
779 impl<'a> From<&'a Label> for &'a Expr {
780 fn from(n: &'a Label) -> &'a Expr {
781 Expr::cast(&n.syntax).unwrap()
784 impl<'a> From<&'a BlockExpr> for &'a Expr {
785 fn from(n: &'a BlockExpr) -> &'a Expr {
786 Expr::cast(&n.syntax).unwrap()
789 impl<'a> From<&'a ReturnExpr> for &'a Expr {
790 fn from(n: &'a ReturnExpr) -> &'a Expr {
791 Expr::cast(&n.syntax).unwrap()
794 impl<'a> From<&'a MatchExpr> for &'a Expr {
795 fn from(n: &'a MatchExpr) -> &'a Expr {
796 Expr::cast(&n.syntax).unwrap()
799 impl<'a> From<&'a StructLit> for &'a Expr {
800 fn from(n: &'a StructLit) -> &'a Expr {
801 Expr::cast(&n.syntax).unwrap()
804 impl<'a> From<&'a CallExpr> for &'a Expr {
805 fn from(n: &'a CallExpr) -> &'a Expr {
806 Expr::cast(&n.syntax).unwrap()
809 impl<'a> From<&'a IndexExpr> for &'a Expr {
810 fn from(n: &'a IndexExpr) -> &'a Expr {
811 Expr::cast(&n.syntax).unwrap()
814 impl<'a> From<&'a MethodCallExpr> for &'a Expr {
815 fn from(n: &'a MethodCallExpr) -> &'a Expr {
816 Expr::cast(&n.syntax).unwrap()
819 impl<'a> From<&'a FieldExpr> for &'a Expr {
820 fn from(n: &'a FieldExpr) -> &'a Expr {
821 Expr::cast(&n.syntax).unwrap()
824 impl<'a> From<&'a TryExpr> for &'a Expr {
825 fn from(n: &'a TryExpr) -> &'a Expr {
826 Expr::cast(&n.syntax).unwrap()
829 impl<'a> From<&'a CastExpr> for &'a Expr {
830 fn from(n: &'a CastExpr) -> &'a Expr {
831 Expr::cast(&n.syntax).unwrap()
834 impl<'a> From<&'a RefExpr> for &'a Expr {
835 fn from(n: &'a RefExpr) -> &'a Expr {
836 Expr::cast(&n.syntax).unwrap()
839 impl<'a> From<&'a PrefixExpr> for &'a Expr {
840 fn from(n: &'a PrefixExpr) -> &'a Expr {
841 Expr::cast(&n.syntax).unwrap()
844 impl<'a> From<&'a RangeExpr> for &'a Expr {
845 fn from(n: &'a RangeExpr) -> &'a Expr {
846 Expr::cast(&n.syntax).unwrap()
849 impl<'a> From<&'a BinExpr> for &'a Expr {
850 fn from(n: &'a BinExpr) -> &'a Expr {
851 Expr::cast(&n.syntax).unwrap()
854 impl<'a> From<&'a Literal> for &'a Expr {
855 fn from(n: &'a Literal) -> &'a Expr {
856 Expr::cast(&n.syntax).unwrap()
859 impl<'a> From<&'a MacroCall> for &'a Expr {
860 fn from(n: &'a MacroCall) -> &'a Expr {
861 Expr::cast(&n.syntax).unwrap()
866 impl AstNode for Expr {
867 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
868 match syntax.kind() {
896 | MACRO_CALL => Some(Expr::from_repr(syntax.into_repr())),
900 fn syntax(&self) -> &SyntaxNode { &self.syntax }
903 impl ToOwned for Expr {
904 type Owned = TreeArc<Expr>;
905 fn to_owned(&self) -> TreeArc<Expr> { TreeArc::cast(self.syntax.to_owned()) }
909 pub fn kind(&self) -> ExprKind {
910 match self.syntax.kind() {
911 TUPLE_EXPR => ExprKind::TupleExpr(TupleExpr::cast(&self.syntax).unwrap()),
912 ARRAY_EXPR => ExprKind::ArrayExpr(ArrayExpr::cast(&self.syntax).unwrap()),
913 PAREN_EXPR => ExprKind::ParenExpr(ParenExpr::cast(&self.syntax).unwrap()),
914 PATH_EXPR => ExprKind::PathExpr(PathExpr::cast(&self.syntax).unwrap()),
915 LAMBDA_EXPR => ExprKind::LambdaExpr(LambdaExpr::cast(&self.syntax).unwrap()),
916 IF_EXPR => ExprKind::IfExpr(IfExpr::cast(&self.syntax).unwrap()),
917 LOOP_EXPR => ExprKind::LoopExpr(LoopExpr::cast(&self.syntax).unwrap()),
918 FOR_EXPR => ExprKind::ForExpr(ForExpr::cast(&self.syntax).unwrap()),
919 WHILE_EXPR => ExprKind::WhileExpr(WhileExpr::cast(&self.syntax).unwrap()),
920 CONTINUE_EXPR => ExprKind::ContinueExpr(ContinueExpr::cast(&self.syntax).unwrap()),
921 BREAK_EXPR => ExprKind::BreakExpr(BreakExpr::cast(&self.syntax).unwrap()),
922 LABEL => ExprKind::Label(Label::cast(&self.syntax).unwrap()),
923 BLOCK_EXPR => ExprKind::BlockExpr(BlockExpr::cast(&self.syntax).unwrap()),
924 RETURN_EXPR => ExprKind::ReturnExpr(ReturnExpr::cast(&self.syntax).unwrap()),
925 MATCH_EXPR => ExprKind::MatchExpr(MatchExpr::cast(&self.syntax).unwrap()),
926 STRUCT_LIT => ExprKind::StructLit(StructLit::cast(&self.syntax).unwrap()),
927 CALL_EXPR => ExprKind::CallExpr(CallExpr::cast(&self.syntax).unwrap()),
928 INDEX_EXPR => ExprKind::IndexExpr(IndexExpr::cast(&self.syntax).unwrap()),
929 METHOD_CALL_EXPR => ExprKind::MethodCallExpr(MethodCallExpr::cast(&self.syntax).unwrap()),
930 FIELD_EXPR => ExprKind::FieldExpr(FieldExpr::cast(&self.syntax).unwrap()),
931 TRY_EXPR => ExprKind::TryExpr(TryExpr::cast(&self.syntax).unwrap()),
932 CAST_EXPR => ExprKind::CastExpr(CastExpr::cast(&self.syntax).unwrap()),
933 REF_EXPR => ExprKind::RefExpr(RefExpr::cast(&self.syntax).unwrap()),
934 PREFIX_EXPR => ExprKind::PrefixExpr(PrefixExpr::cast(&self.syntax).unwrap()),
935 RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(&self.syntax).unwrap()),
936 BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(&self.syntax).unwrap()),
937 LITERAL => ExprKind::Literal(Literal::cast(&self.syntax).unwrap()),
938 MACRO_CALL => ExprKind::MacroCall(MacroCall::cast(&self.syntax).unwrap()),
947 #[derive(Debug, PartialEq, Eq, Hash)]
949 pub struct ExprStmt {
950 pub(crate) syntax: SyntaxNode,
952 unsafe impl TransparentNewType for ExprStmt {
953 type Repr = rowan::SyntaxNode;
956 impl AstNode for ExprStmt {
957 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
958 match syntax.kind() {
959 EXPR_STMT => Some(ExprStmt::from_repr(syntax.into_repr())),
963 fn syntax(&self) -> &SyntaxNode { &self.syntax }
966 impl ToOwned for ExprStmt {
967 type Owned = TreeArc<ExprStmt>;
968 fn to_owned(&self) -> TreeArc<ExprStmt> { TreeArc::cast(self.syntax.to_owned()) }
973 pub fn expr(&self) -> Option<&Expr> {
974 super::child_opt(self)
979 #[derive(Debug, PartialEq, Eq, Hash)]
981 pub struct ExternCrateItem {
982 pub(crate) syntax: SyntaxNode,
984 unsafe impl TransparentNewType for ExternCrateItem {
985 type Repr = rowan::SyntaxNode;
988 impl AstNode for ExternCrateItem {
989 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
990 match syntax.kind() {
991 EXTERN_CRATE_ITEM => Some(ExternCrateItem::from_repr(syntax.into_repr())),
995 fn syntax(&self) -> &SyntaxNode { &self.syntax }
998 impl ToOwned for ExternCrateItem {
999 type Owned = TreeArc<ExternCrateItem>;
1000 fn to_owned(&self) -> TreeArc<ExternCrateItem> { TreeArc::cast(self.syntax.to_owned()) }
1004 impl ExternCrateItem {
1005 pub fn name_ref(&self) -> Option<&NameRef> {
1006 super::child_opt(self)
1009 pub fn alias(&self) -> Option<&Alias> {
1010 super::child_opt(self)
1015 #[derive(Debug, PartialEq, Eq, Hash)]
1016 #[repr(transparent)]
1017 pub struct FieldExpr {
1018 pub(crate) syntax: SyntaxNode,
1020 unsafe impl TransparentNewType for FieldExpr {
1021 type Repr = rowan::SyntaxNode;
1024 impl AstNode for FieldExpr {
1025 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1026 match syntax.kind() {
1027 FIELD_EXPR => Some(FieldExpr::from_repr(syntax.into_repr())),
1031 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1034 impl ToOwned for FieldExpr {
1035 type Owned = TreeArc<FieldExpr>;
1036 fn to_owned(&self) -> TreeArc<FieldExpr> { TreeArc::cast(self.syntax.to_owned()) }
1041 pub fn expr(&self) -> Option<&Expr> {
1042 super::child_opt(self)
1045 pub fn name_ref(&self) -> Option<&NameRef> {
1046 super::child_opt(self)
1051 #[derive(Debug, PartialEq, Eq, Hash)]
1052 #[repr(transparent)]
1053 pub struct FieldPat {
1054 pub(crate) syntax: SyntaxNode,
1056 unsafe impl TransparentNewType for FieldPat {
1057 type Repr = rowan::SyntaxNode;
1060 impl AstNode for FieldPat {
1061 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1062 match syntax.kind() {
1063 FIELD_PAT => Some(FieldPat::from_repr(syntax.into_repr())),
1067 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1070 impl ToOwned for FieldPat {
1071 type Owned = TreeArc<FieldPat>;
1072 fn to_owned(&self) -> TreeArc<FieldPat> { TreeArc::cast(self.syntax.to_owned()) }
1076 impl ast::NameOwner for FieldPat {}
1078 pub fn pat(&self) -> Option<&Pat> {
1079 super::child_opt(self)
1084 #[derive(Debug, PartialEq, Eq, Hash)]
1085 #[repr(transparent)]
1086 pub struct FieldPatList {
1087 pub(crate) syntax: SyntaxNode,
1089 unsafe impl TransparentNewType for FieldPatList {
1090 type Repr = rowan::SyntaxNode;
1093 impl AstNode for FieldPatList {
1094 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1095 match syntax.kind() {
1096 FIELD_PAT_LIST => Some(FieldPatList::from_repr(syntax.into_repr())),
1100 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1103 impl ToOwned for FieldPatList {
1104 type Owned = TreeArc<FieldPatList>;
1105 fn to_owned(&self) -> TreeArc<FieldPatList> { TreeArc::cast(self.syntax.to_owned()) }
1110 pub fn field_pats(&self) -> impl Iterator<Item = &FieldPat> {
1111 super::children(self)
1114 pub fn bind_pats(&self) -> impl Iterator<Item = &BindPat> {
1115 super::children(self)
1120 #[derive(Debug, PartialEq, Eq, Hash)]
1121 #[repr(transparent)]
1123 pub(crate) syntax: SyntaxNode,
1125 unsafe impl TransparentNewType for FnDef {
1126 type Repr = rowan::SyntaxNode;
1129 impl AstNode for FnDef {
1130 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1131 match syntax.kind() {
1132 FN_DEF => Some(FnDef::from_repr(syntax.into_repr())),
1136 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1139 impl ToOwned for FnDef {
1140 type Owned = TreeArc<FnDef>;
1141 fn to_owned(&self) -> TreeArc<FnDef> { TreeArc::cast(self.syntax.to_owned()) }
1145 impl ast::VisibilityOwner for FnDef {}
1146 impl ast::NameOwner for FnDef {}
1147 impl ast::TypeParamsOwner for FnDef {}
1148 impl ast::AttrsOwner for FnDef {}
1149 impl ast::DocCommentsOwner for FnDef {}
1151 pub fn param_list(&self) -> Option<&ParamList> {
1152 super::child_opt(self)
1155 pub fn body(&self) -> Option<&Block> {
1156 super::child_opt(self)
1159 pub fn ret_type(&self) -> Option<&RetType> {
1160 super::child_opt(self)
1165 #[derive(Debug, PartialEq, Eq, Hash)]
1166 #[repr(transparent)]
1167 pub struct FnPointerType {
1168 pub(crate) syntax: SyntaxNode,
1170 unsafe impl TransparentNewType for FnPointerType {
1171 type Repr = rowan::SyntaxNode;
1174 impl AstNode for FnPointerType {
1175 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1176 match syntax.kind() {
1177 FN_POINTER_TYPE => Some(FnPointerType::from_repr(syntax.into_repr())),
1181 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1184 impl ToOwned for FnPointerType {
1185 type Owned = TreeArc<FnPointerType>;
1186 fn to_owned(&self) -> TreeArc<FnPointerType> { TreeArc::cast(self.syntax.to_owned()) }
1190 impl FnPointerType {
1191 pub fn param_list(&self) -> Option<&ParamList> {
1192 super::child_opt(self)
1195 pub fn ret_type(&self) -> Option<&RetType> {
1196 super::child_opt(self)
1201 #[derive(Debug, PartialEq, Eq, Hash)]
1202 #[repr(transparent)]
1203 pub struct ForExpr {
1204 pub(crate) syntax: SyntaxNode,
1206 unsafe impl TransparentNewType for ForExpr {
1207 type Repr = rowan::SyntaxNode;
1210 impl AstNode for ForExpr {
1211 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1212 match syntax.kind() {
1213 FOR_EXPR => Some(ForExpr::from_repr(syntax.into_repr())),
1217 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1220 impl ToOwned for ForExpr {
1221 type Owned = TreeArc<ForExpr>;
1222 fn to_owned(&self) -> TreeArc<ForExpr> { TreeArc::cast(self.syntax.to_owned()) }
1226 impl ast::LoopBodyOwner for ForExpr {}
1228 pub fn pat(&self) -> Option<&Pat> {
1229 super::child_opt(self)
1232 pub fn iterable(&self) -> Option<&Expr> {
1233 super::child_opt(self)
1238 #[derive(Debug, PartialEq, Eq, Hash)]
1239 #[repr(transparent)]
1240 pub struct ForType {
1241 pub(crate) syntax: SyntaxNode,
1243 unsafe impl TransparentNewType for ForType {
1244 type Repr = rowan::SyntaxNode;
1247 impl AstNode for ForType {
1248 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1249 match syntax.kind() {
1250 FOR_TYPE => Some(ForType::from_repr(syntax.into_repr())),
1254 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1257 impl ToOwned for ForType {
1258 type Owned = TreeArc<ForType>;
1259 fn to_owned(&self) -> TreeArc<ForType> { TreeArc::cast(self.syntax.to_owned()) }
1264 pub fn type_ref(&self) -> Option<&TypeRef> {
1265 super::child_opt(self)
1270 #[derive(Debug, PartialEq, Eq, Hash)]
1271 #[repr(transparent)]
1273 pub(crate) syntax: SyntaxNode,
1275 unsafe impl TransparentNewType for IfExpr {
1276 type Repr = rowan::SyntaxNode;
1279 impl AstNode for IfExpr {
1280 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1281 match syntax.kind() {
1282 IF_EXPR => Some(IfExpr::from_repr(syntax.into_repr())),
1286 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1289 impl ToOwned for IfExpr {
1290 type Owned = TreeArc<IfExpr>;
1291 fn to_owned(&self) -> TreeArc<IfExpr> { TreeArc::cast(self.syntax.to_owned()) }
1296 pub fn condition(&self) -> Option<&Condition> {
1297 super::child_opt(self)
1302 #[derive(Debug, PartialEq, Eq, Hash)]
1303 #[repr(transparent)]
1304 pub struct ImplBlock {
1305 pub(crate) syntax: SyntaxNode,
1307 unsafe impl TransparentNewType for ImplBlock {
1308 type Repr = rowan::SyntaxNode;
1311 impl AstNode for ImplBlock {
1312 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1313 match syntax.kind() {
1314 IMPL_BLOCK => Some(ImplBlock::from_repr(syntax.into_repr())),
1318 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1321 impl ToOwned for ImplBlock {
1322 type Owned = TreeArc<ImplBlock>;
1323 fn to_owned(&self) -> TreeArc<ImplBlock> { TreeArc::cast(self.syntax.to_owned()) }
1327 impl ast::TypeParamsOwner for ImplBlock {}
1328 impl ast::AttrsOwner for ImplBlock {}
1330 pub fn item_list(&self) -> Option<&ItemList> {
1331 super::child_opt(self)
1336 #[derive(Debug, PartialEq, Eq, Hash)]
1337 #[repr(transparent)]
1338 pub struct ImplItem {
1339 pub(crate) syntax: SyntaxNode,
1341 unsafe impl TransparentNewType for ImplItem {
1342 type Repr = rowan::SyntaxNode;
1345 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1346 pub enum ImplItemKind<'a> {
1348 TypeAliasDef(&'a TypeAliasDef),
1349 ConstDef(&'a ConstDef),
1351 impl<'a> From<&'a FnDef> for &'a ImplItem {
1352 fn from(n: &'a FnDef) -> &'a ImplItem {
1353 ImplItem::cast(&n.syntax).unwrap()
1356 impl<'a> From<&'a TypeAliasDef> for &'a ImplItem {
1357 fn from(n: &'a TypeAliasDef) -> &'a ImplItem {
1358 ImplItem::cast(&n.syntax).unwrap()
1361 impl<'a> From<&'a ConstDef> for &'a ImplItem {
1362 fn from(n: &'a ConstDef) -> &'a ImplItem {
1363 ImplItem::cast(&n.syntax).unwrap()
1368 impl AstNode for ImplItem {
1369 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1370 match syntax.kind() {
1373 | CONST_DEF => Some(ImplItem::from_repr(syntax.into_repr())),
1377 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1380 impl ToOwned for ImplItem {
1381 type Owned = TreeArc<ImplItem>;
1382 fn to_owned(&self) -> TreeArc<ImplItem> { TreeArc::cast(self.syntax.to_owned()) }
1386 pub fn kind(&self) -> ImplItemKind {
1387 match self.syntax.kind() {
1388 FN_DEF => ImplItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
1389 TYPE_ALIAS_DEF => ImplItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
1390 CONST_DEF => ImplItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
1391 _ => unreachable!(),
1399 #[derive(Debug, PartialEq, Eq, Hash)]
1400 #[repr(transparent)]
1401 pub struct ImplTraitType {
1402 pub(crate) syntax: SyntaxNode,
1404 unsafe impl TransparentNewType for ImplTraitType {
1405 type Repr = rowan::SyntaxNode;
1408 impl AstNode for ImplTraitType {
1409 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1410 match syntax.kind() {
1411 IMPL_TRAIT_TYPE => Some(ImplTraitType::from_repr(syntax.into_repr())),
1415 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1418 impl ToOwned for ImplTraitType {
1419 type Owned = TreeArc<ImplTraitType>;
1420 fn to_owned(&self) -> TreeArc<ImplTraitType> { TreeArc::cast(self.syntax.to_owned()) }
1424 impl ast::TypeBoundsOwner for ImplTraitType {}
1425 impl ImplTraitType {}
1428 #[derive(Debug, PartialEq, Eq, Hash)]
1429 #[repr(transparent)]
1430 pub struct IndexExpr {
1431 pub(crate) syntax: SyntaxNode,
1433 unsafe impl TransparentNewType for IndexExpr {
1434 type Repr = rowan::SyntaxNode;
1437 impl AstNode for IndexExpr {
1438 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1439 match syntax.kind() {
1440 INDEX_EXPR => Some(IndexExpr::from_repr(syntax.into_repr())),
1444 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1447 impl ToOwned for IndexExpr {
1448 type Owned = TreeArc<IndexExpr>;
1449 fn to_owned(&self) -> TreeArc<IndexExpr> { TreeArc::cast(self.syntax.to_owned()) }
1456 #[derive(Debug, PartialEq, Eq, Hash)]
1457 #[repr(transparent)]
1458 pub struct ItemList {
1459 pub(crate) syntax: SyntaxNode,
1461 unsafe impl TransparentNewType for ItemList {
1462 type Repr = rowan::SyntaxNode;
1465 impl AstNode for ItemList {
1466 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1467 match syntax.kind() {
1468 ITEM_LIST => Some(ItemList::from_repr(syntax.into_repr())),
1472 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1475 impl ToOwned for ItemList {
1476 type Owned = TreeArc<ItemList>;
1477 fn to_owned(&self) -> TreeArc<ItemList> { TreeArc::cast(self.syntax.to_owned()) }
1481 impl ast::FnDefOwner for ItemList {}
1482 impl ast::ModuleItemOwner for ItemList {}
1484 pub fn impl_items(&self) -> impl Iterator<Item = &ImplItem> {
1485 super::children(self)
1490 #[derive(Debug, PartialEq, Eq, Hash)]
1491 #[repr(transparent)]
1493 pub(crate) syntax: SyntaxNode,
1495 unsafe impl TransparentNewType for Label {
1496 type Repr = rowan::SyntaxNode;
1499 impl AstNode for Label {
1500 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1501 match syntax.kind() {
1502 LABEL => Some(Label::from_repr(syntax.into_repr())),
1506 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1509 impl ToOwned for Label {
1510 type Owned = TreeArc<Label>;
1511 fn to_owned(&self) -> TreeArc<Label> { TreeArc::cast(self.syntax.to_owned()) }
1518 #[derive(Debug, PartialEq, Eq, Hash)]
1519 #[repr(transparent)]
1520 pub struct LambdaExpr {
1521 pub(crate) syntax: SyntaxNode,
1523 unsafe impl TransparentNewType for LambdaExpr {
1524 type Repr = rowan::SyntaxNode;
1527 impl AstNode for LambdaExpr {
1528 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1529 match syntax.kind() {
1530 LAMBDA_EXPR => Some(LambdaExpr::from_repr(syntax.into_repr())),
1534 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1537 impl ToOwned for LambdaExpr {
1538 type Owned = TreeArc<LambdaExpr>;
1539 fn to_owned(&self) -> TreeArc<LambdaExpr> { TreeArc::cast(self.syntax.to_owned()) }
1544 pub fn param_list(&self) -> Option<&ParamList> {
1545 super::child_opt(self)
1548 pub fn body(&self) -> Option<&Expr> {
1549 super::child_opt(self)
1554 #[derive(Debug, PartialEq, Eq, Hash)]
1555 #[repr(transparent)]
1556 pub struct LetStmt {
1557 pub(crate) syntax: SyntaxNode,
1559 unsafe impl TransparentNewType for LetStmt {
1560 type Repr = rowan::SyntaxNode;
1563 impl AstNode for LetStmt {
1564 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1565 match syntax.kind() {
1566 LET_STMT => Some(LetStmt::from_repr(syntax.into_repr())),
1570 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1573 impl ToOwned for LetStmt {
1574 type Owned = TreeArc<LetStmt>;
1575 fn to_owned(&self) -> TreeArc<LetStmt> { TreeArc::cast(self.syntax.to_owned()) }
1579 impl ast::TypeAscriptionOwner for LetStmt {}
1581 pub fn pat(&self) -> Option<&Pat> {
1582 super::child_opt(self)
1585 pub fn initializer(&self) -> Option<&Expr> {
1586 super::child_opt(self)
1591 #[derive(Debug, PartialEq, Eq, Hash)]
1592 #[repr(transparent)]
1593 pub struct LifetimeArg {
1594 pub(crate) syntax: SyntaxNode,
1596 unsafe impl TransparentNewType for LifetimeArg {
1597 type Repr = rowan::SyntaxNode;
1600 impl AstNode for LifetimeArg {
1601 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1602 match syntax.kind() {
1603 LIFETIME_ARG => Some(LifetimeArg::from_repr(syntax.into_repr())),
1607 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1610 impl ToOwned for LifetimeArg {
1611 type Owned = TreeArc<LifetimeArg>;
1612 fn to_owned(&self) -> TreeArc<LifetimeArg> { TreeArc::cast(self.syntax.to_owned()) }
1619 #[derive(Debug, PartialEq, Eq, Hash)]
1620 #[repr(transparent)]
1621 pub struct LifetimeParam {
1622 pub(crate) syntax: SyntaxNode,
1624 unsafe impl TransparentNewType for LifetimeParam {
1625 type Repr = rowan::SyntaxNode;
1628 impl AstNode for LifetimeParam {
1629 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1630 match syntax.kind() {
1631 LIFETIME_PARAM => Some(LifetimeParam::from_repr(syntax.into_repr())),
1635 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1638 impl ToOwned for LifetimeParam {
1639 type Owned = TreeArc<LifetimeParam>;
1640 fn to_owned(&self) -> TreeArc<LifetimeParam> { TreeArc::cast(self.syntax.to_owned()) }
1644 impl ast::AttrsOwner for LifetimeParam {}
1645 impl LifetimeParam {}
1648 #[derive(Debug, PartialEq, Eq, Hash)]
1649 #[repr(transparent)]
1650 pub struct Literal {
1651 pub(crate) syntax: SyntaxNode,
1653 unsafe impl TransparentNewType for Literal {
1654 type Repr = rowan::SyntaxNode;
1657 impl AstNode for Literal {
1658 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1659 match syntax.kind() {
1660 LITERAL => Some(Literal::from_repr(syntax.into_repr())),
1664 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1667 impl ToOwned for Literal {
1668 type Owned = TreeArc<Literal>;
1669 fn to_owned(&self) -> TreeArc<Literal> { TreeArc::cast(self.syntax.to_owned()) }
1676 #[derive(Debug, PartialEq, Eq, Hash)]
1677 #[repr(transparent)]
1678 pub struct LiteralPat {
1679 pub(crate) syntax: SyntaxNode,
1681 unsafe impl TransparentNewType for LiteralPat {
1682 type Repr = rowan::SyntaxNode;
1685 impl AstNode for LiteralPat {
1686 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1687 match syntax.kind() {
1688 LITERAL_PAT => Some(LiteralPat::from_repr(syntax.into_repr())),
1692 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1695 impl ToOwned for LiteralPat {
1696 type Owned = TreeArc<LiteralPat>;
1697 fn to_owned(&self) -> TreeArc<LiteralPat> { TreeArc::cast(self.syntax.to_owned()) }
1702 pub fn literal(&self) -> Option<&Literal> {
1703 super::child_opt(self)
1708 #[derive(Debug, PartialEq, Eq, Hash)]
1709 #[repr(transparent)]
1710 pub struct LoopExpr {
1711 pub(crate) syntax: SyntaxNode,
1713 unsafe impl TransparentNewType for LoopExpr {
1714 type Repr = rowan::SyntaxNode;
1717 impl AstNode for LoopExpr {
1718 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1719 match syntax.kind() {
1720 LOOP_EXPR => Some(LoopExpr::from_repr(syntax.into_repr())),
1724 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1727 impl ToOwned for LoopExpr {
1728 type Owned = TreeArc<LoopExpr>;
1729 fn to_owned(&self) -> TreeArc<LoopExpr> { TreeArc::cast(self.syntax.to_owned()) }
1733 impl ast::LoopBodyOwner for LoopExpr {}
1737 #[derive(Debug, PartialEq, Eq, Hash)]
1738 #[repr(transparent)]
1739 pub struct MacroCall {
1740 pub(crate) syntax: SyntaxNode,
1742 unsafe impl TransparentNewType for MacroCall {
1743 type Repr = rowan::SyntaxNode;
1746 impl AstNode for MacroCall {
1747 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1748 match syntax.kind() {
1749 MACRO_CALL => Some(MacroCall::from_repr(syntax.into_repr())),
1753 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1756 impl ToOwned for MacroCall {
1757 type Owned = TreeArc<MacroCall>;
1758 fn to_owned(&self) -> TreeArc<MacroCall> { TreeArc::cast(self.syntax.to_owned()) }
1762 impl ast::NameOwner for MacroCall {}
1763 impl ast::AttrsOwner for MacroCall {}
1765 pub fn token_tree(&self) -> Option<&TokenTree> {
1766 super::child_opt(self)
1769 pub fn path(&self) -> Option<&Path> {
1770 super::child_opt(self)
1775 #[derive(Debug, PartialEq, Eq, Hash)]
1776 #[repr(transparent)]
1777 pub struct MatchArm {
1778 pub(crate) syntax: SyntaxNode,
1780 unsafe impl TransparentNewType for MatchArm {
1781 type Repr = rowan::SyntaxNode;
1784 impl AstNode for MatchArm {
1785 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1786 match syntax.kind() {
1787 MATCH_ARM => Some(MatchArm::from_repr(syntax.into_repr())),
1791 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1794 impl ToOwned for MatchArm {
1795 type Owned = TreeArc<MatchArm>;
1796 fn to_owned(&self) -> TreeArc<MatchArm> { TreeArc::cast(self.syntax.to_owned()) }
1800 impl ast::AttrsOwner for MatchArm {}
1802 pub fn pats(&self) -> impl Iterator<Item = &Pat> {
1803 super::children(self)
1806 pub fn guard(&self) -> Option<&MatchGuard> {
1807 super::child_opt(self)
1810 pub fn expr(&self) -> Option<&Expr> {
1811 super::child_opt(self)
1816 #[derive(Debug, PartialEq, Eq, Hash)]
1817 #[repr(transparent)]
1818 pub struct MatchArmList {
1819 pub(crate) syntax: SyntaxNode,
1821 unsafe impl TransparentNewType for MatchArmList {
1822 type Repr = rowan::SyntaxNode;
1825 impl AstNode for MatchArmList {
1826 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1827 match syntax.kind() {
1828 MATCH_ARM_LIST => Some(MatchArmList::from_repr(syntax.into_repr())),
1832 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1835 impl ToOwned for MatchArmList {
1836 type Owned = TreeArc<MatchArmList>;
1837 fn to_owned(&self) -> TreeArc<MatchArmList> { TreeArc::cast(self.syntax.to_owned()) }
1841 impl ast::AttrsOwner for MatchArmList {}
1843 pub fn arms(&self) -> impl Iterator<Item = &MatchArm> {
1844 super::children(self)
1849 #[derive(Debug, PartialEq, Eq, Hash)]
1850 #[repr(transparent)]
1851 pub struct MatchExpr {
1852 pub(crate) syntax: SyntaxNode,
1854 unsafe impl TransparentNewType for MatchExpr {
1855 type Repr = rowan::SyntaxNode;
1858 impl AstNode for MatchExpr {
1859 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1860 match syntax.kind() {
1861 MATCH_EXPR => Some(MatchExpr::from_repr(syntax.into_repr())),
1865 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1868 impl ToOwned for MatchExpr {
1869 type Owned = TreeArc<MatchExpr>;
1870 fn to_owned(&self) -> TreeArc<MatchExpr> { TreeArc::cast(self.syntax.to_owned()) }
1875 pub fn expr(&self) -> Option<&Expr> {
1876 super::child_opt(self)
1879 pub fn match_arm_list(&self) -> Option<&MatchArmList> {
1880 super::child_opt(self)
1885 #[derive(Debug, PartialEq, Eq, Hash)]
1886 #[repr(transparent)]
1887 pub struct MatchGuard {
1888 pub(crate) syntax: SyntaxNode,
1890 unsafe impl TransparentNewType for MatchGuard {
1891 type Repr = rowan::SyntaxNode;
1894 impl AstNode for MatchGuard {
1895 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1896 match syntax.kind() {
1897 MATCH_GUARD => Some(MatchGuard::from_repr(syntax.into_repr())),
1901 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1904 impl ToOwned for MatchGuard {
1905 type Owned = TreeArc<MatchGuard>;
1906 fn to_owned(&self) -> TreeArc<MatchGuard> { TreeArc::cast(self.syntax.to_owned()) }
1911 pub fn expr(&self) -> Option<&Expr> {
1912 super::child_opt(self)
1917 #[derive(Debug, PartialEq, Eq, Hash)]
1918 #[repr(transparent)]
1919 pub struct MethodCallExpr {
1920 pub(crate) syntax: SyntaxNode,
1922 unsafe impl TransparentNewType for MethodCallExpr {
1923 type Repr = rowan::SyntaxNode;
1926 impl AstNode for MethodCallExpr {
1927 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1928 match syntax.kind() {
1929 METHOD_CALL_EXPR => Some(MethodCallExpr::from_repr(syntax.into_repr())),
1933 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1936 impl ToOwned for MethodCallExpr {
1937 type Owned = TreeArc<MethodCallExpr>;
1938 fn to_owned(&self) -> TreeArc<MethodCallExpr> { TreeArc::cast(self.syntax.to_owned()) }
1942 impl ast::ArgListOwner for MethodCallExpr {}
1943 impl MethodCallExpr {
1944 pub fn expr(&self) -> Option<&Expr> {
1945 super::child_opt(self)
1948 pub fn name_ref(&self) -> Option<&NameRef> {
1949 super::child_opt(self)
1952 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
1953 super::child_opt(self)
1958 #[derive(Debug, PartialEq, Eq, Hash)]
1959 #[repr(transparent)]
1961 pub(crate) syntax: SyntaxNode,
1963 unsafe impl TransparentNewType for Module {
1964 type Repr = rowan::SyntaxNode;
1967 impl AstNode for Module {
1968 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1969 match syntax.kind() {
1970 MODULE => Some(Module::from_repr(syntax.into_repr())),
1974 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1977 impl ToOwned for Module {
1978 type Owned = TreeArc<Module>;
1979 fn to_owned(&self) -> TreeArc<Module> { TreeArc::cast(self.syntax.to_owned()) }
1983 impl ast::VisibilityOwner for Module {}
1984 impl ast::NameOwner for Module {}
1985 impl ast::AttrsOwner for Module {}
1986 impl ast::DocCommentsOwner for Module {}
1988 pub fn item_list(&self) -> Option<&ItemList> {
1989 super::child_opt(self)
1994 #[derive(Debug, PartialEq, Eq, Hash)]
1995 #[repr(transparent)]
1996 pub struct ModuleItem {
1997 pub(crate) syntax: SyntaxNode,
1999 unsafe impl TransparentNewType for ModuleItem {
2000 type Repr = rowan::SyntaxNode;
2003 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2004 pub enum ModuleItemKind<'a> {
2005 StructDef(&'a StructDef),
2006 EnumDef(&'a EnumDef),
2008 TraitDef(&'a TraitDef),
2009 TypeAliasDef(&'a TypeAliasDef),
2010 ImplBlock(&'a ImplBlock),
2011 UseItem(&'a UseItem),
2012 ExternCrateItem(&'a ExternCrateItem),
2013 ConstDef(&'a ConstDef),
2014 StaticDef(&'a StaticDef),
2017 impl<'a> From<&'a StructDef> for &'a ModuleItem {
2018 fn from(n: &'a StructDef) -> &'a ModuleItem {
2019 ModuleItem::cast(&n.syntax).unwrap()
2022 impl<'a> From<&'a EnumDef> for &'a ModuleItem {
2023 fn from(n: &'a EnumDef) -> &'a ModuleItem {
2024 ModuleItem::cast(&n.syntax).unwrap()
2027 impl<'a> From<&'a FnDef> for &'a ModuleItem {
2028 fn from(n: &'a FnDef) -> &'a ModuleItem {
2029 ModuleItem::cast(&n.syntax).unwrap()
2032 impl<'a> From<&'a TraitDef> for &'a ModuleItem {
2033 fn from(n: &'a TraitDef) -> &'a ModuleItem {
2034 ModuleItem::cast(&n.syntax).unwrap()
2037 impl<'a> From<&'a TypeAliasDef> for &'a ModuleItem {
2038 fn from(n: &'a TypeAliasDef) -> &'a ModuleItem {
2039 ModuleItem::cast(&n.syntax).unwrap()
2042 impl<'a> From<&'a ImplBlock> for &'a ModuleItem {
2043 fn from(n: &'a ImplBlock) -> &'a ModuleItem {
2044 ModuleItem::cast(&n.syntax).unwrap()
2047 impl<'a> From<&'a UseItem> for &'a ModuleItem {
2048 fn from(n: &'a UseItem) -> &'a ModuleItem {
2049 ModuleItem::cast(&n.syntax).unwrap()
2052 impl<'a> From<&'a ExternCrateItem> for &'a ModuleItem {
2053 fn from(n: &'a ExternCrateItem) -> &'a ModuleItem {
2054 ModuleItem::cast(&n.syntax).unwrap()
2057 impl<'a> From<&'a ConstDef> for &'a ModuleItem {
2058 fn from(n: &'a ConstDef) -> &'a ModuleItem {
2059 ModuleItem::cast(&n.syntax).unwrap()
2062 impl<'a> From<&'a StaticDef> for &'a ModuleItem {
2063 fn from(n: &'a StaticDef) -> &'a ModuleItem {
2064 ModuleItem::cast(&n.syntax).unwrap()
2067 impl<'a> From<&'a Module> for &'a ModuleItem {
2068 fn from(n: &'a Module) -> &'a ModuleItem {
2069 ModuleItem::cast(&n.syntax).unwrap()
2074 impl AstNode for ModuleItem {
2075 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2076 match syntax.kind() {
2087 | MODULE => Some(ModuleItem::from_repr(syntax.into_repr())),
2091 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2094 impl ToOwned for ModuleItem {
2095 type Owned = TreeArc<ModuleItem>;
2096 fn to_owned(&self) -> TreeArc<ModuleItem> { TreeArc::cast(self.syntax.to_owned()) }
2100 pub fn kind(&self) -> ModuleItemKind {
2101 match self.syntax.kind() {
2102 STRUCT_DEF => ModuleItemKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2103 ENUM_DEF => ModuleItemKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2104 FN_DEF => ModuleItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
2105 TRAIT_DEF => ModuleItemKind::TraitDef(TraitDef::cast(&self.syntax).unwrap()),
2106 TYPE_ALIAS_DEF => ModuleItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
2107 IMPL_BLOCK => ModuleItemKind::ImplBlock(ImplBlock::cast(&self.syntax).unwrap()),
2108 USE_ITEM => ModuleItemKind::UseItem(UseItem::cast(&self.syntax).unwrap()),
2109 EXTERN_CRATE_ITEM => ModuleItemKind::ExternCrateItem(ExternCrateItem::cast(&self.syntax).unwrap()),
2110 CONST_DEF => ModuleItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
2111 STATIC_DEF => ModuleItemKind::StaticDef(StaticDef::cast(&self.syntax).unwrap()),
2112 MODULE => ModuleItemKind::Module(Module::cast(&self.syntax).unwrap()),
2113 _ => unreachable!(),
2121 #[derive(Debug, PartialEq, Eq, Hash)]
2122 #[repr(transparent)]
2124 pub(crate) syntax: SyntaxNode,
2126 unsafe impl TransparentNewType for Name {
2127 type Repr = rowan::SyntaxNode;
2130 impl AstNode for Name {
2131 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2132 match syntax.kind() {
2133 NAME => Some(Name::from_repr(syntax.into_repr())),
2137 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2140 impl ToOwned for Name {
2141 type Owned = TreeArc<Name>;
2142 fn to_owned(&self) -> TreeArc<Name> { TreeArc::cast(self.syntax.to_owned()) }
2149 #[derive(Debug, PartialEq, Eq, Hash)]
2150 #[repr(transparent)]
2151 pub struct NameRef {
2152 pub(crate) syntax: SyntaxNode,
2154 unsafe impl TransparentNewType for NameRef {
2155 type Repr = rowan::SyntaxNode;
2158 impl AstNode for NameRef {
2159 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2160 match syntax.kind() {
2161 NAME_REF => Some(NameRef::from_repr(syntax.into_repr())),
2165 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2168 impl ToOwned for NameRef {
2169 type Owned = TreeArc<NameRef>;
2170 fn to_owned(&self) -> TreeArc<NameRef> { TreeArc::cast(self.syntax.to_owned()) }
2177 #[derive(Debug, PartialEq, Eq, Hash)]
2178 #[repr(transparent)]
2179 pub struct NamedField {
2180 pub(crate) syntax: SyntaxNode,
2182 unsafe impl TransparentNewType for NamedField {
2183 type Repr = rowan::SyntaxNode;
2186 impl AstNode for NamedField {
2187 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2188 match syntax.kind() {
2189 NAMED_FIELD => Some(NamedField::from_repr(syntax.into_repr())),
2193 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2196 impl ToOwned for NamedField {
2197 type Owned = TreeArc<NamedField>;
2198 fn to_owned(&self) -> TreeArc<NamedField> { TreeArc::cast(self.syntax.to_owned()) }
2203 pub fn name_ref(&self) -> Option<&NameRef> {
2204 super::child_opt(self)
2207 pub fn expr(&self) -> Option<&Expr> {
2208 super::child_opt(self)
2213 #[derive(Debug, PartialEq, Eq, Hash)]
2214 #[repr(transparent)]
2215 pub struct NamedFieldDef {
2216 pub(crate) syntax: SyntaxNode,
2218 unsafe impl TransparentNewType for NamedFieldDef {
2219 type Repr = rowan::SyntaxNode;
2222 impl AstNode for NamedFieldDef {
2223 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2224 match syntax.kind() {
2225 NAMED_FIELD_DEF => Some(NamedFieldDef::from_repr(syntax.into_repr())),
2229 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2232 impl ToOwned for NamedFieldDef {
2233 type Owned = TreeArc<NamedFieldDef>;
2234 fn to_owned(&self) -> TreeArc<NamedFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2238 impl ast::VisibilityOwner for NamedFieldDef {}
2239 impl ast::NameOwner for NamedFieldDef {}
2240 impl ast::AttrsOwner for NamedFieldDef {}
2241 impl ast::DocCommentsOwner for NamedFieldDef {}
2242 impl ast::TypeAscriptionOwner for NamedFieldDef {}
2243 impl NamedFieldDef {}
2245 // NamedFieldDefList
2246 #[derive(Debug, PartialEq, Eq, Hash)]
2247 #[repr(transparent)]
2248 pub struct NamedFieldDefList {
2249 pub(crate) syntax: SyntaxNode,
2251 unsafe impl TransparentNewType for NamedFieldDefList {
2252 type Repr = rowan::SyntaxNode;
2255 impl AstNode for NamedFieldDefList {
2256 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2257 match syntax.kind() {
2258 NAMED_FIELD_DEF_LIST => Some(NamedFieldDefList::from_repr(syntax.into_repr())),
2262 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2265 impl ToOwned for NamedFieldDefList {
2266 type Owned = TreeArc<NamedFieldDefList>;
2267 fn to_owned(&self) -> TreeArc<NamedFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
2271 impl NamedFieldDefList {
2272 pub fn fields(&self) -> impl Iterator<Item = &NamedFieldDef> {
2273 super::children(self)
2278 #[derive(Debug, PartialEq, Eq, Hash)]
2279 #[repr(transparent)]
2280 pub struct NamedFieldList {
2281 pub(crate) syntax: SyntaxNode,
2283 unsafe impl TransparentNewType for NamedFieldList {
2284 type Repr = rowan::SyntaxNode;
2287 impl AstNode for NamedFieldList {
2288 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2289 match syntax.kind() {
2290 NAMED_FIELD_LIST => Some(NamedFieldList::from_repr(syntax.into_repr())),
2294 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2297 impl ToOwned for NamedFieldList {
2298 type Owned = TreeArc<NamedFieldList>;
2299 fn to_owned(&self) -> TreeArc<NamedFieldList> { TreeArc::cast(self.syntax.to_owned()) }
2303 impl NamedFieldList {
2304 pub fn fields(&self) -> impl Iterator<Item = &NamedField> {
2305 super::children(self)
2310 #[derive(Debug, PartialEq, Eq, Hash)]
2311 #[repr(transparent)]
2312 pub struct NeverType {
2313 pub(crate) syntax: SyntaxNode,
2315 unsafe impl TransparentNewType for NeverType {
2316 type Repr = rowan::SyntaxNode;
2319 impl AstNode for NeverType {
2320 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2321 match syntax.kind() {
2322 NEVER_TYPE => Some(NeverType::from_repr(syntax.into_repr())),
2326 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2329 impl ToOwned for NeverType {
2330 type Owned = TreeArc<NeverType>;
2331 fn to_owned(&self) -> TreeArc<NeverType> { TreeArc::cast(self.syntax.to_owned()) }
2338 #[derive(Debug, PartialEq, Eq, Hash)]
2339 #[repr(transparent)]
2340 pub struct NominalDef {
2341 pub(crate) syntax: SyntaxNode,
2343 unsafe impl TransparentNewType for NominalDef {
2344 type Repr = rowan::SyntaxNode;
2347 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2348 pub enum NominalDefKind<'a> {
2349 StructDef(&'a StructDef),
2350 EnumDef(&'a EnumDef),
2352 impl<'a> From<&'a StructDef> for &'a NominalDef {
2353 fn from(n: &'a StructDef) -> &'a NominalDef {
2354 NominalDef::cast(&n.syntax).unwrap()
2357 impl<'a> From<&'a EnumDef> for &'a NominalDef {
2358 fn from(n: &'a EnumDef) -> &'a NominalDef {
2359 NominalDef::cast(&n.syntax).unwrap()
2364 impl AstNode for NominalDef {
2365 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2366 match syntax.kind() {
2368 | ENUM_DEF => Some(NominalDef::from_repr(syntax.into_repr())),
2372 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2375 impl ToOwned for NominalDef {
2376 type Owned = TreeArc<NominalDef>;
2377 fn to_owned(&self) -> TreeArc<NominalDef> { TreeArc::cast(self.syntax.to_owned()) }
2381 pub fn kind(&self) -> NominalDefKind {
2382 match self.syntax.kind() {
2383 STRUCT_DEF => NominalDefKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2384 ENUM_DEF => NominalDefKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2385 _ => unreachable!(),
2390 impl ast::NameOwner for NominalDef {}
2391 impl ast::TypeParamsOwner for NominalDef {}
2392 impl ast::AttrsOwner for NominalDef {}
2396 #[derive(Debug, PartialEq, Eq, Hash)]
2397 #[repr(transparent)]
2399 pub(crate) syntax: SyntaxNode,
2401 unsafe impl TransparentNewType for Param {
2402 type Repr = rowan::SyntaxNode;
2405 impl AstNode for Param {
2406 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2407 match syntax.kind() {
2408 PARAM => Some(Param::from_repr(syntax.into_repr())),
2412 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2415 impl ToOwned for Param {
2416 type Owned = TreeArc<Param>;
2417 fn to_owned(&self) -> TreeArc<Param> { TreeArc::cast(self.syntax.to_owned()) }
2421 impl ast::TypeAscriptionOwner for Param {}
2423 pub fn pat(&self) -> Option<&Pat> {
2424 super::child_opt(self)
2429 #[derive(Debug, PartialEq, Eq, Hash)]
2430 #[repr(transparent)]
2431 pub struct ParamList {
2432 pub(crate) syntax: SyntaxNode,
2434 unsafe impl TransparentNewType for ParamList {
2435 type Repr = rowan::SyntaxNode;
2438 impl AstNode for ParamList {
2439 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2440 match syntax.kind() {
2441 PARAM_LIST => Some(ParamList::from_repr(syntax.into_repr())),
2445 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2448 impl ToOwned for ParamList {
2449 type Owned = TreeArc<ParamList>;
2450 fn to_owned(&self) -> TreeArc<ParamList> { TreeArc::cast(self.syntax.to_owned()) }
2455 pub fn params(&self) -> impl Iterator<Item = &Param> {
2456 super::children(self)
2459 pub fn self_param(&self) -> Option<&SelfParam> {
2460 super::child_opt(self)
2465 #[derive(Debug, PartialEq, Eq, Hash)]
2466 #[repr(transparent)]
2467 pub struct ParenExpr {
2468 pub(crate) syntax: SyntaxNode,
2470 unsafe impl TransparentNewType for ParenExpr {
2471 type Repr = rowan::SyntaxNode;
2474 impl AstNode for ParenExpr {
2475 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2476 match syntax.kind() {
2477 PAREN_EXPR => Some(ParenExpr::from_repr(syntax.into_repr())),
2481 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2484 impl ToOwned for ParenExpr {
2485 type Owned = TreeArc<ParenExpr>;
2486 fn to_owned(&self) -> TreeArc<ParenExpr> { TreeArc::cast(self.syntax.to_owned()) }
2491 pub fn expr(&self) -> Option<&Expr> {
2492 super::child_opt(self)
2497 #[derive(Debug, PartialEq, Eq, Hash)]
2498 #[repr(transparent)]
2499 pub struct ParenType {
2500 pub(crate) syntax: SyntaxNode,
2502 unsafe impl TransparentNewType for ParenType {
2503 type Repr = rowan::SyntaxNode;
2506 impl AstNode for ParenType {
2507 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2508 match syntax.kind() {
2509 PAREN_TYPE => Some(ParenType::from_repr(syntax.into_repr())),
2513 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2516 impl ToOwned for ParenType {
2517 type Owned = TreeArc<ParenType>;
2518 fn to_owned(&self) -> TreeArc<ParenType> { TreeArc::cast(self.syntax.to_owned()) }
2523 pub fn type_ref(&self) -> Option<&TypeRef> {
2524 super::child_opt(self)
2529 #[derive(Debug, PartialEq, Eq, Hash)]
2530 #[repr(transparent)]
2532 pub(crate) syntax: SyntaxNode,
2534 unsafe impl TransparentNewType for Pat {
2535 type Repr = rowan::SyntaxNode;
2538 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2539 pub enum PatKind<'a> {
2541 BindPat(&'a BindPat),
2542 PlaceholderPat(&'a PlaceholderPat),
2543 PathPat(&'a PathPat),
2544 StructPat(&'a StructPat),
2545 TupleStructPat(&'a TupleStructPat),
2546 TuplePat(&'a TuplePat),
2547 SlicePat(&'a SlicePat),
2548 RangePat(&'a RangePat),
2549 LiteralPat(&'a LiteralPat),
2551 impl<'a> From<&'a RefPat> for &'a Pat {
2552 fn from(n: &'a RefPat) -> &'a Pat {
2553 Pat::cast(&n.syntax).unwrap()
2556 impl<'a> From<&'a BindPat> for &'a Pat {
2557 fn from(n: &'a BindPat) -> &'a Pat {
2558 Pat::cast(&n.syntax).unwrap()
2561 impl<'a> From<&'a PlaceholderPat> for &'a Pat {
2562 fn from(n: &'a PlaceholderPat) -> &'a Pat {
2563 Pat::cast(&n.syntax).unwrap()
2566 impl<'a> From<&'a PathPat> for &'a Pat {
2567 fn from(n: &'a PathPat) -> &'a Pat {
2568 Pat::cast(&n.syntax).unwrap()
2571 impl<'a> From<&'a StructPat> for &'a Pat {
2572 fn from(n: &'a StructPat) -> &'a Pat {
2573 Pat::cast(&n.syntax).unwrap()
2576 impl<'a> From<&'a TupleStructPat> for &'a Pat {
2577 fn from(n: &'a TupleStructPat) -> &'a Pat {
2578 Pat::cast(&n.syntax).unwrap()
2581 impl<'a> From<&'a TuplePat> for &'a Pat {
2582 fn from(n: &'a TuplePat) -> &'a Pat {
2583 Pat::cast(&n.syntax).unwrap()
2586 impl<'a> From<&'a SlicePat> for &'a Pat {
2587 fn from(n: &'a SlicePat) -> &'a Pat {
2588 Pat::cast(&n.syntax).unwrap()
2591 impl<'a> From<&'a RangePat> for &'a Pat {
2592 fn from(n: &'a RangePat) -> &'a Pat {
2593 Pat::cast(&n.syntax).unwrap()
2596 impl<'a> From<&'a LiteralPat> for &'a Pat {
2597 fn from(n: &'a LiteralPat) -> &'a Pat {
2598 Pat::cast(&n.syntax).unwrap()
2603 impl AstNode for Pat {
2604 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2605 match syntax.kind() {
2615 | LITERAL_PAT => Some(Pat::from_repr(syntax.into_repr())),
2619 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2622 impl ToOwned for Pat {
2623 type Owned = TreeArc<Pat>;
2624 fn to_owned(&self) -> TreeArc<Pat> { TreeArc::cast(self.syntax.to_owned()) }
2628 pub fn kind(&self) -> PatKind {
2629 match self.syntax.kind() {
2630 REF_PAT => PatKind::RefPat(RefPat::cast(&self.syntax).unwrap()),
2631 BIND_PAT => PatKind::BindPat(BindPat::cast(&self.syntax).unwrap()),
2632 PLACEHOLDER_PAT => PatKind::PlaceholderPat(PlaceholderPat::cast(&self.syntax).unwrap()),
2633 PATH_PAT => PatKind::PathPat(PathPat::cast(&self.syntax).unwrap()),
2634 STRUCT_PAT => PatKind::StructPat(StructPat::cast(&self.syntax).unwrap()),
2635 TUPLE_STRUCT_PAT => PatKind::TupleStructPat(TupleStructPat::cast(&self.syntax).unwrap()),
2636 TUPLE_PAT => PatKind::TuplePat(TuplePat::cast(&self.syntax).unwrap()),
2637 SLICE_PAT => PatKind::SlicePat(SlicePat::cast(&self.syntax).unwrap()),
2638 RANGE_PAT => PatKind::RangePat(RangePat::cast(&self.syntax).unwrap()),
2639 LITERAL_PAT => PatKind::LiteralPat(LiteralPat::cast(&self.syntax).unwrap()),
2640 _ => unreachable!(),
2648 #[derive(Debug, PartialEq, Eq, Hash)]
2649 #[repr(transparent)]
2651 pub(crate) syntax: SyntaxNode,
2653 unsafe impl TransparentNewType for Path {
2654 type Repr = rowan::SyntaxNode;
2657 impl AstNode for Path {
2658 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2659 match syntax.kind() {
2660 PATH => Some(Path::from_repr(syntax.into_repr())),
2664 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2667 impl ToOwned for Path {
2668 type Owned = TreeArc<Path>;
2669 fn to_owned(&self) -> TreeArc<Path> { TreeArc::cast(self.syntax.to_owned()) }
2674 pub fn segment(&self) -> Option<&PathSegment> {
2675 super::child_opt(self)
2678 pub fn qualifier(&self) -> Option<&Path> {
2679 super::child_opt(self)
2684 #[derive(Debug, PartialEq, Eq, Hash)]
2685 #[repr(transparent)]
2686 pub struct PathExpr {
2687 pub(crate) syntax: SyntaxNode,
2689 unsafe impl TransparentNewType for PathExpr {
2690 type Repr = rowan::SyntaxNode;
2693 impl AstNode for PathExpr {
2694 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2695 match syntax.kind() {
2696 PATH_EXPR => Some(PathExpr::from_repr(syntax.into_repr())),
2700 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2703 impl ToOwned for PathExpr {
2704 type Owned = TreeArc<PathExpr>;
2705 fn to_owned(&self) -> TreeArc<PathExpr> { TreeArc::cast(self.syntax.to_owned()) }
2710 pub fn path(&self) -> Option<&Path> {
2711 super::child_opt(self)
2716 #[derive(Debug, PartialEq, Eq, Hash)]
2717 #[repr(transparent)]
2718 pub struct PathPat {
2719 pub(crate) syntax: SyntaxNode,
2721 unsafe impl TransparentNewType for PathPat {
2722 type Repr = rowan::SyntaxNode;
2725 impl AstNode for PathPat {
2726 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2727 match syntax.kind() {
2728 PATH_PAT => Some(PathPat::from_repr(syntax.into_repr())),
2732 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2735 impl ToOwned for PathPat {
2736 type Owned = TreeArc<PathPat>;
2737 fn to_owned(&self) -> TreeArc<PathPat> { TreeArc::cast(self.syntax.to_owned()) }
2742 pub fn path(&self) -> Option<&Path> {
2743 super::child_opt(self)
2748 #[derive(Debug, PartialEq, Eq, Hash)]
2749 #[repr(transparent)]
2750 pub struct PathSegment {
2751 pub(crate) syntax: SyntaxNode,
2753 unsafe impl TransparentNewType for PathSegment {
2754 type Repr = rowan::SyntaxNode;
2757 impl AstNode for PathSegment {
2758 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2759 match syntax.kind() {
2760 PATH_SEGMENT => Some(PathSegment::from_repr(syntax.into_repr())),
2764 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2767 impl ToOwned for PathSegment {
2768 type Owned = TreeArc<PathSegment>;
2769 fn to_owned(&self) -> TreeArc<PathSegment> { TreeArc::cast(self.syntax.to_owned()) }
2774 pub fn name_ref(&self) -> Option<&NameRef> {
2775 super::child_opt(self)
2778 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
2779 super::child_opt(self)
2784 #[derive(Debug, PartialEq, Eq, Hash)]
2785 #[repr(transparent)]
2786 pub struct PathType {
2787 pub(crate) syntax: SyntaxNode,
2789 unsafe impl TransparentNewType for PathType {
2790 type Repr = rowan::SyntaxNode;
2793 impl AstNode for PathType {
2794 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2795 match syntax.kind() {
2796 PATH_TYPE => Some(PathType::from_repr(syntax.into_repr())),
2800 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2803 impl ToOwned for PathType {
2804 type Owned = TreeArc<PathType>;
2805 fn to_owned(&self) -> TreeArc<PathType> { TreeArc::cast(self.syntax.to_owned()) }
2810 pub fn path(&self) -> Option<&Path> {
2811 super::child_opt(self)
2816 #[derive(Debug, PartialEq, Eq, Hash)]
2817 #[repr(transparent)]
2818 pub struct PlaceholderPat {
2819 pub(crate) syntax: SyntaxNode,
2821 unsafe impl TransparentNewType for PlaceholderPat {
2822 type Repr = rowan::SyntaxNode;
2825 impl AstNode for PlaceholderPat {
2826 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2827 match syntax.kind() {
2828 PLACEHOLDER_PAT => Some(PlaceholderPat::from_repr(syntax.into_repr())),
2832 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2835 impl ToOwned for PlaceholderPat {
2836 type Owned = TreeArc<PlaceholderPat>;
2837 fn to_owned(&self) -> TreeArc<PlaceholderPat> { TreeArc::cast(self.syntax.to_owned()) }
2841 impl PlaceholderPat {}
2844 #[derive(Debug, PartialEq, Eq, Hash)]
2845 #[repr(transparent)]
2846 pub struct PlaceholderType {
2847 pub(crate) syntax: SyntaxNode,
2849 unsafe impl TransparentNewType for PlaceholderType {
2850 type Repr = rowan::SyntaxNode;
2853 impl AstNode for PlaceholderType {
2854 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2855 match syntax.kind() {
2856 PLACEHOLDER_TYPE => Some(PlaceholderType::from_repr(syntax.into_repr())),
2860 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2863 impl ToOwned for PlaceholderType {
2864 type Owned = TreeArc<PlaceholderType>;
2865 fn to_owned(&self) -> TreeArc<PlaceholderType> { TreeArc::cast(self.syntax.to_owned()) }
2869 impl PlaceholderType {}
2872 #[derive(Debug, PartialEq, Eq, Hash)]
2873 #[repr(transparent)]
2874 pub struct PointerType {
2875 pub(crate) syntax: SyntaxNode,
2877 unsafe impl TransparentNewType for PointerType {
2878 type Repr = rowan::SyntaxNode;
2881 impl AstNode for PointerType {
2882 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2883 match syntax.kind() {
2884 POINTER_TYPE => Some(PointerType::from_repr(syntax.into_repr())),
2888 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2891 impl ToOwned for PointerType {
2892 type Owned = TreeArc<PointerType>;
2893 fn to_owned(&self) -> TreeArc<PointerType> { TreeArc::cast(self.syntax.to_owned()) }
2898 pub fn type_ref(&self) -> Option<&TypeRef> {
2899 super::child_opt(self)
2904 #[derive(Debug, PartialEq, Eq, Hash)]
2905 #[repr(transparent)]
2906 pub struct PosFieldDef {
2907 pub(crate) syntax: SyntaxNode,
2909 unsafe impl TransparentNewType for PosFieldDef {
2910 type Repr = rowan::SyntaxNode;
2913 impl AstNode for PosFieldDef {
2914 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2915 match syntax.kind() {
2916 POS_FIELD_DEF => Some(PosFieldDef::from_repr(syntax.into_repr())),
2920 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2923 impl ToOwned for PosFieldDef {
2924 type Owned = TreeArc<PosFieldDef>;
2925 fn to_owned(&self) -> TreeArc<PosFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2929 impl ast::VisibilityOwner for PosFieldDef {}
2930 impl ast::AttrsOwner for PosFieldDef {}
2932 pub fn type_ref(&self) -> Option<&TypeRef> {
2933 super::child_opt(self)
2938 #[derive(Debug, PartialEq, Eq, Hash)]
2939 #[repr(transparent)]
2940 pub struct PosFieldDefList {
2941 pub(crate) syntax: SyntaxNode,
2943 unsafe impl TransparentNewType for PosFieldDefList {
2944 type Repr = rowan::SyntaxNode;
2947 impl AstNode for PosFieldDefList {
2948 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2949 match syntax.kind() {
2950 POS_FIELD_DEF_LIST => Some(PosFieldDefList::from_repr(syntax.into_repr())),
2954 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2957 impl ToOwned for PosFieldDefList {
2958 type Owned = TreeArc<PosFieldDefList>;
2959 fn to_owned(&self) -> TreeArc<PosFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
2963 impl PosFieldDefList {
2964 pub fn fields(&self) -> impl Iterator<Item = &PosFieldDef> {
2965 super::children(self)
2970 #[derive(Debug, PartialEq, Eq, Hash)]
2971 #[repr(transparent)]
2972 pub struct PrefixExpr {
2973 pub(crate) syntax: SyntaxNode,
2975 unsafe impl TransparentNewType for PrefixExpr {
2976 type Repr = rowan::SyntaxNode;
2979 impl AstNode for PrefixExpr {
2980 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2981 match syntax.kind() {
2982 PREFIX_EXPR => Some(PrefixExpr::from_repr(syntax.into_repr())),
2986 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2989 impl ToOwned for PrefixExpr {
2990 type Owned = TreeArc<PrefixExpr>;
2991 fn to_owned(&self) -> TreeArc<PrefixExpr> { TreeArc::cast(self.syntax.to_owned()) }
2996 pub fn expr(&self) -> Option<&Expr> {
2997 super::child_opt(self)
3002 #[derive(Debug, PartialEq, Eq, Hash)]
3003 #[repr(transparent)]
3004 pub struct RangeExpr {
3005 pub(crate) syntax: SyntaxNode,
3007 unsafe impl TransparentNewType for RangeExpr {
3008 type Repr = rowan::SyntaxNode;
3011 impl AstNode for RangeExpr {
3012 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3013 match syntax.kind() {
3014 RANGE_EXPR => Some(RangeExpr::from_repr(syntax.into_repr())),
3018 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3021 impl ToOwned for RangeExpr {
3022 type Owned = TreeArc<RangeExpr>;
3023 fn to_owned(&self) -> TreeArc<RangeExpr> { TreeArc::cast(self.syntax.to_owned()) }
3030 #[derive(Debug, PartialEq, Eq, Hash)]
3031 #[repr(transparent)]
3032 pub struct RangePat {
3033 pub(crate) syntax: SyntaxNode,
3035 unsafe impl TransparentNewType for RangePat {
3036 type Repr = rowan::SyntaxNode;
3039 impl AstNode for RangePat {
3040 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3041 match syntax.kind() {
3042 RANGE_PAT => Some(RangePat::from_repr(syntax.into_repr())),
3046 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3049 impl ToOwned for RangePat {
3050 type Owned = TreeArc<RangePat>;
3051 fn to_owned(&self) -> TreeArc<RangePat> { TreeArc::cast(self.syntax.to_owned()) }
3058 #[derive(Debug, PartialEq, Eq, Hash)]
3059 #[repr(transparent)]
3060 pub struct RefExpr {
3061 pub(crate) syntax: SyntaxNode,
3063 unsafe impl TransparentNewType for RefExpr {
3064 type Repr = rowan::SyntaxNode;
3067 impl AstNode for RefExpr {
3068 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3069 match syntax.kind() {
3070 REF_EXPR => Some(RefExpr::from_repr(syntax.into_repr())),
3074 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3077 impl ToOwned for RefExpr {
3078 type Owned = TreeArc<RefExpr>;
3079 fn to_owned(&self) -> TreeArc<RefExpr> { TreeArc::cast(self.syntax.to_owned()) }
3084 pub fn expr(&self) -> Option<&Expr> {
3085 super::child_opt(self)
3090 #[derive(Debug, PartialEq, Eq, Hash)]
3091 #[repr(transparent)]
3093 pub(crate) syntax: SyntaxNode,
3095 unsafe impl TransparentNewType for RefPat {
3096 type Repr = rowan::SyntaxNode;
3099 impl AstNode for RefPat {
3100 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3101 match syntax.kind() {
3102 REF_PAT => Some(RefPat::from_repr(syntax.into_repr())),
3106 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3109 impl ToOwned for RefPat {
3110 type Owned = TreeArc<RefPat>;
3111 fn to_owned(&self) -> TreeArc<RefPat> { TreeArc::cast(self.syntax.to_owned()) }
3116 pub fn pat(&self) -> Option<&Pat> {
3117 super::child_opt(self)
3122 #[derive(Debug, PartialEq, Eq, Hash)]
3123 #[repr(transparent)]
3124 pub struct ReferenceType {
3125 pub(crate) syntax: SyntaxNode,
3127 unsafe impl TransparentNewType for ReferenceType {
3128 type Repr = rowan::SyntaxNode;
3131 impl AstNode for ReferenceType {
3132 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3133 match syntax.kind() {
3134 REFERENCE_TYPE => Some(ReferenceType::from_repr(syntax.into_repr())),
3138 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3141 impl ToOwned for ReferenceType {
3142 type Owned = TreeArc<ReferenceType>;
3143 fn to_owned(&self) -> TreeArc<ReferenceType> { TreeArc::cast(self.syntax.to_owned()) }
3147 impl ReferenceType {
3148 pub fn type_ref(&self) -> Option<&TypeRef> {
3149 super::child_opt(self)
3154 #[derive(Debug, PartialEq, Eq, Hash)]
3155 #[repr(transparent)]
3156 pub struct RetType {
3157 pub(crate) syntax: SyntaxNode,
3159 unsafe impl TransparentNewType for RetType {
3160 type Repr = rowan::SyntaxNode;
3163 impl AstNode for RetType {
3164 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3165 match syntax.kind() {
3166 RET_TYPE => Some(RetType::from_repr(syntax.into_repr())),
3170 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3173 impl ToOwned for RetType {
3174 type Owned = TreeArc<RetType>;
3175 fn to_owned(&self) -> TreeArc<RetType> { TreeArc::cast(self.syntax.to_owned()) }
3180 pub fn type_ref(&self) -> Option<&TypeRef> {
3181 super::child_opt(self)
3186 #[derive(Debug, PartialEq, Eq, Hash)]
3187 #[repr(transparent)]
3188 pub struct ReturnExpr {
3189 pub(crate) syntax: SyntaxNode,
3191 unsafe impl TransparentNewType for ReturnExpr {
3192 type Repr = rowan::SyntaxNode;
3195 impl AstNode for ReturnExpr {
3196 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3197 match syntax.kind() {
3198 RETURN_EXPR => Some(ReturnExpr::from_repr(syntax.into_repr())),
3202 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3205 impl ToOwned for ReturnExpr {
3206 type Owned = TreeArc<ReturnExpr>;
3207 fn to_owned(&self) -> TreeArc<ReturnExpr> { TreeArc::cast(self.syntax.to_owned()) }
3212 pub fn expr(&self) -> Option<&Expr> {
3213 super::child_opt(self)
3218 #[derive(Debug, PartialEq, Eq, Hash)]
3219 #[repr(transparent)]
3220 pub struct SelfParam {
3221 pub(crate) syntax: SyntaxNode,
3223 unsafe impl TransparentNewType for SelfParam {
3224 type Repr = rowan::SyntaxNode;
3227 impl AstNode for SelfParam {
3228 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3229 match syntax.kind() {
3230 SELF_PARAM => Some(SelfParam::from_repr(syntax.into_repr())),
3234 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3237 impl ToOwned for SelfParam {
3238 type Owned = TreeArc<SelfParam>;
3239 fn to_owned(&self) -> TreeArc<SelfParam> { TreeArc::cast(self.syntax.to_owned()) }
3243 impl ast::TypeAscriptionOwner for SelfParam {}
3247 #[derive(Debug, PartialEq, Eq, Hash)]
3248 #[repr(transparent)]
3249 pub struct SlicePat {
3250 pub(crate) syntax: SyntaxNode,
3252 unsafe impl TransparentNewType for SlicePat {
3253 type Repr = rowan::SyntaxNode;
3256 impl AstNode for SlicePat {
3257 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3258 match syntax.kind() {
3259 SLICE_PAT => Some(SlicePat::from_repr(syntax.into_repr())),
3263 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3266 impl ToOwned for SlicePat {
3267 type Owned = TreeArc<SlicePat>;
3268 fn to_owned(&self) -> TreeArc<SlicePat> { TreeArc::cast(self.syntax.to_owned()) }
3275 #[derive(Debug, PartialEq, Eq, Hash)]
3276 #[repr(transparent)]
3277 pub struct SliceType {
3278 pub(crate) syntax: SyntaxNode,
3280 unsafe impl TransparentNewType for SliceType {
3281 type Repr = rowan::SyntaxNode;
3284 impl AstNode for SliceType {
3285 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3286 match syntax.kind() {
3287 SLICE_TYPE => Some(SliceType::from_repr(syntax.into_repr())),
3291 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3294 impl ToOwned for SliceType {
3295 type Owned = TreeArc<SliceType>;
3296 fn to_owned(&self) -> TreeArc<SliceType> { TreeArc::cast(self.syntax.to_owned()) }
3301 pub fn type_ref(&self) -> Option<&TypeRef> {
3302 super::child_opt(self)
3307 #[derive(Debug, PartialEq, Eq, Hash)]
3308 #[repr(transparent)]
3309 pub struct SourceFile {
3310 pub(crate) syntax: SyntaxNode,
3312 unsafe impl TransparentNewType for SourceFile {
3313 type Repr = rowan::SyntaxNode;
3316 impl AstNode for SourceFile {
3317 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3318 match syntax.kind() {
3319 SOURCE_FILE => Some(SourceFile::from_repr(syntax.into_repr())),
3323 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3326 impl ToOwned for SourceFile {
3327 type Owned = TreeArc<SourceFile>;
3328 fn to_owned(&self) -> TreeArc<SourceFile> { TreeArc::cast(self.syntax.to_owned()) }
3332 impl ast::ModuleItemOwner for SourceFile {}
3333 impl ast::FnDefOwner for SourceFile {}
3335 pub fn modules(&self) -> impl Iterator<Item = &Module> {
3336 super::children(self)
3341 #[derive(Debug, PartialEq, Eq, Hash)]
3342 #[repr(transparent)]
3343 pub struct StaticDef {
3344 pub(crate) syntax: SyntaxNode,
3346 unsafe impl TransparentNewType for StaticDef {
3347 type Repr = rowan::SyntaxNode;
3350 impl AstNode for StaticDef {
3351 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3352 match syntax.kind() {
3353 STATIC_DEF => Some(StaticDef::from_repr(syntax.into_repr())),
3357 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3360 impl ToOwned for StaticDef {
3361 type Owned = TreeArc<StaticDef>;
3362 fn to_owned(&self) -> TreeArc<StaticDef> { TreeArc::cast(self.syntax.to_owned()) }
3366 impl ast::VisibilityOwner for StaticDef {}
3367 impl ast::NameOwner for StaticDef {}
3368 impl ast::TypeParamsOwner for StaticDef {}
3369 impl ast::AttrsOwner for StaticDef {}
3370 impl ast::DocCommentsOwner for StaticDef {}
3371 impl ast::TypeAscriptionOwner for StaticDef {}
3373 pub fn body(&self) -> Option<&Expr> {
3374 super::child_opt(self)
3379 #[derive(Debug, PartialEq, Eq, Hash)]
3380 #[repr(transparent)]
3382 pub(crate) syntax: SyntaxNode,
3384 unsafe impl TransparentNewType for Stmt {
3385 type Repr = rowan::SyntaxNode;
3388 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3389 pub enum StmtKind<'a> {
3390 ExprStmt(&'a ExprStmt),
3391 LetStmt(&'a LetStmt),
3393 impl<'a> From<&'a ExprStmt> for &'a Stmt {
3394 fn from(n: &'a ExprStmt) -> &'a Stmt {
3395 Stmt::cast(&n.syntax).unwrap()
3398 impl<'a> From<&'a LetStmt> for &'a Stmt {
3399 fn from(n: &'a LetStmt) -> &'a Stmt {
3400 Stmt::cast(&n.syntax).unwrap()
3405 impl AstNode for Stmt {
3406 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3407 match syntax.kind() {
3409 | LET_STMT => Some(Stmt::from_repr(syntax.into_repr())),
3413 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3416 impl ToOwned for Stmt {
3417 type Owned = TreeArc<Stmt>;
3418 fn to_owned(&self) -> TreeArc<Stmt> { TreeArc::cast(self.syntax.to_owned()) }
3422 pub fn kind(&self) -> StmtKind {
3423 match self.syntax.kind() {
3424 EXPR_STMT => StmtKind::ExprStmt(ExprStmt::cast(&self.syntax).unwrap()),
3425 LET_STMT => StmtKind::LetStmt(LetStmt::cast(&self.syntax).unwrap()),
3426 _ => unreachable!(),
3434 #[derive(Debug, PartialEq, Eq, Hash)]
3435 #[repr(transparent)]
3436 pub struct StructDef {
3437 pub(crate) syntax: SyntaxNode,
3439 unsafe impl TransparentNewType for StructDef {
3440 type Repr = rowan::SyntaxNode;
3443 impl AstNode for StructDef {
3444 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3445 match syntax.kind() {
3446 STRUCT_DEF => Some(StructDef::from_repr(syntax.into_repr())),
3450 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3453 impl ToOwned for StructDef {
3454 type Owned = TreeArc<StructDef>;
3455 fn to_owned(&self) -> TreeArc<StructDef> { TreeArc::cast(self.syntax.to_owned()) }
3459 impl ast::VisibilityOwner for StructDef {}
3460 impl ast::NameOwner for StructDef {}
3461 impl ast::TypeParamsOwner for StructDef {}
3462 impl ast::AttrsOwner for StructDef {}
3463 impl ast::DocCommentsOwner for StructDef {}
3467 #[derive(Debug, PartialEq, Eq, Hash)]
3468 #[repr(transparent)]
3469 pub struct StructLit {
3470 pub(crate) syntax: SyntaxNode,
3472 unsafe impl TransparentNewType for StructLit {
3473 type Repr = rowan::SyntaxNode;
3476 impl AstNode for StructLit {
3477 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3478 match syntax.kind() {
3479 STRUCT_LIT => Some(StructLit::from_repr(syntax.into_repr())),
3483 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3486 impl ToOwned for StructLit {
3487 type Owned = TreeArc<StructLit>;
3488 fn to_owned(&self) -> TreeArc<StructLit> { TreeArc::cast(self.syntax.to_owned()) }
3493 pub fn path(&self) -> Option<&Path> {
3494 super::child_opt(self)
3497 pub fn named_field_list(&self) -> Option<&NamedFieldList> {
3498 super::child_opt(self)
3501 pub fn spread(&self) -> Option<&Expr> {
3502 super::child_opt(self)
3507 #[derive(Debug, PartialEq, Eq, Hash)]
3508 #[repr(transparent)]
3509 pub struct StructPat {
3510 pub(crate) syntax: SyntaxNode,
3512 unsafe impl TransparentNewType for StructPat {
3513 type Repr = rowan::SyntaxNode;
3516 impl AstNode for StructPat {
3517 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3518 match syntax.kind() {
3519 STRUCT_PAT => Some(StructPat::from_repr(syntax.into_repr())),
3523 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3526 impl ToOwned for StructPat {
3527 type Owned = TreeArc<StructPat>;
3528 fn to_owned(&self) -> TreeArc<StructPat> { TreeArc::cast(self.syntax.to_owned()) }
3533 pub fn field_pat_list(&self) -> Option<&FieldPatList> {
3534 super::child_opt(self)
3537 pub fn path(&self) -> Option<&Path> {
3538 super::child_opt(self)
3543 #[derive(Debug, PartialEq, Eq, Hash)]
3544 #[repr(transparent)]
3545 pub struct TokenTree {
3546 pub(crate) syntax: SyntaxNode,
3548 unsafe impl TransparentNewType for TokenTree {
3549 type Repr = rowan::SyntaxNode;
3552 impl AstNode for TokenTree {
3553 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3554 match syntax.kind() {
3555 TOKEN_TREE => Some(TokenTree::from_repr(syntax.into_repr())),
3559 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3562 impl ToOwned for TokenTree {
3563 type Owned = TreeArc<TokenTree>;
3564 fn to_owned(&self) -> TreeArc<TokenTree> { TreeArc::cast(self.syntax.to_owned()) }
3571 #[derive(Debug, PartialEq, Eq, Hash)]
3572 #[repr(transparent)]
3573 pub struct TraitDef {
3574 pub(crate) syntax: SyntaxNode,
3576 unsafe impl TransparentNewType for TraitDef {
3577 type Repr = rowan::SyntaxNode;
3580 impl AstNode for TraitDef {
3581 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3582 match syntax.kind() {
3583 TRAIT_DEF => Some(TraitDef::from_repr(syntax.into_repr())),
3587 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3590 impl ToOwned for TraitDef {
3591 type Owned = TreeArc<TraitDef>;
3592 fn to_owned(&self) -> TreeArc<TraitDef> { TreeArc::cast(self.syntax.to_owned()) }
3596 impl ast::VisibilityOwner for TraitDef {}
3597 impl ast::NameOwner for TraitDef {}
3598 impl ast::AttrsOwner for TraitDef {}
3599 impl ast::DocCommentsOwner for TraitDef {}
3600 impl ast::TypeParamsOwner for TraitDef {}
3601 impl ast::TypeBoundsOwner for TraitDef {}
3603 pub fn item_list(&self) -> Option<&ItemList> {
3604 super::child_opt(self)
3609 #[derive(Debug, PartialEq, Eq, Hash)]
3610 #[repr(transparent)]
3611 pub struct TryExpr {
3612 pub(crate) syntax: SyntaxNode,
3614 unsafe impl TransparentNewType for TryExpr {
3615 type Repr = rowan::SyntaxNode;
3618 impl AstNode for TryExpr {
3619 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3620 match syntax.kind() {
3621 TRY_EXPR => Some(TryExpr::from_repr(syntax.into_repr())),
3625 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3628 impl ToOwned for TryExpr {
3629 type Owned = TreeArc<TryExpr>;
3630 fn to_owned(&self) -> TreeArc<TryExpr> { TreeArc::cast(self.syntax.to_owned()) }
3635 pub fn expr(&self) -> Option<&Expr> {
3636 super::child_opt(self)
3641 #[derive(Debug, PartialEq, Eq, Hash)]
3642 #[repr(transparent)]
3643 pub struct TupleExpr {
3644 pub(crate) syntax: SyntaxNode,
3646 unsafe impl TransparentNewType for TupleExpr {
3647 type Repr = rowan::SyntaxNode;
3650 impl AstNode for TupleExpr {
3651 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3652 match syntax.kind() {
3653 TUPLE_EXPR => Some(TupleExpr::from_repr(syntax.into_repr())),
3657 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3660 impl ToOwned for TupleExpr {
3661 type Owned = TreeArc<TupleExpr>;
3662 fn to_owned(&self) -> TreeArc<TupleExpr> { TreeArc::cast(self.syntax.to_owned()) }
3667 pub fn exprs(&self) -> impl Iterator<Item = &Expr> {
3668 super::children(self)
3673 #[derive(Debug, PartialEq, Eq, Hash)]
3674 #[repr(transparent)]
3675 pub struct TuplePat {
3676 pub(crate) syntax: SyntaxNode,
3678 unsafe impl TransparentNewType for TuplePat {
3679 type Repr = rowan::SyntaxNode;
3682 impl AstNode for TuplePat {
3683 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3684 match syntax.kind() {
3685 TUPLE_PAT => Some(TuplePat::from_repr(syntax.into_repr())),
3689 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3692 impl ToOwned for TuplePat {
3693 type Owned = TreeArc<TuplePat>;
3694 fn to_owned(&self) -> TreeArc<TuplePat> { TreeArc::cast(self.syntax.to_owned()) }
3699 pub fn args(&self) -> impl Iterator<Item = &Pat> {
3700 super::children(self)
3705 #[derive(Debug, PartialEq, Eq, Hash)]
3706 #[repr(transparent)]
3707 pub struct TupleStructPat {
3708 pub(crate) syntax: SyntaxNode,
3710 unsafe impl TransparentNewType for TupleStructPat {
3711 type Repr = rowan::SyntaxNode;
3714 impl AstNode for TupleStructPat {
3715 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3716 match syntax.kind() {
3717 TUPLE_STRUCT_PAT => Some(TupleStructPat::from_repr(syntax.into_repr())),
3721 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3724 impl ToOwned for TupleStructPat {
3725 type Owned = TreeArc<TupleStructPat>;
3726 fn to_owned(&self) -> TreeArc<TupleStructPat> { TreeArc::cast(self.syntax.to_owned()) }
3730 impl TupleStructPat {
3731 pub fn args(&self) -> impl Iterator<Item = &Pat> {
3732 super::children(self)
3735 pub fn path(&self) -> Option<&Path> {
3736 super::child_opt(self)
3741 #[derive(Debug, PartialEq, Eq, Hash)]
3742 #[repr(transparent)]
3743 pub struct TupleType {
3744 pub(crate) syntax: SyntaxNode,
3746 unsafe impl TransparentNewType for TupleType {
3747 type Repr = rowan::SyntaxNode;
3750 impl AstNode for TupleType {
3751 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3752 match syntax.kind() {
3753 TUPLE_TYPE => Some(TupleType::from_repr(syntax.into_repr())),
3757 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3760 impl ToOwned for TupleType {
3761 type Owned = TreeArc<TupleType>;
3762 fn to_owned(&self) -> TreeArc<TupleType> { TreeArc::cast(self.syntax.to_owned()) }
3767 pub fn fields(&self) -> impl Iterator<Item = &TypeRef> {
3768 super::children(self)
3773 #[derive(Debug, PartialEq, Eq, Hash)]
3774 #[repr(transparent)]
3775 pub struct TypeAliasDef {
3776 pub(crate) syntax: SyntaxNode,
3778 unsafe impl TransparentNewType for TypeAliasDef {
3779 type Repr = rowan::SyntaxNode;
3782 impl AstNode for TypeAliasDef {
3783 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3784 match syntax.kind() {
3785 TYPE_ALIAS_DEF => Some(TypeAliasDef::from_repr(syntax.into_repr())),
3789 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3792 impl ToOwned for TypeAliasDef {
3793 type Owned = TreeArc<TypeAliasDef>;
3794 fn to_owned(&self) -> TreeArc<TypeAliasDef> { TreeArc::cast(self.syntax.to_owned()) }
3798 impl ast::VisibilityOwner for TypeAliasDef {}
3799 impl ast::NameOwner for TypeAliasDef {}
3800 impl ast::TypeParamsOwner for TypeAliasDef {}
3801 impl ast::AttrsOwner for TypeAliasDef {}
3802 impl ast::DocCommentsOwner for TypeAliasDef {}
3803 impl ast::TypeBoundsOwner for TypeAliasDef {}
3805 pub fn type_ref(&self) -> Option<&TypeRef> {
3806 super::child_opt(self)
3811 #[derive(Debug, PartialEq, Eq, Hash)]
3812 #[repr(transparent)]
3813 pub struct TypeArg {
3814 pub(crate) syntax: SyntaxNode,
3816 unsafe impl TransparentNewType for TypeArg {
3817 type Repr = rowan::SyntaxNode;
3820 impl AstNode for TypeArg {
3821 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3822 match syntax.kind() {
3823 TYPE_ARG => Some(TypeArg::from_repr(syntax.into_repr())),
3827 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3830 impl ToOwned for TypeArg {
3831 type Owned = TreeArc<TypeArg>;
3832 fn to_owned(&self) -> TreeArc<TypeArg> { TreeArc::cast(self.syntax.to_owned()) }
3837 pub fn type_ref(&self) -> Option<&TypeRef> {
3838 super::child_opt(self)
3843 #[derive(Debug, PartialEq, Eq, Hash)]
3844 #[repr(transparent)]
3845 pub struct TypeArgList {
3846 pub(crate) syntax: SyntaxNode,
3848 unsafe impl TransparentNewType for TypeArgList {
3849 type Repr = rowan::SyntaxNode;
3852 impl AstNode for TypeArgList {
3853 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3854 match syntax.kind() {
3855 TYPE_ARG_LIST => Some(TypeArgList::from_repr(syntax.into_repr())),
3859 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3862 impl ToOwned for TypeArgList {
3863 type Owned = TreeArc<TypeArgList>;
3864 fn to_owned(&self) -> TreeArc<TypeArgList> { TreeArc::cast(self.syntax.to_owned()) }
3869 pub fn type_args(&self) -> impl Iterator<Item = &TypeArg> {
3870 super::children(self)
3873 pub fn lifetime_args(&self) -> impl Iterator<Item = &LifetimeArg> {
3874 super::children(self)
3877 pub fn assoc_type_args(&self) -> impl Iterator<Item = &AssocTypeArg> {
3878 super::children(self)
3883 #[derive(Debug, PartialEq, Eq, Hash)]
3884 #[repr(transparent)]
3885 pub struct TypeBound {
3886 pub(crate) syntax: SyntaxNode,
3888 unsafe impl TransparentNewType for TypeBound {
3889 type Repr = rowan::SyntaxNode;
3892 impl AstNode for TypeBound {
3893 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3894 match syntax.kind() {
3895 TYPE_BOUND => Some(TypeBound::from_repr(syntax.into_repr())),
3899 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3902 impl ToOwned for TypeBound {
3903 type Owned = TreeArc<TypeBound>;
3904 fn to_owned(&self) -> TreeArc<TypeBound> { TreeArc::cast(self.syntax.to_owned()) }
3909 pub fn type_ref(&self) -> Option<&TypeRef> {
3910 super::child_opt(self)
3915 #[derive(Debug, PartialEq, Eq, Hash)]
3916 #[repr(transparent)]
3917 pub struct TypeBoundList {
3918 pub(crate) syntax: SyntaxNode,
3920 unsafe impl TransparentNewType for TypeBoundList {
3921 type Repr = rowan::SyntaxNode;
3924 impl AstNode for TypeBoundList {
3925 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3926 match syntax.kind() {
3927 TYPE_BOUND_LIST => Some(TypeBoundList::from_repr(syntax.into_repr())),
3931 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3934 impl ToOwned for TypeBoundList {
3935 type Owned = TreeArc<TypeBoundList>;
3936 fn to_owned(&self) -> TreeArc<TypeBoundList> { TreeArc::cast(self.syntax.to_owned()) }
3940 impl TypeBoundList {
3941 pub fn bounds(&self) -> impl Iterator<Item = &TypeBound> {
3942 super::children(self)
3947 #[derive(Debug, PartialEq, Eq, Hash)]
3948 #[repr(transparent)]
3949 pub struct TypeParam {
3950 pub(crate) syntax: SyntaxNode,
3952 unsafe impl TransparentNewType for TypeParam {
3953 type Repr = rowan::SyntaxNode;
3956 impl AstNode for TypeParam {
3957 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3958 match syntax.kind() {
3959 TYPE_PARAM => Some(TypeParam::from_repr(syntax.into_repr())),
3963 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3966 impl ToOwned for TypeParam {
3967 type Owned = TreeArc<TypeParam>;
3968 fn to_owned(&self) -> TreeArc<TypeParam> { TreeArc::cast(self.syntax.to_owned()) }
3972 impl ast::NameOwner for TypeParam {}
3973 impl ast::AttrsOwner for TypeParam {}
3974 impl ast::TypeBoundsOwner for TypeParam {}
3978 #[derive(Debug, PartialEq, Eq, Hash)]
3979 #[repr(transparent)]
3980 pub struct TypeParamList {
3981 pub(crate) syntax: SyntaxNode,
3983 unsafe impl TransparentNewType for TypeParamList {
3984 type Repr = rowan::SyntaxNode;
3987 impl AstNode for TypeParamList {
3988 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3989 match syntax.kind() {
3990 TYPE_PARAM_LIST => Some(TypeParamList::from_repr(syntax.into_repr())),
3994 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3997 impl ToOwned for TypeParamList {
3998 type Owned = TreeArc<TypeParamList>;
3999 fn to_owned(&self) -> TreeArc<TypeParamList> { TreeArc::cast(self.syntax.to_owned()) }
4003 impl TypeParamList {
4004 pub fn type_params(&self) -> impl Iterator<Item = &TypeParam> {
4005 super::children(self)
4008 pub fn lifetime_params(&self) -> impl Iterator<Item = &LifetimeParam> {
4009 super::children(self)
4014 #[derive(Debug, PartialEq, Eq, Hash)]
4015 #[repr(transparent)]
4016 pub struct TypeRef {
4017 pub(crate) syntax: SyntaxNode,
4019 unsafe impl TransparentNewType for TypeRef {
4020 type Repr = rowan::SyntaxNode;
4023 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4024 pub enum TypeRefKind<'a> {
4025 ParenType(&'a ParenType),
4026 TupleType(&'a TupleType),
4027 NeverType(&'a NeverType),
4028 PathType(&'a PathType),
4029 PointerType(&'a PointerType),
4030 ArrayType(&'a ArrayType),
4031 SliceType(&'a SliceType),
4032 ReferenceType(&'a ReferenceType),
4033 PlaceholderType(&'a PlaceholderType),
4034 FnPointerType(&'a FnPointerType),
4035 ForType(&'a ForType),
4036 ImplTraitType(&'a ImplTraitType),
4037 DynTraitType(&'a DynTraitType),
4039 impl<'a> From<&'a ParenType> for &'a TypeRef {
4040 fn from(n: &'a ParenType) -> &'a TypeRef {
4041 TypeRef::cast(&n.syntax).unwrap()
4044 impl<'a> From<&'a TupleType> for &'a TypeRef {
4045 fn from(n: &'a TupleType) -> &'a TypeRef {
4046 TypeRef::cast(&n.syntax).unwrap()
4049 impl<'a> From<&'a NeverType> for &'a TypeRef {
4050 fn from(n: &'a NeverType) -> &'a TypeRef {
4051 TypeRef::cast(&n.syntax).unwrap()
4054 impl<'a> From<&'a PathType> for &'a TypeRef {
4055 fn from(n: &'a PathType) -> &'a TypeRef {
4056 TypeRef::cast(&n.syntax).unwrap()
4059 impl<'a> From<&'a PointerType> for &'a TypeRef {
4060 fn from(n: &'a PointerType) -> &'a TypeRef {
4061 TypeRef::cast(&n.syntax).unwrap()
4064 impl<'a> From<&'a ArrayType> for &'a TypeRef {
4065 fn from(n: &'a ArrayType) -> &'a TypeRef {
4066 TypeRef::cast(&n.syntax).unwrap()
4069 impl<'a> From<&'a SliceType> for &'a TypeRef {
4070 fn from(n: &'a SliceType) -> &'a TypeRef {
4071 TypeRef::cast(&n.syntax).unwrap()
4074 impl<'a> From<&'a ReferenceType> for &'a TypeRef {
4075 fn from(n: &'a ReferenceType) -> &'a TypeRef {
4076 TypeRef::cast(&n.syntax).unwrap()
4079 impl<'a> From<&'a PlaceholderType> for &'a TypeRef {
4080 fn from(n: &'a PlaceholderType) -> &'a TypeRef {
4081 TypeRef::cast(&n.syntax).unwrap()
4084 impl<'a> From<&'a FnPointerType> for &'a TypeRef {
4085 fn from(n: &'a FnPointerType) -> &'a TypeRef {
4086 TypeRef::cast(&n.syntax).unwrap()
4089 impl<'a> From<&'a ForType> for &'a TypeRef {
4090 fn from(n: &'a ForType) -> &'a TypeRef {
4091 TypeRef::cast(&n.syntax).unwrap()
4094 impl<'a> From<&'a ImplTraitType> for &'a TypeRef {
4095 fn from(n: &'a ImplTraitType) -> &'a TypeRef {
4096 TypeRef::cast(&n.syntax).unwrap()
4099 impl<'a> From<&'a DynTraitType> for &'a TypeRef {
4100 fn from(n: &'a DynTraitType) -> &'a TypeRef {
4101 TypeRef::cast(&n.syntax).unwrap()
4106 impl AstNode for TypeRef {
4107 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4108 match syntax.kind() {
4121 | DYN_TRAIT_TYPE => Some(TypeRef::from_repr(syntax.into_repr())),
4125 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4128 impl ToOwned for TypeRef {
4129 type Owned = TreeArc<TypeRef>;
4130 fn to_owned(&self) -> TreeArc<TypeRef> { TreeArc::cast(self.syntax.to_owned()) }
4134 pub fn kind(&self) -> TypeRefKind {
4135 match self.syntax.kind() {
4136 PAREN_TYPE => TypeRefKind::ParenType(ParenType::cast(&self.syntax).unwrap()),
4137 TUPLE_TYPE => TypeRefKind::TupleType(TupleType::cast(&self.syntax).unwrap()),
4138 NEVER_TYPE => TypeRefKind::NeverType(NeverType::cast(&self.syntax).unwrap()),
4139 PATH_TYPE => TypeRefKind::PathType(PathType::cast(&self.syntax).unwrap()),
4140 POINTER_TYPE => TypeRefKind::PointerType(PointerType::cast(&self.syntax).unwrap()),
4141 ARRAY_TYPE => TypeRefKind::ArrayType(ArrayType::cast(&self.syntax).unwrap()),
4142 SLICE_TYPE => TypeRefKind::SliceType(SliceType::cast(&self.syntax).unwrap()),
4143 REFERENCE_TYPE => TypeRefKind::ReferenceType(ReferenceType::cast(&self.syntax).unwrap()),
4144 PLACEHOLDER_TYPE => TypeRefKind::PlaceholderType(PlaceholderType::cast(&self.syntax).unwrap()),
4145 FN_POINTER_TYPE => TypeRefKind::FnPointerType(FnPointerType::cast(&self.syntax).unwrap()),
4146 FOR_TYPE => TypeRefKind::ForType(ForType::cast(&self.syntax).unwrap()),
4147 IMPL_TRAIT_TYPE => TypeRefKind::ImplTraitType(ImplTraitType::cast(&self.syntax).unwrap()),
4148 DYN_TRAIT_TYPE => TypeRefKind::DynTraitType(DynTraitType::cast(&self.syntax).unwrap()),
4149 _ => unreachable!(),
4157 #[derive(Debug, PartialEq, Eq, Hash)]
4158 #[repr(transparent)]
4159 pub struct UseItem {
4160 pub(crate) syntax: SyntaxNode,
4162 unsafe impl TransparentNewType for UseItem {
4163 type Repr = rowan::SyntaxNode;
4166 impl AstNode for UseItem {
4167 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4168 match syntax.kind() {
4169 USE_ITEM => Some(UseItem::from_repr(syntax.into_repr())),
4173 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4176 impl ToOwned for UseItem {
4177 type Owned = TreeArc<UseItem>;
4178 fn to_owned(&self) -> TreeArc<UseItem> { TreeArc::cast(self.syntax.to_owned()) }
4182 impl ast::AttrsOwner for UseItem {}
4184 pub fn use_tree(&self) -> Option<&UseTree> {
4185 super::child_opt(self)
4190 #[derive(Debug, PartialEq, Eq, Hash)]
4191 #[repr(transparent)]
4192 pub struct UseTree {
4193 pub(crate) syntax: SyntaxNode,
4195 unsafe impl TransparentNewType for UseTree {
4196 type Repr = rowan::SyntaxNode;
4199 impl AstNode for UseTree {
4200 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4201 match syntax.kind() {
4202 USE_TREE => Some(UseTree::from_repr(syntax.into_repr())),
4206 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4209 impl ToOwned for UseTree {
4210 type Owned = TreeArc<UseTree>;
4211 fn to_owned(&self) -> TreeArc<UseTree> { TreeArc::cast(self.syntax.to_owned()) }
4216 pub fn path(&self) -> Option<&Path> {
4217 super::child_opt(self)
4220 pub fn use_tree_list(&self) -> Option<&UseTreeList> {
4221 super::child_opt(self)
4224 pub fn alias(&self) -> Option<&Alias> {
4225 super::child_opt(self)
4230 #[derive(Debug, PartialEq, Eq, Hash)]
4231 #[repr(transparent)]
4232 pub struct UseTreeList {
4233 pub(crate) syntax: SyntaxNode,
4235 unsafe impl TransparentNewType for UseTreeList {
4236 type Repr = rowan::SyntaxNode;
4239 impl AstNode for UseTreeList {
4240 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4241 match syntax.kind() {
4242 USE_TREE_LIST => Some(UseTreeList::from_repr(syntax.into_repr())),
4246 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4249 impl ToOwned for UseTreeList {
4250 type Owned = TreeArc<UseTreeList>;
4251 fn to_owned(&self) -> TreeArc<UseTreeList> { TreeArc::cast(self.syntax.to_owned()) }
4256 pub fn use_trees(&self) -> impl Iterator<Item = &UseTree> {
4257 super::children(self)
4262 #[derive(Debug, PartialEq, Eq, Hash)]
4263 #[repr(transparent)]
4264 pub struct Visibility {
4265 pub(crate) syntax: SyntaxNode,
4267 unsafe impl TransparentNewType for Visibility {
4268 type Repr = rowan::SyntaxNode;
4271 impl AstNode for Visibility {
4272 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4273 match syntax.kind() {
4274 VISIBILITY => Some(Visibility::from_repr(syntax.into_repr())),
4278 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4281 impl ToOwned for Visibility {
4282 type Owned = TreeArc<Visibility>;
4283 fn to_owned(&self) -> TreeArc<Visibility> { TreeArc::cast(self.syntax.to_owned()) }
4290 #[derive(Debug, PartialEq, Eq, Hash)]
4291 #[repr(transparent)]
4292 pub struct WhereClause {
4293 pub(crate) syntax: SyntaxNode,
4295 unsafe impl TransparentNewType for WhereClause {
4296 type Repr = rowan::SyntaxNode;
4299 impl AstNode for WhereClause {
4300 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4301 match syntax.kind() {
4302 WHERE_CLAUSE => Some(WhereClause::from_repr(syntax.into_repr())),
4306 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4309 impl ToOwned for WhereClause {
4310 type Owned = TreeArc<WhereClause>;
4311 fn to_owned(&self) -> TreeArc<WhereClause> { TreeArc::cast(self.syntax.to_owned()) }
4316 pub fn predicates(&self) -> impl Iterator<Item = &WherePred> {
4317 super::children(self)
4322 #[derive(Debug, PartialEq, Eq, Hash)]
4323 #[repr(transparent)]
4324 pub struct WherePred {
4325 pub(crate) syntax: SyntaxNode,
4327 unsafe impl TransparentNewType for WherePred {
4328 type Repr = rowan::SyntaxNode;
4331 impl AstNode for WherePred {
4332 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4333 match syntax.kind() {
4334 WHERE_PRED => Some(WherePred::from_repr(syntax.into_repr())),
4338 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4341 impl ToOwned for WherePred {
4342 type Owned = TreeArc<WherePred>;
4343 fn to_owned(&self) -> TreeArc<WherePred> { TreeArc::cast(self.syntax.to_owned()) }
4347 impl ast::TypeBoundsOwner for WherePred {}
4349 pub fn type_ref(&self) -> Option<&TypeRef> {
4350 super::child_opt(self)
4355 #[derive(Debug, PartialEq, Eq, Hash)]
4356 #[repr(transparent)]
4357 pub struct WhileExpr {
4358 pub(crate) syntax: SyntaxNode,
4360 unsafe impl TransparentNewType for WhileExpr {
4361 type Repr = rowan::SyntaxNode;
4364 impl AstNode for WhileExpr {
4365 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4366 match syntax.kind() {
4367 WHILE_EXPR => Some(WhileExpr::from_repr(syntax.into_repr())),
4371 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4374 impl ToOwned for WhileExpr {
4375 type Owned = TreeArc<WhileExpr>;
4376 fn to_owned(&self) -> TreeArc<WhileExpr> { TreeArc::cast(self.syntax.to_owned()) }
4380 impl ast::LoopBodyOwner for WhileExpr {}
4382 pub fn condition(&self) -> Option<&Condition> {
4383 super::child_opt(self)