1 // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run
2 // Do not edit manually
4 //! This module contains auto-generated Rust AST. Like `SyntaxNode`s, AST nodes
5 //! are generic over ownership: `X<'a>` things are `Copy` references, `XNode`
6 //! are Arc-based. You can switch between the two variants using `.owned` and
7 //! `.borrowed` functions. Most of the code works with borowed mode, and only
8 //! this mode has all AST accessors.
10 #![cfg_attr(rustfmt, rustfmt_skip)]
12 use rowan::TransparentNewType;
15 SyntaxNode, SyntaxKind::*,
16 syntax_node::{TreeArc},
21 #[derive(Debug, PartialEq, Eq, Hash)]
24 pub(crate) syntax: SyntaxNode,
26 unsafe impl TransparentNewType for Alias {
27 type Repr = rowan::SyntaxNode;
30 impl AstNode for Alias {
31 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
33 ALIAS => Some(Alias::from_repr(syntax.into_repr())),
37 fn syntax(&self) -> &SyntaxNode { &self.syntax }
40 impl ToOwned for Alias {
41 type Owned = TreeArc<Alias>;
42 fn to_owned(&self) -> TreeArc<Alias> { TreeArc::cast(self.syntax.to_owned()) }
46 impl ast::NameOwner for Alias {}
50 #[derive(Debug, PartialEq, Eq, Hash)]
53 pub(crate) syntax: SyntaxNode,
55 unsafe impl TransparentNewType for ArgList {
56 type Repr = rowan::SyntaxNode;
59 impl AstNode for ArgList {
60 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
62 ARG_LIST => Some(ArgList::from_repr(syntax.into_repr())),
66 fn syntax(&self) -> &SyntaxNode { &self.syntax }
69 impl ToOwned for ArgList {
70 type Owned = TreeArc<ArgList>;
71 fn to_owned(&self) -> TreeArc<ArgList> { TreeArc::cast(self.syntax.to_owned()) }
76 pub fn args(&self) -> impl Iterator<Item = &Expr> {
82 #[derive(Debug, PartialEq, Eq, Hash)]
84 pub struct ArrayExpr {
85 pub(crate) syntax: SyntaxNode,
87 unsafe impl TransparentNewType for ArrayExpr {
88 type Repr = rowan::SyntaxNode;
91 impl AstNode for ArrayExpr {
92 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
94 ARRAY_EXPR => Some(ArrayExpr::from_repr(syntax.into_repr())),
98 fn syntax(&self) -> &SyntaxNode { &self.syntax }
101 impl ToOwned for ArrayExpr {
102 type Owned = TreeArc<ArrayExpr>;
103 fn to_owned(&self) -> TreeArc<ArrayExpr> { TreeArc::cast(self.syntax.to_owned()) }
108 pub fn exprs(&self) -> impl Iterator<Item = &Expr> {
109 super::children(self)
114 #[derive(Debug, PartialEq, Eq, Hash)]
116 pub struct ArrayType {
117 pub(crate) syntax: SyntaxNode,
119 unsafe impl TransparentNewType for ArrayType {
120 type Repr = rowan::SyntaxNode;
123 impl AstNode for ArrayType {
124 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
125 match syntax.kind() {
126 ARRAY_TYPE => Some(ArrayType::from_repr(syntax.into_repr())),
130 fn syntax(&self) -> &SyntaxNode { &self.syntax }
133 impl ToOwned for ArrayType {
134 type Owned = TreeArc<ArrayType>;
135 fn to_owned(&self) -> TreeArc<ArrayType> { TreeArc::cast(self.syntax.to_owned()) }
140 pub fn type_ref(&self) -> Option<&TypeRef> {
141 super::child_opt(self)
144 pub fn expr(&self) -> Option<&Expr> {
145 super::child_opt(self)
150 #[derive(Debug, PartialEq, Eq, Hash)]
152 pub struct AssocTypeArg {
153 pub(crate) syntax: SyntaxNode,
155 unsafe impl TransparentNewType for AssocTypeArg {
156 type Repr = rowan::SyntaxNode;
159 impl AstNode for AssocTypeArg {
160 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
161 match syntax.kind() {
162 ASSOC_TYPE_ARG => Some(AssocTypeArg::from_repr(syntax.into_repr())),
166 fn syntax(&self) -> &SyntaxNode { &self.syntax }
169 impl ToOwned for AssocTypeArg {
170 type Owned = TreeArc<AssocTypeArg>;
171 fn to_owned(&self) -> TreeArc<AssocTypeArg> { TreeArc::cast(self.syntax.to_owned()) }
176 pub fn name_ref(&self) -> Option<&NameRef> {
177 super::child_opt(self)
180 pub fn type_ref(&self) -> Option<&TypeRef> {
181 super::child_opt(self)
186 #[derive(Debug, PartialEq, Eq, Hash)]
189 pub(crate) syntax: SyntaxNode,
191 unsafe impl TransparentNewType for Attr {
192 type Repr = rowan::SyntaxNode;
195 impl AstNode for Attr {
196 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
197 match syntax.kind() {
198 ATTR => Some(Attr::from_repr(syntax.into_repr())),
202 fn syntax(&self) -> &SyntaxNode { &self.syntax }
205 impl ToOwned for Attr {
206 type Owned = TreeArc<Attr>;
207 fn to_owned(&self) -> TreeArc<Attr> { TreeArc::cast(self.syntax.to_owned()) }
212 pub fn value(&self) -> Option<&TokenTree> {
213 super::child_opt(self)
218 #[derive(Debug, PartialEq, Eq, Hash)]
221 pub(crate) syntax: SyntaxNode,
223 unsafe impl TransparentNewType for BinExpr {
224 type Repr = rowan::SyntaxNode;
227 impl AstNode for BinExpr {
228 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
229 match syntax.kind() {
230 BIN_EXPR => Some(BinExpr::from_repr(syntax.into_repr())),
234 fn syntax(&self) -> &SyntaxNode { &self.syntax }
237 impl ToOwned for BinExpr {
238 type Owned = TreeArc<BinExpr>;
239 fn to_owned(&self) -> TreeArc<BinExpr> { TreeArc::cast(self.syntax.to_owned()) }
246 #[derive(Debug, PartialEq, Eq, Hash)]
249 pub(crate) syntax: SyntaxNode,
251 unsafe impl TransparentNewType for BindPat {
252 type Repr = rowan::SyntaxNode;
255 impl AstNode for BindPat {
256 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
257 match syntax.kind() {
258 BIND_PAT => Some(BindPat::from_repr(syntax.into_repr())),
262 fn syntax(&self) -> &SyntaxNode { &self.syntax }
265 impl ToOwned for BindPat {
266 type Owned = TreeArc<BindPat>;
267 fn to_owned(&self) -> TreeArc<BindPat> { TreeArc::cast(self.syntax.to_owned()) }
271 impl ast::NameOwner for BindPat {}
273 pub fn pat(&self) -> Option<&Pat> {
274 super::child_opt(self)
279 #[derive(Debug, PartialEq, Eq, Hash)]
282 pub(crate) syntax: SyntaxNode,
284 unsafe impl TransparentNewType for Block {
285 type Repr = rowan::SyntaxNode;
288 impl AstNode for Block {
289 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
290 match syntax.kind() {
291 BLOCK => Some(Block::from_repr(syntax.into_repr())),
295 fn syntax(&self) -> &SyntaxNode { &self.syntax }
298 impl ToOwned for Block {
299 type Owned = TreeArc<Block>;
300 fn to_owned(&self) -> TreeArc<Block> { TreeArc::cast(self.syntax.to_owned()) }
304 impl ast::AttrsOwner for Block {}
306 pub fn statements(&self) -> impl Iterator<Item = &Stmt> {
307 super::children(self)
310 pub fn expr(&self) -> Option<&Expr> {
311 super::child_opt(self)
316 #[derive(Debug, PartialEq, Eq, Hash)]
318 pub struct BlockExpr {
319 pub(crate) syntax: SyntaxNode,
321 unsafe impl TransparentNewType for BlockExpr {
322 type Repr = rowan::SyntaxNode;
325 impl AstNode for BlockExpr {
326 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
327 match syntax.kind() {
328 BLOCK_EXPR => Some(BlockExpr::from_repr(syntax.into_repr())),
332 fn syntax(&self) -> &SyntaxNode { &self.syntax }
335 impl ToOwned for BlockExpr {
336 type Owned = TreeArc<BlockExpr>;
337 fn to_owned(&self) -> TreeArc<BlockExpr> { TreeArc::cast(self.syntax.to_owned()) }
342 pub fn block(&self) -> Option<&Block> {
343 super::child_opt(self)
348 #[derive(Debug, PartialEq, Eq, Hash)]
350 pub struct BreakExpr {
351 pub(crate) syntax: SyntaxNode,
353 unsafe impl TransparentNewType for BreakExpr {
354 type Repr = rowan::SyntaxNode;
357 impl AstNode for BreakExpr {
358 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
359 match syntax.kind() {
360 BREAK_EXPR => Some(BreakExpr::from_repr(syntax.into_repr())),
364 fn syntax(&self) -> &SyntaxNode { &self.syntax }
367 impl ToOwned for BreakExpr {
368 type Owned = TreeArc<BreakExpr>;
369 fn to_owned(&self) -> TreeArc<BreakExpr> { TreeArc::cast(self.syntax.to_owned()) }
374 pub fn expr(&self) -> Option<&Expr> {
375 super::child_opt(self)
380 #[derive(Debug, PartialEq, Eq, Hash)]
382 pub struct CallExpr {
383 pub(crate) syntax: SyntaxNode,
385 unsafe impl TransparentNewType for CallExpr {
386 type Repr = rowan::SyntaxNode;
389 impl AstNode for CallExpr {
390 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
391 match syntax.kind() {
392 CALL_EXPR => Some(CallExpr::from_repr(syntax.into_repr())),
396 fn syntax(&self) -> &SyntaxNode { &self.syntax }
399 impl ToOwned for CallExpr {
400 type Owned = TreeArc<CallExpr>;
401 fn to_owned(&self) -> TreeArc<CallExpr> { TreeArc::cast(self.syntax.to_owned()) }
405 impl ast::ArgListOwner for CallExpr {}
407 pub fn expr(&self) -> Option<&Expr> {
408 super::child_opt(self)
413 #[derive(Debug, PartialEq, Eq, Hash)]
415 pub struct CastExpr {
416 pub(crate) syntax: SyntaxNode,
418 unsafe impl TransparentNewType for CastExpr {
419 type Repr = rowan::SyntaxNode;
422 impl AstNode for CastExpr {
423 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
424 match syntax.kind() {
425 CAST_EXPR => Some(CastExpr::from_repr(syntax.into_repr())),
429 fn syntax(&self) -> &SyntaxNode { &self.syntax }
432 impl ToOwned for CastExpr {
433 type Owned = TreeArc<CastExpr>;
434 fn to_owned(&self) -> TreeArc<CastExpr> { TreeArc::cast(self.syntax.to_owned()) }
439 pub fn expr(&self) -> Option<&Expr> {
440 super::child_opt(self)
443 pub fn type_ref(&self) -> Option<&TypeRef> {
444 super::child_opt(self)
449 #[derive(Debug, PartialEq, Eq, Hash)]
451 pub struct Condition {
452 pub(crate) syntax: SyntaxNode,
454 unsafe impl TransparentNewType for Condition {
455 type Repr = rowan::SyntaxNode;
458 impl AstNode for Condition {
459 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
460 match syntax.kind() {
461 CONDITION => Some(Condition::from_repr(syntax.into_repr())),
465 fn syntax(&self) -> &SyntaxNode { &self.syntax }
468 impl ToOwned for Condition {
469 type Owned = TreeArc<Condition>;
470 fn to_owned(&self) -> TreeArc<Condition> { TreeArc::cast(self.syntax.to_owned()) }
475 pub fn pat(&self) -> Option<&Pat> {
476 super::child_opt(self)
479 pub fn expr(&self) -> Option<&Expr> {
480 super::child_opt(self)
485 #[derive(Debug, PartialEq, Eq, Hash)]
487 pub struct ConstDef {
488 pub(crate) syntax: SyntaxNode,
490 unsafe impl TransparentNewType for ConstDef {
491 type Repr = rowan::SyntaxNode;
494 impl AstNode for ConstDef {
495 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
496 match syntax.kind() {
497 CONST_DEF => Some(ConstDef::from_repr(syntax.into_repr())),
501 fn syntax(&self) -> &SyntaxNode { &self.syntax }
504 impl ToOwned for ConstDef {
505 type Owned = TreeArc<ConstDef>;
506 fn to_owned(&self) -> TreeArc<ConstDef> { TreeArc::cast(self.syntax.to_owned()) }
510 impl ast::VisibilityOwner for ConstDef {}
511 impl ast::NameOwner for ConstDef {}
512 impl ast::TypeParamsOwner for ConstDef {}
513 impl ast::AttrsOwner for ConstDef {}
514 impl ast::DocCommentsOwner for ConstDef {}
515 impl ast::TypeAscriptionOwner for ConstDef {}
517 pub fn body(&self) -> Option<&Expr> {
518 super::child_opt(self)
523 #[derive(Debug, PartialEq, Eq, Hash)]
525 pub struct ContinueExpr {
526 pub(crate) syntax: SyntaxNode,
528 unsafe impl TransparentNewType for ContinueExpr {
529 type Repr = rowan::SyntaxNode;
532 impl AstNode for ContinueExpr {
533 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
534 match syntax.kind() {
535 CONTINUE_EXPR => Some(ContinueExpr::from_repr(syntax.into_repr())),
539 fn syntax(&self) -> &SyntaxNode { &self.syntax }
542 impl ToOwned for ContinueExpr {
543 type Owned = TreeArc<ContinueExpr>;
544 fn to_owned(&self) -> TreeArc<ContinueExpr> { TreeArc::cast(self.syntax.to_owned()) }
551 #[derive(Debug, PartialEq, Eq, Hash)]
553 pub struct DynTraitType {
554 pub(crate) syntax: SyntaxNode,
556 unsafe impl TransparentNewType for DynTraitType {
557 type Repr = rowan::SyntaxNode;
560 impl AstNode for DynTraitType {
561 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
562 match syntax.kind() {
563 DYN_TRAIT_TYPE => Some(DynTraitType::from_repr(syntax.into_repr())),
567 fn syntax(&self) -> &SyntaxNode { &self.syntax }
570 impl ToOwned for DynTraitType {
571 type Owned = TreeArc<DynTraitType>;
572 fn to_owned(&self) -> TreeArc<DynTraitType> { TreeArc::cast(self.syntax.to_owned()) }
576 impl ast::TypeBoundsOwner for DynTraitType {}
580 #[derive(Debug, PartialEq, Eq, Hash)]
583 pub(crate) syntax: SyntaxNode,
585 unsafe impl TransparentNewType for EnumDef {
586 type Repr = rowan::SyntaxNode;
589 impl AstNode for EnumDef {
590 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
591 match syntax.kind() {
592 ENUM_DEF => Some(EnumDef::from_repr(syntax.into_repr())),
596 fn syntax(&self) -> &SyntaxNode { &self.syntax }
599 impl ToOwned for EnumDef {
600 type Owned = TreeArc<EnumDef>;
601 fn to_owned(&self) -> TreeArc<EnumDef> { TreeArc::cast(self.syntax.to_owned()) }
605 impl ast::VisibilityOwner for EnumDef {}
606 impl ast::NameOwner for EnumDef {}
607 impl ast::TypeParamsOwner for EnumDef {}
608 impl ast::AttrsOwner for EnumDef {}
609 impl ast::DocCommentsOwner for EnumDef {}
611 pub fn variant_list(&self) -> Option<&EnumVariantList> {
612 super::child_opt(self)
617 #[derive(Debug, PartialEq, Eq, Hash)]
619 pub struct EnumVariant {
620 pub(crate) syntax: SyntaxNode,
622 unsafe impl TransparentNewType for EnumVariant {
623 type Repr = rowan::SyntaxNode;
626 impl AstNode for EnumVariant {
627 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
628 match syntax.kind() {
629 ENUM_VARIANT => Some(EnumVariant::from_repr(syntax.into_repr())),
633 fn syntax(&self) -> &SyntaxNode { &self.syntax }
636 impl ToOwned for EnumVariant {
637 type Owned = TreeArc<EnumVariant>;
638 fn to_owned(&self) -> TreeArc<EnumVariant> { TreeArc::cast(self.syntax.to_owned()) }
642 impl ast::NameOwner for EnumVariant {}
643 impl ast::DocCommentsOwner for EnumVariant {}
644 impl ast::AttrsOwner for EnumVariant {}
646 pub fn expr(&self) -> Option<&Expr> {
647 super::child_opt(self)
652 #[derive(Debug, PartialEq, Eq, Hash)]
654 pub struct EnumVariantList {
655 pub(crate) syntax: SyntaxNode,
657 unsafe impl TransparentNewType for EnumVariantList {
658 type Repr = rowan::SyntaxNode;
661 impl AstNode for EnumVariantList {
662 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
663 match syntax.kind() {
664 ENUM_VARIANT_LIST => Some(EnumVariantList::from_repr(syntax.into_repr())),
668 fn syntax(&self) -> &SyntaxNode { &self.syntax }
671 impl ToOwned for EnumVariantList {
672 type Owned = TreeArc<EnumVariantList>;
673 fn to_owned(&self) -> TreeArc<EnumVariantList> { TreeArc::cast(self.syntax.to_owned()) }
677 impl EnumVariantList {
678 pub fn variants(&self) -> impl Iterator<Item = &EnumVariant> {
679 super::children(self)
684 #[derive(Debug, PartialEq, Eq, Hash)]
687 pub(crate) syntax: SyntaxNode,
689 unsafe impl TransparentNewType for Expr {
690 type Repr = rowan::SyntaxNode;
693 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
694 pub enum ExprKind<'a> {
695 TupleExpr(&'a TupleExpr),
696 ArrayExpr(&'a ArrayExpr),
697 ParenExpr(&'a ParenExpr),
698 PathExpr(&'a PathExpr),
699 LambdaExpr(&'a LambdaExpr),
701 LoopExpr(&'a LoopExpr),
702 ForExpr(&'a ForExpr),
703 WhileExpr(&'a WhileExpr),
704 ContinueExpr(&'a ContinueExpr),
705 BreakExpr(&'a BreakExpr),
707 BlockExpr(&'a BlockExpr),
708 ReturnExpr(&'a ReturnExpr),
709 MatchExpr(&'a MatchExpr),
710 StructLit(&'a StructLit),
711 CallExpr(&'a CallExpr),
712 IndexExpr(&'a IndexExpr),
713 MethodCallExpr(&'a MethodCallExpr),
714 FieldExpr(&'a FieldExpr),
715 TryExpr(&'a TryExpr),
716 CastExpr(&'a CastExpr),
717 RefExpr(&'a RefExpr),
718 PrefixExpr(&'a PrefixExpr),
719 RangeExpr(&'a RangeExpr),
720 BinExpr(&'a BinExpr),
721 Literal(&'a Literal),
722 MacroCall(&'a MacroCall),
724 impl<'a> From<&'a TupleExpr> for &'a Expr {
725 fn from(n: &'a TupleExpr) -> &'a Expr {
726 Expr::cast(&n.syntax).unwrap()
729 impl<'a> From<&'a ArrayExpr> for &'a Expr {
730 fn from(n: &'a ArrayExpr) -> &'a Expr {
731 Expr::cast(&n.syntax).unwrap()
734 impl<'a> From<&'a ParenExpr> for &'a Expr {
735 fn from(n: &'a ParenExpr) -> &'a Expr {
736 Expr::cast(&n.syntax).unwrap()
739 impl<'a> From<&'a PathExpr> for &'a Expr {
740 fn from(n: &'a PathExpr) -> &'a Expr {
741 Expr::cast(&n.syntax).unwrap()
744 impl<'a> From<&'a LambdaExpr> for &'a Expr {
745 fn from(n: &'a LambdaExpr) -> &'a Expr {
746 Expr::cast(&n.syntax).unwrap()
749 impl<'a> From<&'a IfExpr> for &'a Expr {
750 fn from(n: &'a IfExpr) -> &'a Expr {
751 Expr::cast(&n.syntax).unwrap()
754 impl<'a> From<&'a LoopExpr> for &'a Expr {
755 fn from(n: &'a LoopExpr) -> &'a Expr {
756 Expr::cast(&n.syntax).unwrap()
759 impl<'a> From<&'a ForExpr> for &'a Expr {
760 fn from(n: &'a ForExpr) -> &'a Expr {
761 Expr::cast(&n.syntax).unwrap()
764 impl<'a> From<&'a WhileExpr> for &'a Expr {
765 fn from(n: &'a WhileExpr) -> &'a Expr {
766 Expr::cast(&n.syntax).unwrap()
769 impl<'a> From<&'a ContinueExpr> for &'a Expr {
770 fn from(n: &'a ContinueExpr) -> &'a Expr {
771 Expr::cast(&n.syntax).unwrap()
774 impl<'a> From<&'a BreakExpr> for &'a Expr {
775 fn from(n: &'a BreakExpr) -> &'a Expr {
776 Expr::cast(&n.syntax).unwrap()
779 impl<'a> From<&'a Label> for &'a Expr {
780 fn from(n: &'a Label) -> &'a Expr {
781 Expr::cast(&n.syntax).unwrap()
784 impl<'a> From<&'a BlockExpr> for &'a Expr {
785 fn from(n: &'a BlockExpr) -> &'a Expr {
786 Expr::cast(&n.syntax).unwrap()
789 impl<'a> From<&'a ReturnExpr> for &'a Expr {
790 fn from(n: &'a ReturnExpr) -> &'a Expr {
791 Expr::cast(&n.syntax).unwrap()
794 impl<'a> From<&'a MatchExpr> for &'a Expr {
795 fn from(n: &'a MatchExpr) -> &'a Expr {
796 Expr::cast(&n.syntax).unwrap()
799 impl<'a> From<&'a StructLit> for &'a Expr {
800 fn from(n: &'a StructLit) -> &'a Expr {
801 Expr::cast(&n.syntax).unwrap()
804 impl<'a> From<&'a CallExpr> for &'a Expr {
805 fn from(n: &'a CallExpr) -> &'a Expr {
806 Expr::cast(&n.syntax).unwrap()
809 impl<'a> From<&'a IndexExpr> for &'a Expr {
810 fn from(n: &'a IndexExpr) -> &'a Expr {
811 Expr::cast(&n.syntax).unwrap()
814 impl<'a> From<&'a MethodCallExpr> for &'a Expr {
815 fn from(n: &'a MethodCallExpr) -> &'a Expr {
816 Expr::cast(&n.syntax).unwrap()
819 impl<'a> From<&'a FieldExpr> for &'a Expr {
820 fn from(n: &'a FieldExpr) -> &'a Expr {
821 Expr::cast(&n.syntax).unwrap()
824 impl<'a> From<&'a TryExpr> for &'a Expr {
825 fn from(n: &'a TryExpr) -> &'a Expr {
826 Expr::cast(&n.syntax).unwrap()
829 impl<'a> From<&'a CastExpr> for &'a Expr {
830 fn from(n: &'a CastExpr) -> &'a Expr {
831 Expr::cast(&n.syntax).unwrap()
834 impl<'a> From<&'a RefExpr> for &'a Expr {
835 fn from(n: &'a RefExpr) -> &'a Expr {
836 Expr::cast(&n.syntax).unwrap()
839 impl<'a> From<&'a PrefixExpr> for &'a Expr {
840 fn from(n: &'a PrefixExpr) -> &'a Expr {
841 Expr::cast(&n.syntax).unwrap()
844 impl<'a> From<&'a RangeExpr> for &'a Expr {
845 fn from(n: &'a RangeExpr) -> &'a Expr {
846 Expr::cast(&n.syntax).unwrap()
849 impl<'a> From<&'a BinExpr> for &'a Expr {
850 fn from(n: &'a BinExpr) -> &'a Expr {
851 Expr::cast(&n.syntax).unwrap()
854 impl<'a> From<&'a Literal> for &'a Expr {
855 fn from(n: &'a Literal) -> &'a Expr {
856 Expr::cast(&n.syntax).unwrap()
859 impl<'a> From<&'a MacroCall> for &'a Expr {
860 fn from(n: &'a MacroCall) -> &'a Expr {
861 Expr::cast(&n.syntax).unwrap()
866 impl AstNode for Expr {
867 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
868 match syntax.kind() {
896 | MACRO_CALL => Some(Expr::from_repr(syntax.into_repr())),
900 fn syntax(&self) -> &SyntaxNode { &self.syntax }
903 impl ToOwned for Expr {
904 type Owned = TreeArc<Expr>;
905 fn to_owned(&self) -> TreeArc<Expr> { TreeArc::cast(self.syntax.to_owned()) }
909 pub fn kind(&self) -> ExprKind {
910 match self.syntax.kind() {
911 TUPLE_EXPR => ExprKind::TupleExpr(TupleExpr::cast(&self.syntax).unwrap()),
912 ARRAY_EXPR => ExprKind::ArrayExpr(ArrayExpr::cast(&self.syntax).unwrap()),
913 PAREN_EXPR => ExprKind::ParenExpr(ParenExpr::cast(&self.syntax).unwrap()),
914 PATH_EXPR => ExprKind::PathExpr(PathExpr::cast(&self.syntax).unwrap()),
915 LAMBDA_EXPR => ExprKind::LambdaExpr(LambdaExpr::cast(&self.syntax).unwrap()),
916 IF_EXPR => ExprKind::IfExpr(IfExpr::cast(&self.syntax).unwrap()),
917 LOOP_EXPR => ExprKind::LoopExpr(LoopExpr::cast(&self.syntax).unwrap()),
918 FOR_EXPR => ExprKind::ForExpr(ForExpr::cast(&self.syntax).unwrap()),
919 WHILE_EXPR => ExprKind::WhileExpr(WhileExpr::cast(&self.syntax).unwrap()),
920 CONTINUE_EXPR => ExprKind::ContinueExpr(ContinueExpr::cast(&self.syntax).unwrap()),
921 BREAK_EXPR => ExprKind::BreakExpr(BreakExpr::cast(&self.syntax).unwrap()),
922 LABEL => ExprKind::Label(Label::cast(&self.syntax).unwrap()),
923 BLOCK_EXPR => ExprKind::BlockExpr(BlockExpr::cast(&self.syntax).unwrap()),
924 RETURN_EXPR => ExprKind::ReturnExpr(ReturnExpr::cast(&self.syntax).unwrap()),
925 MATCH_EXPR => ExprKind::MatchExpr(MatchExpr::cast(&self.syntax).unwrap()),
926 STRUCT_LIT => ExprKind::StructLit(StructLit::cast(&self.syntax).unwrap()),
927 CALL_EXPR => ExprKind::CallExpr(CallExpr::cast(&self.syntax).unwrap()),
928 INDEX_EXPR => ExprKind::IndexExpr(IndexExpr::cast(&self.syntax).unwrap()),
929 METHOD_CALL_EXPR => ExprKind::MethodCallExpr(MethodCallExpr::cast(&self.syntax).unwrap()),
930 FIELD_EXPR => ExprKind::FieldExpr(FieldExpr::cast(&self.syntax).unwrap()),
931 TRY_EXPR => ExprKind::TryExpr(TryExpr::cast(&self.syntax).unwrap()),
932 CAST_EXPR => ExprKind::CastExpr(CastExpr::cast(&self.syntax).unwrap()),
933 REF_EXPR => ExprKind::RefExpr(RefExpr::cast(&self.syntax).unwrap()),
934 PREFIX_EXPR => ExprKind::PrefixExpr(PrefixExpr::cast(&self.syntax).unwrap()),
935 RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(&self.syntax).unwrap()),
936 BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(&self.syntax).unwrap()),
937 LITERAL => ExprKind::Literal(Literal::cast(&self.syntax).unwrap()),
938 MACRO_CALL => ExprKind::MacroCall(MacroCall::cast(&self.syntax).unwrap()),
947 #[derive(Debug, PartialEq, Eq, Hash)]
949 pub struct ExprStmt {
950 pub(crate) syntax: SyntaxNode,
952 unsafe impl TransparentNewType for ExprStmt {
953 type Repr = rowan::SyntaxNode;
956 impl AstNode for ExprStmt {
957 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
958 match syntax.kind() {
959 EXPR_STMT => Some(ExprStmt::from_repr(syntax.into_repr())),
963 fn syntax(&self) -> &SyntaxNode { &self.syntax }
966 impl ToOwned for ExprStmt {
967 type Owned = TreeArc<ExprStmt>;
968 fn to_owned(&self) -> TreeArc<ExprStmt> { TreeArc::cast(self.syntax.to_owned()) }
973 pub fn expr(&self) -> Option<&Expr> {
974 super::child_opt(self)
979 #[derive(Debug, PartialEq, Eq, Hash)]
981 pub struct ExternCrateItem {
982 pub(crate) syntax: SyntaxNode,
984 unsafe impl TransparentNewType for ExternCrateItem {
985 type Repr = rowan::SyntaxNode;
988 impl AstNode for ExternCrateItem {
989 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
990 match syntax.kind() {
991 EXTERN_CRATE_ITEM => Some(ExternCrateItem::from_repr(syntax.into_repr())),
995 fn syntax(&self) -> &SyntaxNode { &self.syntax }
998 impl ToOwned for ExternCrateItem {
999 type Owned = TreeArc<ExternCrateItem>;
1000 fn to_owned(&self) -> TreeArc<ExternCrateItem> { TreeArc::cast(self.syntax.to_owned()) }
1004 impl ExternCrateItem {
1005 pub fn name_ref(&self) -> Option<&NameRef> {
1006 super::child_opt(self)
1009 pub fn alias(&self) -> Option<&Alias> {
1010 super::child_opt(self)
1015 #[derive(Debug, PartialEq, Eq, Hash)]
1016 #[repr(transparent)]
1017 pub struct FieldExpr {
1018 pub(crate) syntax: SyntaxNode,
1020 unsafe impl TransparentNewType for FieldExpr {
1021 type Repr = rowan::SyntaxNode;
1024 impl AstNode for FieldExpr {
1025 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1026 match syntax.kind() {
1027 FIELD_EXPR => Some(FieldExpr::from_repr(syntax.into_repr())),
1031 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1034 impl ToOwned for FieldExpr {
1035 type Owned = TreeArc<FieldExpr>;
1036 fn to_owned(&self) -> TreeArc<FieldExpr> { TreeArc::cast(self.syntax.to_owned()) }
1041 pub fn expr(&self) -> Option<&Expr> {
1042 super::child_opt(self)
1045 pub fn name_ref(&self) -> Option<&NameRef> {
1046 super::child_opt(self)
1051 #[derive(Debug, PartialEq, Eq, Hash)]
1052 #[repr(transparent)]
1053 pub struct FieldPat {
1054 pub(crate) syntax: SyntaxNode,
1056 unsafe impl TransparentNewType for FieldPat {
1057 type Repr = rowan::SyntaxNode;
1060 impl AstNode for FieldPat {
1061 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1062 match syntax.kind() {
1063 FIELD_PAT => Some(FieldPat::from_repr(syntax.into_repr())),
1067 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1070 impl ToOwned for FieldPat {
1071 type Owned = TreeArc<FieldPat>;
1072 fn to_owned(&self) -> TreeArc<FieldPat> { TreeArc::cast(self.syntax.to_owned()) }
1076 impl ast::NameOwner for FieldPat {}
1078 pub fn pat(&self) -> Option<&Pat> {
1079 super::child_opt(self)
1084 #[derive(Debug, PartialEq, Eq, Hash)]
1085 #[repr(transparent)]
1086 pub struct FieldPatList {
1087 pub(crate) syntax: SyntaxNode,
1089 unsafe impl TransparentNewType for FieldPatList {
1090 type Repr = rowan::SyntaxNode;
1093 impl AstNode for FieldPatList {
1094 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1095 match syntax.kind() {
1096 FIELD_PAT_LIST => Some(FieldPatList::from_repr(syntax.into_repr())),
1100 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1103 impl ToOwned for FieldPatList {
1104 type Owned = TreeArc<FieldPatList>;
1105 fn to_owned(&self) -> TreeArc<FieldPatList> { TreeArc::cast(self.syntax.to_owned()) }
1110 pub fn field_pats(&self) -> impl Iterator<Item = &FieldPat> {
1111 super::children(self)
1114 pub fn bind_pats(&self) -> impl Iterator<Item = &BindPat> {
1115 super::children(self)
1120 #[derive(Debug, PartialEq, Eq, Hash)]
1121 #[repr(transparent)]
1123 pub(crate) syntax: SyntaxNode,
1125 unsafe impl TransparentNewType for FnDef {
1126 type Repr = rowan::SyntaxNode;
1129 impl AstNode for FnDef {
1130 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1131 match syntax.kind() {
1132 FN_DEF => Some(FnDef::from_repr(syntax.into_repr())),
1136 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1139 impl ToOwned for FnDef {
1140 type Owned = TreeArc<FnDef>;
1141 fn to_owned(&self) -> TreeArc<FnDef> { TreeArc::cast(self.syntax.to_owned()) }
1145 impl ast::VisibilityOwner for FnDef {}
1146 impl ast::NameOwner for FnDef {}
1147 impl ast::TypeParamsOwner for FnDef {}
1148 impl ast::AttrsOwner for FnDef {}
1149 impl ast::DocCommentsOwner for FnDef {}
1151 pub fn param_list(&self) -> Option<&ParamList> {
1152 super::child_opt(self)
1155 pub fn body(&self) -> Option<&Block> {
1156 super::child_opt(self)
1159 pub fn ret_type(&self) -> Option<&RetType> {
1160 super::child_opt(self)
1165 #[derive(Debug, PartialEq, Eq, Hash)]
1166 #[repr(transparent)]
1167 pub struct FnPointerType {
1168 pub(crate) syntax: SyntaxNode,
1170 unsafe impl TransparentNewType for FnPointerType {
1171 type Repr = rowan::SyntaxNode;
1174 impl AstNode for FnPointerType {
1175 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1176 match syntax.kind() {
1177 FN_POINTER_TYPE => Some(FnPointerType::from_repr(syntax.into_repr())),
1181 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1184 impl ToOwned for FnPointerType {
1185 type Owned = TreeArc<FnPointerType>;
1186 fn to_owned(&self) -> TreeArc<FnPointerType> { TreeArc::cast(self.syntax.to_owned()) }
1190 impl FnPointerType {
1191 pub fn param_list(&self) -> Option<&ParamList> {
1192 super::child_opt(self)
1195 pub fn ret_type(&self) -> Option<&RetType> {
1196 super::child_opt(self)
1201 #[derive(Debug, PartialEq, Eq, Hash)]
1202 #[repr(transparent)]
1203 pub struct ForExpr {
1204 pub(crate) syntax: SyntaxNode,
1206 unsafe impl TransparentNewType for ForExpr {
1207 type Repr = rowan::SyntaxNode;
1210 impl AstNode for ForExpr {
1211 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1212 match syntax.kind() {
1213 FOR_EXPR => Some(ForExpr::from_repr(syntax.into_repr())),
1217 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1220 impl ToOwned for ForExpr {
1221 type Owned = TreeArc<ForExpr>;
1222 fn to_owned(&self) -> TreeArc<ForExpr> { TreeArc::cast(self.syntax.to_owned()) }
1226 impl ast::LoopBodyOwner for ForExpr {}
1228 pub fn pat(&self) -> Option<&Pat> {
1229 super::child_opt(self)
1232 pub fn iterable(&self) -> Option<&Expr> {
1233 super::child_opt(self)
1238 #[derive(Debug, PartialEq, Eq, Hash)]
1239 #[repr(transparent)]
1240 pub struct ForType {
1241 pub(crate) syntax: SyntaxNode,
1243 unsafe impl TransparentNewType for ForType {
1244 type Repr = rowan::SyntaxNode;
1247 impl AstNode for ForType {
1248 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1249 match syntax.kind() {
1250 FOR_TYPE => Some(ForType::from_repr(syntax.into_repr())),
1254 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1257 impl ToOwned for ForType {
1258 type Owned = TreeArc<ForType>;
1259 fn to_owned(&self) -> TreeArc<ForType> { TreeArc::cast(self.syntax.to_owned()) }
1264 pub fn type_ref(&self) -> Option<&TypeRef> {
1265 super::child_opt(self)
1270 #[derive(Debug, PartialEq, Eq, Hash)]
1271 #[repr(transparent)]
1273 pub(crate) syntax: SyntaxNode,
1275 unsafe impl TransparentNewType for IfExpr {
1276 type Repr = rowan::SyntaxNode;
1279 impl AstNode for IfExpr {
1280 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1281 match syntax.kind() {
1282 IF_EXPR => Some(IfExpr::from_repr(syntax.into_repr())),
1286 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1289 impl ToOwned for IfExpr {
1290 type Owned = TreeArc<IfExpr>;
1291 fn to_owned(&self) -> TreeArc<IfExpr> { TreeArc::cast(self.syntax.to_owned()) }
1296 pub fn condition(&self) -> Option<&Condition> {
1297 super::child_opt(self)
1302 #[derive(Debug, PartialEq, Eq, Hash)]
1303 #[repr(transparent)]
1304 pub struct ImplBlock {
1305 pub(crate) syntax: SyntaxNode,
1307 unsafe impl TransparentNewType for ImplBlock {
1308 type Repr = rowan::SyntaxNode;
1311 impl AstNode for ImplBlock {
1312 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1313 match syntax.kind() {
1314 IMPL_BLOCK => Some(ImplBlock::from_repr(syntax.into_repr())),
1318 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1321 impl ToOwned for ImplBlock {
1322 type Owned = TreeArc<ImplBlock>;
1323 fn to_owned(&self) -> TreeArc<ImplBlock> { TreeArc::cast(self.syntax.to_owned()) }
1327 impl ast::TypeParamsOwner for ImplBlock {}
1328 impl ast::AttrsOwner for ImplBlock {}
1330 pub fn item_list(&self) -> Option<&ItemList> {
1331 super::child_opt(self)
1336 #[derive(Debug, PartialEq, Eq, Hash)]
1337 #[repr(transparent)]
1338 pub struct ImplItem {
1339 pub(crate) syntax: SyntaxNode,
1341 unsafe impl TransparentNewType for ImplItem {
1342 type Repr = rowan::SyntaxNode;
1345 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1346 pub enum ImplItemKind<'a> {
1348 TypeAliasDef(&'a TypeAliasDef),
1349 ConstDef(&'a ConstDef),
1351 impl<'a> From<&'a FnDef> for &'a ImplItem {
1352 fn from(n: &'a FnDef) -> &'a ImplItem {
1353 ImplItem::cast(&n.syntax).unwrap()
1356 impl<'a> From<&'a TypeAliasDef> for &'a ImplItem {
1357 fn from(n: &'a TypeAliasDef) -> &'a ImplItem {
1358 ImplItem::cast(&n.syntax).unwrap()
1361 impl<'a> From<&'a ConstDef> for &'a ImplItem {
1362 fn from(n: &'a ConstDef) -> &'a ImplItem {
1363 ImplItem::cast(&n.syntax).unwrap()
1368 impl AstNode for ImplItem {
1369 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1370 match syntax.kind() {
1373 | CONST_DEF => Some(ImplItem::from_repr(syntax.into_repr())),
1377 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1380 impl ToOwned for ImplItem {
1381 type Owned = TreeArc<ImplItem>;
1382 fn to_owned(&self) -> TreeArc<ImplItem> { TreeArc::cast(self.syntax.to_owned()) }
1386 pub fn kind(&self) -> ImplItemKind {
1387 match self.syntax.kind() {
1388 FN_DEF => ImplItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
1389 TYPE_ALIAS_DEF => ImplItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
1390 CONST_DEF => ImplItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
1391 _ => unreachable!(),
1399 #[derive(Debug, PartialEq, Eq, Hash)]
1400 #[repr(transparent)]
1401 pub struct ImplTraitType {
1402 pub(crate) syntax: SyntaxNode,
1404 unsafe impl TransparentNewType for ImplTraitType {
1405 type Repr = rowan::SyntaxNode;
1408 impl AstNode for ImplTraitType {
1409 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1410 match syntax.kind() {
1411 IMPL_TRAIT_TYPE => Some(ImplTraitType::from_repr(syntax.into_repr())),
1415 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1418 impl ToOwned for ImplTraitType {
1419 type Owned = TreeArc<ImplTraitType>;
1420 fn to_owned(&self) -> TreeArc<ImplTraitType> { TreeArc::cast(self.syntax.to_owned()) }
1424 impl ast::TypeBoundsOwner for ImplTraitType {}
1425 impl ImplTraitType {}
1428 #[derive(Debug, PartialEq, Eq, Hash)]
1429 #[repr(transparent)]
1430 pub struct IndexExpr {
1431 pub(crate) syntax: SyntaxNode,
1433 unsafe impl TransparentNewType for IndexExpr {
1434 type Repr = rowan::SyntaxNode;
1437 impl AstNode for IndexExpr {
1438 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1439 match syntax.kind() {
1440 INDEX_EXPR => Some(IndexExpr::from_repr(syntax.into_repr())),
1444 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1447 impl ToOwned for IndexExpr {
1448 type Owned = TreeArc<IndexExpr>;
1449 fn to_owned(&self) -> TreeArc<IndexExpr> { TreeArc::cast(self.syntax.to_owned()) }
1456 #[derive(Debug, PartialEq, Eq, Hash)]
1457 #[repr(transparent)]
1458 pub struct ItemList {
1459 pub(crate) syntax: SyntaxNode,
1461 unsafe impl TransparentNewType for ItemList {
1462 type Repr = rowan::SyntaxNode;
1465 impl AstNode for ItemList {
1466 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1467 match syntax.kind() {
1468 ITEM_LIST => Some(ItemList::from_repr(syntax.into_repr())),
1472 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1475 impl ToOwned for ItemList {
1476 type Owned = TreeArc<ItemList>;
1477 fn to_owned(&self) -> TreeArc<ItemList> { TreeArc::cast(self.syntax.to_owned()) }
1481 impl ast::FnDefOwner for ItemList {}
1482 impl ast::ModuleItemOwner for ItemList {}
1484 pub fn impl_items(&self) -> impl Iterator<Item = &ImplItem> {
1485 super::children(self)
1490 #[derive(Debug, PartialEq, Eq, Hash)]
1491 #[repr(transparent)]
1493 pub(crate) syntax: SyntaxNode,
1495 unsafe impl TransparentNewType for Label {
1496 type Repr = rowan::SyntaxNode;
1499 impl AstNode for Label {
1500 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1501 match syntax.kind() {
1502 LABEL => Some(Label::from_repr(syntax.into_repr())),
1506 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1509 impl ToOwned for Label {
1510 type Owned = TreeArc<Label>;
1511 fn to_owned(&self) -> TreeArc<Label> { TreeArc::cast(self.syntax.to_owned()) }
1518 #[derive(Debug, PartialEq, Eq, Hash)]
1519 #[repr(transparent)]
1520 pub struct LambdaExpr {
1521 pub(crate) syntax: SyntaxNode,
1523 unsafe impl TransparentNewType for LambdaExpr {
1524 type Repr = rowan::SyntaxNode;
1527 impl AstNode for LambdaExpr {
1528 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1529 match syntax.kind() {
1530 LAMBDA_EXPR => Some(LambdaExpr::from_repr(syntax.into_repr())),
1534 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1537 impl ToOwned for LambdaExpr {
1538 type Owned = TreeArc<LambdaExpr>;
1539 fn to_owned(&self) -> TreeArc<LambdaExpr> { TreeArc::cast(self.syntax.to_owned()) }
1544 pub fn param_list(&self) -> Option<&ParamList> {
1545 super::child_opt(self)
1548 pub fn body(&self) -> Option<&Expr> {
1549 super::child_opt(self)
1554 #[derive(Debug, PartialEq, Eq, Hash)]
1555 #[repr(transparent)]
1556 pub struct LetStmt {
1557 pub(crate) syntax: SyntaxNode,
1559 unsafe impl TransparentNewType for LetStmt {
1560 type Repr = rowan::SyntaxNode;
1563 impl AstNode for LetStmt {
1564 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1565 match syntax.kind() {
1566 LET_STMT => Some(LetStmt::from_repr(syntax.into_repr())),
1570 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1573 impl ToOwned for LetStmt {
1574 type Owned = TreeArc<LetStmt>;
1575 fn to_owned(&self) -> TreeArc<LetStmt> { TreeArc::cast(self.syntax.to_owned()) }
1579 impl ast::TypeAscriptionOwner for LetStmt {}
1581 pub fn pat(&self) -> Option<&Pat> {
1582 super::child_opt(self)
1585 pub fn initializer(&self) -> Option<&Expr> {
1586 super::child_opt(self)
1591 #[derive(Debug, PartialEq, Eq, Hash)]
1592 #[repr(transparent)]
1593 pub struct LifetimeArg {
1594 pub(crate) syntax: SyntaxNode,
1596 unsafe impl TransparentNewType for LifetimeArg {
1597 type Repr = rowan::SyntaxNode;
1600 impl AstNode for LifetimeArg {
1601 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1602 match syntax.kind() {
1603 LIFETIME_ARG => Some(LifetimeArg::from_repr(syntax.into_repr())),
1607 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1610 impl ToOwned for LifetimeArg {
1611 type Owned = TreeArc<LifetimeArg>;
1612 fn to_owned(&self) -> TreeArc<LifetimeArg> { TreeArc::cast(self.syntax.to_owned()) }
1619 #[derive(Debug, PartialEq, Eq, Hash)]
1620 #[repr(transparent)]
1621 pub struct LifetimeParam {
1622 pub(crate) syntax: SyntaxNode,
1624 unsafe impl TransparentNewType for LifetimeParam {
1625 type Repr = rowan::SyntaxNode;
1628 impl AstNode for LifetimeParam {
1629 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1630 match syntax.kind() {
1631 LIFETIME_PARAM => Some(LifetimeParam::from_repr(syntax.into_repr())),
1635 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1638 impl ToOwned for LifetimeParam {
1639 type Owned = TreeArc<LifetimeParam>;
1640 fn to_owned(&self) -> TreeArc<LifetimeParam> { TreeArc::cast(self.syntax.to_owned()) }
1644 impl ast::AttrsOwner for LifetimeParam {}
1645 impl LifetimeParam {}
1648 #[derive(Debug, PartialEq, Eq, Hash)]
1649 #[repr(transparent)]
1650 pub struct Literal {
1651 pub(crate) syntax: SyntaxNode,
1653 unsafe impl TransparentNewType for Literal {
1654 type Repr = rowan::SyntaxNode;
1657 impl AstNode for Literal {
1658 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1659 match syntax.kind() {
1660 LITERAL => Some(Literal::from_repr(syntax.into_repr())),
1664 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1667 impl ToOwned for Literal {
1668 type Owned = TreeArc<Literal>;
1669 fn to_owned(&self) -> TreeArc<Literal> { TreeArc::cast(self.syntax.to_owned()) }
1676 #[derive(Debug, PartialEq, Eq, Hash)]
1677 #[repr(transparent)]
1678 pub struct LiteralPat {
1679 pub(crate) syntax: SyntaxNode,
1681 unsafe impl TransparentNewType for LiteralPat {
1682 type Repr = rowan::SyntaxNode;
1685 impl AstNode for LiteralPat {
1686 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1687 match syntax.kind() {
1688 LITERAL_PAT => Some(LiteralPat::from_repr(syntax.into_repr())),
1692 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1695 impl ToOwned for LiteralPat {
1696 type Owned = TreeArc<LiteralPat>;
1697 fn to_owned(&self) -> TreeArc<LiteralPat> { TreeArc::cast(self.syntax.to_owned()) }
1702 pub fn literal(&self) -> Option<&Literal> {
1703 super::child_opt(self)
1708 #[derive(Debug, PartialEq, Eq, Hash)]
1709 #[repr(transparent)]
1710 pub struct LoopExpr {
1711 pub(crate) syntax: SyntaxNode,
1713 unsafe impl TransparentNewType for LoopExpr {
1714 type Repr = rowan::SyntaxNode;
1717 impl AstNode for LoopExpr {
1718 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1719 match syntax.kind() {
1720 LOOP_EXPR => Some(LoopExpr::from_repr(syntax.into_repr())),
1724 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1727 impl ToOwned for LoopExpr {
1728 type Owned = TreeArc<LoopExpr>;
1729 fn to_owned(&self) -> TreeArc<LoopExpr> { TreeArc::cast(self.syntax.to_owned()) }
1733 impl ast::LoopBodyOwner for LoopExpr {}
1737 #[derive(Debug, PartialEq, Eq, Hash)]
1738 #[repr(transparent)]
1739 pub struct MacroCall {
1740 pub(crate) syntax: SyntaxNode,
1742 unsafe impl TransparentNewType for MacroCall {
1743 type Repr = rowan::SyntaxNode;
1746 impl AstNode for MacroCall {
1747 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1748 match syntax.kind() {
1749 MACRO_CALL => Some(MacroCall::from_repr(syntax.into_repr())),
1753 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1756 impl ToOwned for MacroCall {
1757 type Owned = TreeArc<MacroCall>;
1758 fn to_owned(&self) -> TreeArc<MacroCall> { TreeArc::cast(self.syntax.to_owned()) }
1762 impl ast::NameOwner for MacroCall {}
1763 impl ast::AttrsOwner for MacroCall {}
1764 impl ast::DocCommentsOwner for MacroCall {}
1766 pub fn token_tree(&self) -> Option<&TokenTree> {
1767 super::child_opt(self)
1770 pub fn path(&self) -> Option<&Path> {
1771 super::child_opt(self)
1776 #[derive(Debug, PartialEq, Eq, Hash)]
1777 #[repr(transparent)]
1778 pub struct MacroItems {
1779 pub(crate) syntax: SyntaxNode,
1781 unsafe impl TransparentNewType for MacroItems {
1782 type Repr = rowan::SyntaxNode;
1785 impl AstNode for MacroItems {
1786 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1787 match syntax.kind() {
1788 MACRO_ITEMS => Some(MacroItems::from_repr(syntax.into_repr())),
1792 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1795 impl ToOwned for MacroItems {
1796 type Owned = TreeArc<MacroItems>;
1797 fn to_owned(&self) -> TreeArc<MacroItems> { TreeArc::cast(self.syntax.to_owned()) }
1801 impl ast::ModuleItemOwner for MacroItems {}
1802 impl ast::FnDefOwner for MacroItems {}
1806 #[derive(Debug, PartialEq, Eq, Hash)]
1807 #[repr(transparent)]
1808 pub struct MacroStmts {
1809 pub(crate) syntax: SyntaxNode,
1811 unsafe impl TransparentNewType for MacroStmts {
1812 type Repr = rowan::SyntaxNode;
1815 impl AstNode for MacroStmts {
1816 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1817 match syntax.kind() {
1818 MACRO_STMTS => Some(MacroStmts::from_repr(syntax.into_repr())),
1822 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1825 impl ToOwned for MacroStmts {
1826 type Owned = TreeArc<MacroStmts>;
1827 fn to_owned(&self) -> TreeArc<MacroStmts> { TreeArc::cast(self.syntax.to_owned()) }
1832 pub fn statements(&self) -> impl Iterator<Item = &Stmt> {
1833 super::children(self)
1836 pub fn expr(&self) -> Option<&Expr> {
1837 super::child_opt(self)
1842 #[derive(Debug, PartialEq, Eq, Hash)]
1843 #[repr(transparent)]
1844 pub struct MatchArm {
1845 pub(crate) syntax: SyntaxNode,
1847 unsafe impl TransparentNewType for MatchArm {
1848 type Repr = rowan::SyntaxNode;
1851 impl AstNode for MatchArm {
1852 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1853 match syntax.kind() {
1854 MATCH_ARM => Some(MatchArm::from_repr(syntax.into_repr())),
1858 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1861 impl ToOwned for MatchArm {
1862 type Owned = TreeArc<MatchArm>;
1863 fn to_owned(&self) -> TreeArc<MatchArm> { TreeArc::cast(self.syntax.to_owned()) }
1867 impl ast::AttrsOwner for MatchArm {}
1869 pub fn pats(&self) -> impl Iterator<Item = &Pat> {
1870 super::children(self)
1873 pub fn guard(&self) -> Option<&MatchGuard> {
1874 super::child_opt(self)
1877 pub fn expr(&self) -> Option<&Expr> {
1878 super::child_opt(self)
1883 #[derive(Debug, PartialEq, Eq, Hash)]
1884 #[repr(transparent)]
1885 pub struct MatchArmList {
1886 pub(crate) syntax: SyntaxNode,
1888 unsafe impl TransparentNewType for MatchArmList {
1889 type Repr = rowan::SyntaxNode;
1892 impl AstNode for MatchArmList {
1893 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1894 match syntax.kind() {
1895 MATCH_ARM_LIST => Some(MatchArmList::from_repr(syntax.into_repr())),
1899 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1902 impl ToOwned for MatchArmList {
1903 type Owned = TreeArc<MatchArmList>;
1904 fn to_owned(&self) -> TreeArc<MatchArmList> { TreeArc::cast(self.syntax.to_owned()) }
1908 impl ast::AttrsOwner for MatchArmList {}
1910 pub fn arms(&self) -> impl Iterator<Item = &MatchArm> {
1911 super::children(self)
1916 #[derive(Debug, PartialEq, Eq, Hash)]
1917 #[repr(transparent)]
1918 pub struct MatchExpr {
1919 pub(crate) syntax: SyntaxNode,
1921 unsafe impl TransparentNewType for MatchExpr {
1922 type Repr = rowan::SyntaxNode;
1925 impl AstNode for MatchExpr {
1926 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1927 match syntax.kind() {
1928 MATCH_EXPR => Some(MatchExpr::from_repr(syntax.into_repr())),
1932 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1935 impl ToOwned for MatchExpr {
1936 type Owned = TreeArc<MatchExpr>;
1937 fn to_owned(&self) -> TreeArc<MatchExpr> { TreeArc::cast(self.syntax.to_owned()) }
1942 pub fn expr(&self) -> Option<&Expr> {
1943 super::child_opt(self)
1946 pub fn match_arm_list(&self) -> Option<&MatchArmList> {
1947 super::child_opt(self)
1952 #[derive(Debug, PartialEq, Eq, Hash)]
1953 #[repr(transparent)]
1954 pub struct MatchGuard {
1955 pub(crate) syntax: SyntaxNode,
1957 unsafe impl TransparentNewType for MatchGuard {
1958 type Repr = rowan::SyntaxNode;
1961 impl AstNode for MatchGuard {
1962 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1963 match syntax.kind() {
1964 MATCH_GUARD => Some(MatchGuard::from_repr(syntax.into_repr())),
1968 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1971 impl ToOwned for MatchGuard {
1972 type Owned = TreeArc<MatchGuard>;
1973 fn to_owned(&self) -> TreeArc<MatchGuard> { TreeArc::cast(self.syntax.to_owned()) }
1978 pub fn expr(&self) -> Option<&Expr> {
1979 super::child_opt(self)
1984 #[derive(Debug, PartialEq, Eq, Hash)]
1985 #[repr(transparent)]
1986 pub struct MethodCallExpr {
1987 pub(crate) syntax: SyntaxNode,
1989 unsafe impl TransparentNewType for MethodCallExpr {
1990 type Repr = rowan::SyntaxNode;
1993 impl AstNode for MethodCallExpr {
1994 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1995 match syntax.kind() {
1996 METHOD_CALL_EXPR => Some(MethodCallExpr::from_repr(syntax.into_repr())),
2000 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2003 impl ToOwned for MethodCallExpr {
2004 type Owned = TreeArc<MethodCallExpr>;
2005 fn to_owned(&self) -> TreeArc<MethodCallExpr> { TreeArc::cast(self.syntax.to_owned()) }
2009 impl ast::ArgListOwner for MethodCallExpr {}
2010 impl MethodCallExpr {
2011 pub fn expr(&self) -> Option<&Expr> {
2012 super::child_opt(self)
2015 pub fn name_ref(&self) -> Option<&NameRef> {
2016 super::child_opt(self)
2019 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
2020 super::child_opt(self)
2025 #[derive(Debug, PartialEq, Eq, Hash)]
2026 #[repr(transparent)]
2028 pub(crate) syntax: SyntaxNode,
2030 unsafe impl TransparentNewType for Module {
2031 type Repr = rowan::SyntaxNode;
2034 impl AstNode for Module {
2035 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2036 match syntax.kind() {
2037 MODULE => Some(Module::from_repr(syntax.into_repr())),
2041 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2044 impl ToOwned for Module {
2045 type Owned = TreeArc<Module>;
2046 fn to_owned(&self) -> TreeArc<Module> { TreeArc::cast(self.syntax.to_owned()) }
2050 impl ast::VisibilityOwner for Module {}
2051 impl ast::NameOwner for Module {}
2052 impl ast::AttrsOwner for Module {}
2053 impl ast::DocCommentsOwner for Module {}
2055 pub fn item_list(&self) -> Option<&ItemList> {
2056 super::child_opt(self)
2061 #[derive(Debug, PartialEq, Eq, Hash)]
2062 #[repr(transparent)]
2063 pub struct ModuleItem {
2064 pub(crate) syntax: SyntaxNode,
2066 unsafe impl TransparentNewType for ModuleItem {
2067 type Repr = rowan::SyntaxNode;
2070 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2071 pub enum ModuleItemKind<'a> {
2072 StructDef(&'a StructDef),
2073 EnumDef(&'a EnumDef),
2075 TraitDef(&'a TraitDef),
2076 TypeAliasDef(&'a TypeAliasDef),
2077 ImplBlock(&'a ImplBlock),
2078 UseItem(&'a UseItem),
2079 ExternCrateItem(&'a ExternCrateItem),
2080 ConstDef(&'a ConstDef),
2081 StaticDef(&'a StaticDef),
2084 impl<'a> From<&'a StructDef> for &'a ModuleItem {
2085 fn from(n: &'a StructDef) -> &'a ModuleItem {
2086 ModuleItem::cast(&n.syntax).unwrap()
2089 impl<'a> From<&'a EnumDef> for &'a ModuleItem {
2090 fn from(n: &'a EnumDef) -> &'a ModuleItem {
2091 ModuleItem::cast(&n.syntax).unwrap()
2094 impl<'a> From<&'a FnDef> for &'a ModuleItem {
2095 fn from(n: &'a FnDef) -> &'a ModuleItem {
2096 ModuleItem::cast(&n.syntax).unwrap()
2099 impl<'a> From<&'a TraitDef> for &'a ModuleItem {
2100 fn from(n: &'a TraitDef) -> &'a ModuleItem {
2101 ModuleItem::cast(&n.syntax).unwrap()
2104 impl<'a> From<&'a TypeAliasDef> for &'a ModuleItem {
2105 fn from(n: &'a TypeAliasDef) -> &'a ModuleItem {
2106 ModuleItem::cast(&n.syntax).unwrap()
2109 impl<'a> From<&'a ImplBlock> for &'a ModuleItem {
2110 fn from(n: &'a ImplBlock) -> &'a ModuleItem {
2111 ModuleItem::cast(&n.syntax).unwrap()
2114 impl<'a> From<&'a UseItem> for &'a ModuleItem {
2115 fn from(n: &'a UseItem) -> &'a ModuleItem {
2116 ModuleItem::cast(&n.syntax).unwrap()
2119 impl<'a> From<&'a ExternCrateItem> for &'a ModuleItem {
2120 fn from(n: &'a ExternCrateItem) -> &'a ModuleItem {
2121 ModuleItem::cast(&n.syntax).unwrap()
2124 impl<'a> From<&'a ConstDef> for &'a ModuleItem {
2125 fn from(n: &'a ConstDef) -> &'a ModuleItem {
2126 ModuleItem::cast(&n.syntax).unwrap()
2129 impl<'a> From<&'a StaticDef> for &'a ModuleItem {
2130 fn from(n: &'a StaticDef) -> &'a ModuleItem {
2131 ModuleItem::cast(&n.syntax).unwrap()
2134 impl<'a> From<&'a Module> for &'a ModuleItem {
2135 fn from(n: &'a Module) -> &'a ModuleItem {
2136 ModuleItem::cast(&n.syntax).unwrap()
2141 impl AstNode for ModuleItem {
2142 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2143 match syntax.kind() {
2154 | MODULE => Some(ModuleItem::from_repr(syntax.into_repr())),
2158 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2161 impl ToOwned for ModuleItem {
2162 type Owned = TreeArc<ModuleItem>;
2163 fn to_owned(&self) -> TreeArc<ModuleItem> { TreeArc::cast(self.syntax.to_owned()) }
2167 pub fn kind(&self) -> ModuleItemKind {
2168 match self.syntax.kind() {
2169 STRUCT_DEF => ModuleItemKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2170 ENUM_DEF => ModuleItemKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2171 FN_DEF => ModuleItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
2172 TRAIT_DEF => ModuleItemKind::TraitDef(TraitDef::cast(&self.syntax).unwrap()),
2173 TYPE_ALIAS_DEF => ModuleItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
2174 IMPL_BLOCK => ModuleItemKind::ImplBlock(ImplBlock::cast(&self.syntax).unwrap()),
2175 USE_ITEM => ModuleItemKind::UseItem(UseItem::cast(&self.syntax).unwrap()),
2176 EXTERN_CRATE_ITEM => ModuleItemKind::ExternCrateItem(ExternCrateItem::cast(&self.syntax).unwrap()),
2177 CONST_DEF => ModuleItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
2178 STATIC_DEF => ModuleItemKind::StaticDef(StaticDef::cast(&self.syntax).unwrap()),
2179 MODULE => ModuleItemKind::Module(Module::cast(&self.syntax).unwrap()),
2180 _ => unreachable!(),
2188 #[derive(Debug, PartialEq, Eq, Hash)]
2189 #[repr(transparent)]
2191 pub(crate) syntax: SyntaxNode,
2193 unsafe impl TransparentNewType for Name {
2194 type Repr = rowan::SyntaxNode;
2197 impl AstNode for Name {
2198 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2199 match syntax.kind() {
2200 NAME => Some(Name::from_repr(syntax.into_repr())),
2204 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2207 impl ToOwned for Name {
2208 type Owned = TreeArc<Name>;
2209 fn to_owned(&self) -> TreeArc<Name> { TreeArc::cast(self.syntax.to_owned()) }
2216 #[derive(Debug, PartialEq, Eq, Hash)]
2217 #[repr(transparent)]
2218 pub struct NameRef {
2219 pub(crate) syntax: SyntaxNode,
2221 unsafe impl TransparentNewType for NameRef {
2222 type Repr = rowan::SyntaxNode;
2225 impl AstNode for NameRef {
2226 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2227 match syntax.kind() {
2228 NAME_REF => Some(NameRef::from_repr(syntax.into_repr())),
2232 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2235 impl ToOwned for NameRef {
2236 type Owned = TreeArc<NameRef>;
2237 fn to_owned(&self) -> TreeArc<NameRef> { TreeArc::cast(self.syntax.to_owned()) }
2244 #[derive(Debug, PartialEq, Eq, Hash)]
2245 #[repr(transparent)]
2246 pub struct NamedField {
2247 pub(crate) syntax: SyntaxNode,
2249 unsafe impl TransparentNewType for NamedField {
2250 type Repr = rowan::SyntaxNode;
2253 impl AstNode for NamedField {
2254 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2255 match syntax.kind() {
2256 NAMED_FIELD => Some(NamedField::from_repr(syntax.into_repr())),
2260 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2263 impl ToOwned for NamedField {
2264 type Owned = TreeArc<NamedField>;
2265 fn to_owned(&self) -> TreeArc<NamedField> { TreeArc::cast(self.syntax.to_owned()) }
2270 pub fn name_ref(&self) -> Option<&NameRef> {
2271 super::child_opt(self)
2274 pub fn expr(&self) -> Option<&Expr> {
2275 super::child_opt(self)
2280 #[derive(Debug, PartialEq, Eq, Hash)]
2281 #[repr(transparent)]
2282 pub struct NamedFieldDef {
2283 pub(crate) syntax: SyntaxNode,
2285 unsafe impl TransparentNewType for NamedFieldDef {
2286 type Repr = rowan::SyntaxNode;
2289 impl AstNode for NamedFieldDef {
2290 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2291 match syntax.kind() {
2292 NAMED_FIELD_DEF => Some(NamedFieldDef::from_repr(syntax.into_repr())),
2296 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2299 impl ToOwned for NamedFieldDef {
2300 type Owned = TreeArc<NamedFieldDef>;
2301 fn to_owned(&self) -> TreeArc<NamedFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2305 impl ast::VisibilityOwner for NamedFieldDef {}
2306 impl ast::NameOwner for NamedFieldDef {}
2307 impl ast::AttrsOwner for NamedFieldDef {}
2308 impl ast::DocCommentsOwner for NamedFieldDef {}
2309 impl ast::TypeAscriptionOwner for NamedFieldDef {}
2310 impl NamedFieldDef {}
2312 // NamedFieldDefList
2313 #[derive(Debug, PartialEq, Eq, Hash)]
2314 #[repr(transparent)]
2315 pub struct NamedFieldDefList {
2316 pub(crate) syntax: SyntaxNode,
2318 unsafe impl TransparentNewType for NamedFieldDefList {
2319 type Repr = rowan::SyntaxNode;
2322 impl AstNode for NamedFieldDefList {
2323 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2324 match syntax.kind() {
2325 NAMED_FIELD_DEF_LIST => Some(NamedFieldDefList::from_repr(syntax.into_repr())),
2329 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2332 impl ToOwned for NamedFieldDefList {
2333 type Owned = TreeArc<NamedFieldDefList>;
2334 fn to_owned(&self) -> TreeArc<NamedFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
2338 impl NamedFieldDefList {
2339 pub fn fields(&self) -> impl Iterator<Item = &NamedFieldDef> {
2340 super::children(self)
2345 #[derive(Debug, PartialEq, Eq, Hash)]
2346 #[repr(transparent)]
2347 pub struct NamedFieldList {
2348 pub(crate) syntax: SyntaxNode,
2350 unsafe impl TransparentNewType for NamedFieldList {
2351 type Repr = rowan::SyntaxNode;
2354 impl AstNode for NamedFieldList {
2355 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2356 match syntax.kind() {
2357 NAMED_FIELD_LIST => Some(NamedFieldList::from_repr(syntax.into_repr())),
2361 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2364 impl ToOwned for NamedFieldList {
2365 type Owned = TreeArc<NamedFieldList>;
2366 fn to_owned(&self) -> TreeArc<NamedFieldList> { TreeArc::cast(self.syntax.to_owned()) }
2370 impl NamedFieldList {
2371 pub fn fields(&self) -> impl Iterator<Item = &NamedField> {
2372 super::children(self)
2377 #[derive(Debug, PartialEq, Eq, Hash)]
2378 #[repr(transparent)]
2379 pub struct NeverType {
2380 pub(crate) syntax: SyntaxNode,
2382 unsafe impl TransparentNewType for NeverType {
2383 type Repr = rowan::SyntaxNode;
2386 impl AstNode for NeverType {
2387 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2388 match syntax.kind() {
2389 NEVER_TYPE => Some(NeverType::from_repr(syntax.into_repr())),
2393 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2396 impl ToOwned for NeverType {
2397 type Owned = TreeArc<NeverType>;
2398 fn to_owned(&self) -> TreeArc<NeverType> { TreeArc::cast(self.syntax.to_owned()) }
2405 #[derive(Debug, PartialEq, Eq, Hash)]
2406 #[repr(transparent)]
2407 pub struct NominalDef {
2408 pub(crate) syntax: SyntaxNode,
2410 unsafe impl TransparentNewType for NominalDef {
2411 type Repr = rowan::SyntaxNode;
2414 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2415 pub enum NominalDefKind<'a> {
2416 StructDef(&'a StructDef),
2417 EnumDef(&'a EnumDef),
2419 impl<'a> From<&'a StructDef> for &'a NominalDef {
2420 fn from(n: &'a StructDef) -> &'a NominalDef {
2421 NominalDef::cast(&n.syntax).unwrap()
2424 impl<'a> From<&'a EnumDef> for &'a NominalDef {
2425 fn from(n: &'a EnumDef) -> &'a NominalDef {
2426 NominalDef::cast(&n.syntax).unwrap()
2431 impl AstNode for NominalDef {
2432 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2433 match syntax.kind() {
2435 | ENUM_DEF => Some(NominalDef::from_repr(syntax.into_repr())),
2439 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2442 impl ToOwned for NominalDef {
2443 type Owned = TreeArc<NominalDef>;
2444 fn to_owned(&self) -> TreeArc<NominalDef> { TreeArc::cast(self.syntax.to_owned()) }
2448 pub fn kind(&self) -> NominalDefKind {
2449 match self.syntax.kind() {
2450 STRUCT_DEF => NominalDefKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2451 ENUM_DEF => NominalDefKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2452 _ => unreachable!(),
2457 impl ast::NameOwner for NominalDef {}
2458 impl ast::TypeParamsOwner for NominalDef {}
2459 impl ast::AttrsOwner for NominalDef {}
2463 #[derive(Debug, PartialEq, Eq, Hash)]
2464 #[repr(transparent)]
2466 pub(crate) syntax: SyntaxNode,
2468 unsafe impl TransparentNewType for Param {
2469 type Repr = rowan::SyntaxNode;
2472 impl AstNode for Param {
2473 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2474 match syntax.kind() {
2475 PARAM => Some(Param::from_repr(syntax.into_repr())),
2479 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2482 impl ToOwned for Param {
2483 type Owned = TreeArc<Param>;
2484 fn to_owned(&self) -> TreeArc<Param> { TreeArc::cast(self.syntax.to_owned()) }
2488 impl ast::TypeAscriptionOwner for Param {}
2490 pub fn pat(&self) -> Option<&Pat> {
2491 super::child_opt(self)
2496 #[derive(Debug, PartialEq, Eq, Hash)]
2497 #[repr(transparent)]
2498 pub struct ParamList {
2499 pub(crate) syntax: SyntaxNode,
2501 unsafe impl TransparentNewType for ParamList {
2502 type Repr = rowan::SyntaxNode;
2505 impl AstNode for ParamList {
2506 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2507 match syntax.kind() {
2508 PARAM_LIST => Some(ParamList::from_repr(syntax.into_repr())),
2512 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2515 impl ToOwned for ParamList {
2516 type Owned = TreeArc<ParamList>;
2517 fn to_owned(&self) -> TreeArc<ParamList> { TreeArc::cast(self.syntax.to_owned()) }
2522 pub fn params(&self) -> impl Iterator<Item = &Param> {
2523 super::children(self)
2526 pub fn self_param(&self) -> Option<&SelfParam> {
2527 super::child_opt(self)
2532 #[derive(Debug, PartialEq, Eq, Hash)]
2533 #[repr(transparent)]
2534 pub struct ParenExpr {
2535 pub(crate) syntax: SyntaxNode,
2537 unsafe impl TransparentNewType for ParenExpr {
2538 type Repr = rowan::SyntaxNode;
2541 impl AstNode for ParenExpr {
2542 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2543 match syntax.kind() {
2544 PAREN_EXPR => Some(ParenExpr::from_repr(syntax.into_repr())),
2548 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2551 impl ToOwned for ParenExpr {
2552 type Owned = TreeArc<ParenExpr>;
2553 fn to_owned(&self) -> TreeArc<ParenExpr> { TreeArc::cast(self.syntax.to_owned()) }
2558 pub fn expr(&self) -> Option<&Expr> {
2559 super::child_opt(self)
2564 #[derive(Debug, PartialEq, Eq, Hash)]
2565 #[repr(transparent)]
2566 pub struct ParenType {
2567 pub(crate) syntax: SyntaxNode,
2569 unsafe impl TransparentNewType for ParenType {
2570 type Repr = rowan::SyntaxNode;
2573 impl AstNode for ParenType {
2574 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2575 match syntax.kind() {
2576 PAREN_TYPE => Some(ParenType::from_repr(syntax.into_repr())),
2580 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2583 impl ToOwned for ParenType {
2584 type Owned = TreeArc<ParenType>;
2585 fn to_owned(&self) -> TreeArc<ParenType> { TreeArc::cast(self.syntax.to_owned()) }
2590 pub fn type_ref(&self) -> Option<&TypeRef> {
2591 super::child_opt(self)
2596 #[derive(Debug, PartialEq, Eq, Hash)]
2597 #[repr(transparent)]
2599 pub(crate) syntax: SyntaxNode,
2601 unsafe impl TransparentNewType for Pat {
2602 type Repr = rowan::SyntaxNode;
2605 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2606 pub enum PatKind<'a> {
2608 BindPat(&'a BindPat),
2609 PlaceholderPat(&'a PlaceholderPat),
2610 PathPat(&'a PathPat),
2611 StructPat(&'a StructPat),
2612 TupleStructPat(&'a TupleStructPat),
2613 TuplePat(&'a TuplePat),
2614 SlicePat(&'a SlicePat),
2615 RangePat(&'a RangePat),
2616 LiteralPat(&'a LiteralPat),
2618 impl<'a> From<&'a RefPat> for &'a Pat {
2619 fn from(n: &'a RefPat) -> &'a Pat {
2620 Pat::cast(&n.syntax).unwrap()
2623 impl<'a> From<&'a BindPat> for &'a Pat {
2624 fn from(n: &'a BindPat) -> &'a Pat {
2625 Pat::cast(&n.syntax).unwrap()
2628 impl<'a> From<&'a PlaceholderPat> for &'a Pat {
2629 fn from(n: &'a PlaceholderPat) -> &'a Pat {
2630 Pat::cast(&n.syntax).unwrap()
2633 impl<'a> From<&'a PathPat> for &'a Pat {
2634 fn from(n: &'a PathPat) -> &'a Pat {
2635 Pat::cast(&n.syntax).unwrap()
2638 impl<'a> From<&'a StructPat> for &'a Pat {
2639 fn from(n: &'a StructPat) -> &'a Pat {
2640 Pat::cast(&n.syntax).unwrap()
2643 impl<'a> From<&'a TupleStructPat> for &'a Pat {
2644 fn from(n: &'a TupleStructPat) -> &'a Pat {
2645 Pat::cast(&n.syntax).unwrap()
2648 impl<'a> From<&'a TuplePat> for &'a Pat {
2649 fn from(n: &'a TuplePat) -> &'a Pat {
2650 Pat::cast(&n.syntax).unwrap()
2653 impl<'a> From<&'a SlicePat> for &'a Pat {
2654 fn from(n: &'a SlicePat) -> &'a Pat {
2655 Pat::cast(&n.syntax).unwrap()
2658 impl<'a> From<&'a RangePat> for &'a Pat {
2659 fn from(n: &'a RangePat) -> &'a Pat {
2660 Pat::cast(&n.syntax).unwrap()
2663 impl<'a> From<&'a LiteralPat> for &'a Pat {
2664 fn from(n: &'a LiteralPat) -> &'a Pat {
2665 Pat::cast(&n.syntax).unwrap()
2670 impl AstNode for Pat {
2671 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2672 match syntax.kind() {
2682 | LITERAL_PAT => Some(Pat::from_repr(syntax.into_repr())),
2686 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2689 impl ToOwned for Pat {
2690 type Owned = TreeArc<Pat>;
2691 fn to_owned(&self) -> TreeArc<Pat> { TreeArc::cast(self.syntax.to_owned()) }
2695 pub fn kind(&self) -> PatKind {
2696 match self.syntax.kind() {
2697 REF_PAT => PatKind::RefPat(RefPat::cast(&self.syntax).unwrap()),
2698 BIND_PAT => PatKind::BindPat(BindPat::cast(&self.syntax).unwrap()),
2699 PLACEHOLDER_PAT => PatKind::PlaceholderPat(PlaceholderPat::cast(&self.syntax).unwrap()),
2700 PATH_PAT => PatKind::PathPat(PathPat::cast(&self.syntax).unwrap()),
2701 STRUCT_PAT => PatKind::StructPat(StructPat::cast(&self.syntax).unwrap()),
2702 TUPLE_STRUCT_PAT => PatKind::TupleStructPat(TupleStructPat::cast(&self.syntax).unwrap()),
2703 TUPLE_PAT => PatKind::TuplePat(TuplePat::cast(&self.syntax).unwrap()),
2704 SLICE_PAT => PatKind::SlicePat(SlicePat::cast(&self.syntax).unwrap()),
2705 RANGE_PAT => PatKind::RangePat(RangePat::cast(&self.syntax).unwrap()),
2706 LITERAL_PAT => PatKind::LiteralPat(LiteralPat::cast(&self.syntax).unwrap()),
2707 _ => unreachable!(),
2715 #[derive(Debug, PartialEq, Eq, Hash)]
2716 #[repr(transparent)]
2718 pub(crate) syntax: SyntaxNode,
2720 unsafe impl TransparentNewType for Path {
2721 type Repr = rowan::SyntaxNode;
2724 impl AstNode for Path {
2725 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2726 match syntax.kind() {
2727 PATH => Some(Path::from_repr(syntax.into_repr())),
2731 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2734 impl ToOwned for Path {
2735 type Owned = TreeArc<Path>;
2736 fn to_owned(&self) -> TreeArc<Path> { TreeArc::cast(self.syntax.to_owned()) }
2741 pub fn segment(&self) -> Option<&PathSegment> {
2742 super::child_opt(self)
2745 pub fn qualifier(&self) -> Option<&Path> {
2746 super::child_opt(self)
2751 #[derive(Debug, PartialEq, Eq, Hash)]
2752 #[repr(transparent)]
2753 pub struct PathExpr {
2754 pub(crate) syntax: SyntaxNode,
2756 unsafe impl TransparentNewType for PathExpr {
2757 type Repr = rowan::SyntaxNode;
2760 impl AstNode for PathExpr {
2761 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2762 match syntax.kind() {
2763 PATH_EXPR => Some(PathExpr::from_repr(syntax.into_repr())),
2767 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2770 impl ToOwned for PathExpr {
2771 type Owned = TreeArc<PathExpr>;
2772 fn to_owned(&self) -> TreeArc<PathExpr> { TreeArc::cast(self.syntax.to_owned()) }
2777 pub fn path(&self) -> Option<&Path> {
2778 super::child_opt(self)
2783 #[derive(Debug, PartialEq, Eq, Hash)]
2784 #[repr(transparent)]
2785 pub struct PathPat {
2786 pub(crate) syntax: SyntaxNode,
2788 unsafe impl TransparentNewType for PathPat {
2789 type Repr = rowan::SyntaxNode;
2792 impl AstNode for PathPat {
2793 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2794 match syntax.kind() {
2795 PATH_PAT => Some(PathPat::from_repr(syntax.into_repr())),
2799 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2802 impl ToOwned for PathPat {
2803 type Owned = TreeArc<PathPat>;
2804 fn to_owned(&self) -> TreeArc<PathPat> { TreeArc::cast(self.syntax.to_owned()) }
2809 pub fn path(&self) -> Option<&Path> {
2810 super::child_opt(self)
2815 #[derive(Debug, PartialEq, Eq, Hash)]
2816 #[repr(transparent)]
2817 pub struct PathSegment {
2818 pub(crate) syntax: SyntaxNode,
2820 unsafe impl TransparentNewType for PathSegment {
2821 type Repr = rowan::SyntaxNode;
2824 impl AstNode for PathSegment {
2825 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2826 match syntax.kind() {
2827 PATH_SEGMENT => Some(PathSegment::from_repr(syntax.into_repr())),
2831 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2834 impl ToOwned for PathSegment {
2835 type Owned = TreeArc<PathSegment>;
2836 fn to_owned(&self) -> TreeArc<PathSegment> { TreeArc::cast(self.syntax.to_owned()) }
2841 pub fn name_ref(&self) -> Option<&NameRef> {
2842 super::child_opt(self)
2845 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
2846 super::child_opt(self)
2851 #[derive(Debug, PartialEq, Eq, Hash)]
2852 #[repr(transparent)]
2853 pub struct PathType {
2854 pub(crate) syntax: SyntaxNode,
2856 unsafe impl TransparentNewType for PathType {
2857 type Repr = rowan::SyntaxNode;
2860 impl AstNode for PathType {
2861 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2862 match syntax.kind() {
2863 PATH_TYPE => Some(PathType::from_repr(syntax.into_repr())),
2867 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2870 impl ToOwned for PathType {
2871 type Owned = TreeArc<PathType>;
2872 fn to_owned(&self) -> TreeArc<PathType> { TreeArc::cast(self.syntax.to_owned()) }
2877 pub fn path(&self) -> Option<&Path> {
2878 super::child_opt(self)
2883 #[derive(Debug, PartialEq, Eq, Hash)]
2884 #[repr(transparent)]
2885 pub struct PlaceholderPat {
2886 pub(crate) syntax: SyntaxNode,
2888 unsafe impl TransparentNewType for PlaceholderPat {
2889 type Repr = rowan::SyntaxNode;
2892 impl AstNode for PlaceholderPat {
2893 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2894 match syntax.kind() {
2895 PLACEHOLDER_PAT => Some(PlaceholderPat::from_repr(syntax.into_repr())),
2899 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2902 impl ToOwned for PlaceholderPat {
2903 type Owned = TreeArc<PlaceholderPat>;
2904 fn to_owned(&self) -> TreeArc<PlaceholderPat> { TreeArc::cast(self.syntax.to_owned()) }
2908 impl PlaceholderPat {}
2911 #[derive(Debug, PartialEq, Eq, Hash)]
2912 #[repr(transparent)]
2913 pub struct PlaceholderType {
2914 pub(crate) syntax: SyntaxNode,
2916 unsafe impl TransparentNewType for PlaceholderType {
2917 type Repr = rowan::SyntaxNode;
2920 impl AstNode for PlaceholderType {
2921 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2922 match syntax.kind() {
2923 PLACEHOLDER_TYPE => Some(PlaceholderType::from_repr(syntax.into_repr())),
2927 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2930 impl ToOwned for PlaceholderType {
2931 type Owned = TreeArc<PlaceholderType>;
2932 fn to_owned(&self) -> TreeArc<PlaceholderType> { TreeArc::cast(self.syntax.to_owned()) }
2936 impl PlaceholderType {}
2939 #[derive(Debug, PartialEq, Eq, Hash)]
2940 #[repr(transparent)]
2941 pub struct PointerType {
2942 pub(crate) syntax: SyntaxNode,
2944 unsafe impl TransparentNewType for PointerType {
2945 type Repr = rowan::SyntaxNode;
2948 impl AstNode for PointerType {
2949 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2950 match syntax.kind() {
2951 POINTER_TYPE => Some(PointerType::from_repr(syntax.into_repr())),
2955 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2958 impl ToOwned for PointerType {
2959 type Owned = TreeArc<PointerType>;
2960 fn to_owned(&self) -> TreeArc<PointerType> { TreeArc::cast(self.syntax.to_owned()) }
2965 pub fn type_ref(&self) -> Option<&TypeRef> {
2966 super::child_opt(self)
2971 #[derive(Debug, PartialEq, Eq, Hash)]
2972 #[repr(transparent)]
2973 pub struct PosFieldDef {
2974 pub(crate) syntax: SyntaxNode,
2976 unsafe impl TransparentNewType for PosFieldDef {
2977 type Repr = rowan::SyntaxNode;
2980 impl AstNode for PosFieldDef {
2981 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2982 match syntax.kind() {
2983 POS_FIELD_DEF => Some(PosFieldDef::from_repr(syntax.into_repr())),
2987 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2990 impl ToOwned for PosFieldDef {
2991 type Owned = TreeArc<PosFieldDef>;
2992 fn to_owned(&self) -> TreeArc<PosFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2996 impl ast::VisibilityOwner for PosFieldDef {}
2997 impl ast::AttrsOwner for PosFieldDef {}
2999 pub fn type_ref(&self) -> Option<&TypeRef> {
3000 super::child_opt(self)
3005 #[derive(Debug, PartialEq, Eq, Hash)]
3006 #[repr(transparent)]
3007 pub struct PosFieldDefList {
3008 pub(crate) syntax: SyntaxNode,
3010 unsafe impl TransparentNewType for PosFieldDefList {
3011 type Repr = rowan::SyntaxNode;
3014 impl AstNode for PosFieldDefList {
3015 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3016 match syntax.kind() {
3017 POS_FIELD_DEF_LIST => Some(PosFieldDefList::from_repr(syntax.into_repr())),
3021 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3024 impl ToOwned for PosFieldDefList {
3025 type Owned = TreeArc<PosFieldDefList>;
3026 fn to_owned(&self) -> TreeArc<PosFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
3030 impl PosFieldDefList {
3031 pub fn fields(&self) -> impl Iterator<Item = &PosFieldDef> {
3032 super::children(self)
3037 #[derive(Debug, PartialEq, Eq, Hash)]
3038 #[repr(transparent)]
3039 pub struct PrefixExpr {
3040 pub(crate) syntax: SyntaxNode,
3042 unsafe impl TransparentNewType for PrefixExpr {
3043 type Repr = rowan::SyntaxNode;
3046 impl AstNode for PrefixExpr {
3047 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3048 match syntax.kind() {
3049 PREFIX_EXPR => Some(PrefixExpr::from_repr(syntax.into_repr())),
3053 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3056 impl ToOwned for PrefixExpr {
3057 type Owned = TreeArc<PrefixExpr>;
3058 fn to_owned(&self) -> TreeArc<PrefixExpr> { TreeArc::cast(self.syntax.to_owned()) }
3063 pub fn expr(&self) -> Option<&Expr> {
3064 super::child_opt(self)
3069 #[derive(Debug, PartialEq, Eq, Hash)]
3070 #[repr(transparent)]
3071 pub struct RangeExpr {
3072 pub(crate) syntax: SyntaxNode,
3074 unsafe impl TransparentNewType for RangeExpr {
3075 type Repr = rowan::SyntaxNode;
3078 impl AstNode for RangeExpr {
3079 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3080 match syntax.kind() {
3081 RANGE_EXPR => Some(RangeExpr::from_repr(syntax.into_repr())),
3085 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3088 impl ToOwned for RangeExpr {
3089 type Owned = TreeArc<RangeExpr>;
3090 fn to_owned(&self) -> TreeArc<RangeExpr> { TreeArc::cast(self.syntax.to_owned()) }
3097 #[derive(Debug, PartialEq, Eq, Hash)]
3098 #[repr(transparent)]
3099 pub struct RangePat {
3100 pub(crate) syntax: SyntaxNode,
3102 unsafe impl TransparentNewType for RangePat {
3103 type Repr = rowan::SyntaxNode;
3106 impl AstNode for RangePat {
3107 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3108 match syntax.kind() {
3109 RANGE_PAT => Some(RangePat::from_repr(syntax.into_repr())),
3113 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3116 impl ToOwned for RangePat {
3117 type Owned = TreeArc<RangePat>;
3118 fn to_owned(&self) -> TreeArc<RangePat> { TreeArc::cast(self.syntax.to_owned()) }
3125 #[derive(Debug, PartialEq, Eq, Hash)]
3126 #[repr(transparent)]
3127 pub struct RefExpr {
3128 pub(crate) syntax: SyntaxNode,
3130 unsafe impl TransparentNewType for RefExpr {
3131 type Repr = rowan::SyntaxNode;
3134 impl AstNode for RefExpr {
3135 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3136 match syntax.kind() {
3137 REF_EXPR => Some(RefExpr::from_repr(syntax.into_repr())),
3141 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3144 impl ToOwned for RefExpr {
3145 type Owned = TreeArc<RefExpr>;
3146 fn to_owned(&self) -> TreeArc<RefExpr> { TreeArc::cast(self.syntax.to_owned()) }
3151 pub fn expr(&self) -> Option<&Expr> {
3152 super::child_opt(self)
3157 #[derive(Debug, PartialEq, Eq, Hash)]
3158 #[repr(transparent)]
3160 pub(crate) syntax: SyntaxNode,
3162 unsafe impl TransparentNewType for RefPat {
3163 type Repr = rowan::SyntaxNode;
3166 impl AstNode for RefPat {
3167 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3168 match syntax.kind() {
3169 REF_PAT => Some(RefPat::from_repr(syntax.into_repr())),
3173 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3176 impl ToOwned for RefPat {
3177 type Owned = TreeArc<RefPat>;
3178 fn to_owned(&self) -> TreeArc<RefPat> { TreeArc::cast(self.syntax.to_owned()) }
3183 pub fn pat(&self) -> Option<&Pat> {
3184 super::child_opt(self)
3189 #[derive(Debug, PartialEq, Eq, Hash)]
3190 #[repr(transparent)]
3191 pub struct ReferenceType {
3192 pub(crate) syntax: SyntaxNode,
3194 unsafe impl TransparentNewType for ReferenceType {
3195 type Repr = rowan::SyntaxNode;
3198 impl AstNode for ReferenceType {
3199 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3200 match syntax.kind() {
3201 REFERENCE_TYPE => Some(ReferenceType::from_repr(syntax.into_repr())),
3205 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3208 impl ToOwned for ReferenceType {
3209 type Owned = TreeArc<ReferenceType>;
3210 fn to_owned(&self) -> TreeArc<ReferenceType> { TreeArc::cast(self.syntax.to_owned()) }
3214 impl ReferenceType {
3215 pub fn type_ref(&self) -> Option<&TypeRef> {
3216 super::child_opt(self)
3221 #[derive(Debug, PartialEq, Eq, Hash)]
3222 #[repr(transparent)]
3223 pub struct RetType {
3224 pub(crate) syntax: SyntaxNode,
3226 unsafe impl TransparentNewType for RetType {
3227 type Repr = rowan::SyntaxNode;
3230 impl AstNode for RetType {
3231 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3232 match syntax.kind() {
3233 RET_TYPE => Some(RetType::from_repr(syntax.into_repr())),
3237 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3240 impl ToOwned for RetType {
3241 type Owned = TreeArc<RetType>;
3242 fn to_owned(&self) -> TreeArc<RetType> { TreeArc::cast(self.syntax.to_owned()) }
3247 pub fn type_ref(&self) -> Option<&TypeRef> {
3248 super::child_opt(self)
3253 #[derive(Debug, PartialEq, Eq, Hash)]
3254 #[repr(transparent)]
3255 pub struct ReturnExpr {
3256 pub(crate) syntax: SyntaxNode,
3258 unsafe impl TransparentNewType for ReturnExpr {
3259 type Repr = rowan::SyntaxNode;
3262 impl AstNode for ReturnExpr {
3263 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3264 match syntax.kind() {
3265 RETURN_EXPR => Some(ReturnExpr::from_repr(syntax.into_repr())),
3269 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3272 impl ToOwned for ReturnExpr {
3273 type Owned = TreeArc<ReturnExpr>;
3274 fn to_owned(&self) -> TreeArc<ReturnExpr> { TreeArc::cast(self.syntax.to_owned()) }
3279 pub fn expr(&self) -> Option<&Expr> {
3280 super::child_opt(self)
3285 #[derive(Debug, PartialEq, Eq, Hash)]
3286 #[repr(transparent)]
3287 pub struct SelfParam {
3288 pub(crate) syntax: SyntaxNode,
3290 unsafe impl TransparentNewType for SelfParam {
3291 type Repr = rowan::SyntaxNode;
3294 impl AstNode for SelfParam {
3295 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3296 match syntax.kind() {
3297 SELF_PARAM => Some(SelfParam::from_repr(syntax.into_repr())),
3301 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3304 impl ToOwned for SelfParam {
3305 type Owned = TreeArc<SelfParam>;
3306 fn to_owned(&self) -> TreeArc<SelfParam> { TreeArc::cast(self.syntax.to_owned()) }
3310 impl ast::TypeAscriptionOwner for SelfParam {}
3314 #[derive(Debug, PartialEq, Eq, Hash)]
3315 #[repr(transparent)]
3316 pub struct SlicePat {
3317 pub(crate) syntax: SyntaxNode,
3319 unsafe impl TransparentNewType for SlicePat {
3320 type Repr = rowan::SyntaxNode;
3323 impl AstNode for SlicePat {
3324 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3325 match syntax.kind() {
3326 SLICE_PAT => Some(SlicePat::from_repr(syntax.into_repr())),
3330 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3333 impl ToOwned for SlicePat {
3334 type Owned = TreeArc<SlicePat>;
3335 fn to_owned(&self) -> TreeArc<SlicePat> { TreeArc::cast(self.syntax.to_owned()) }
3342 #[derive(Debug, PartialEq, Eq, Hash)]
3343 #[repr(transparent)]
3344 pub struct SliceType {
3345 pub(crate) syntax: SyntaxNode,
3347 unsafe impl TransparentNewType for SliceType {
3348 type Repr = rowan::SyntaxNode;
3351 impl AstNode for SliceType {
3352 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3353 match syntax.kind() {
3354 SLICE_TYPE => Some(SliceType::from_repr(syntax.into_repr())),
3358 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3361 impl ToOwned for SliceType {
3362 type Owned = TreeArc<SliceType>;
3363 fn to_owned(&self) -> TreeArc<SliceType> { TreeArc::cast(self.syntax.to_owned()) }
3368 pub fn type_ref(&self) -> Option<&TypeRef> {
3369 super::child_opt(self)
3374 #[derive(Debug, PartialEq, Eq, Hash)]
3375 #[repr(transparent)]
3376 pub struct SourceFile {
3377 pub(crate) syntax: SyntaxNode,
3379 unsafe impl TransparentNewType for SourceFile {
3380 type Repr = rowan::SyntaxNode;
3383 impl AstNode for SourceFile {
3384 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3385 match syntax.kind() {
3386 SOURCE_FILE => Some(SourceFile::from_repr(syntax.into_repr())),
3390 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3393 impl ToOwned for SourceFile {
3394 type Owned = TreeArc<SourceFile>;
3395 fn to_owned(&self) -> TreeArc<SourceFile> { TreeArc::cast(self.syntax.to_owned()) }
3399 impl ast::ModuleItemOwner for SourceFile {}
3400 impl ast::FnDefOwner for SourceFile {}
3402 pub fn modules(&self) -> impl Iterator<Item = &Module> {
3403 super::children(self)
3408 #[derive(Debug, PartialEq, Eq, Hash)]
3409 #[repr(transparent)]
3410 pub struct StaticDef {
3411 pub(crate) syntax: SyntaxNode,
3413 unsafe impl TransparentNewType for StaticDef {
3414 type Repr = rowan::SyntaxNode;
3417 impl AstNode for StaticDef {
3418 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3419 match syntax.kind() {
3420 STATIC_DEF => Some(StaticDef::from_repr(syntax.into_repr())),
3424 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3427 impl ToOwned for StaticDef {
3428 type Owned = TreeArc<StaticDef>;
3429 fn to_owned(&self) -> TreeArc<StaticDef> { TreeArc::cast(self.syntax.to_owned()) }
3433 impl ast::VisibilityOwner for StaticDef {}
3434 impl ast::NameOwner for StaticDef {}
3435 impl ast::TypeParamsOwner for StaticDef {}
3436 impl ast::AttrsOwner for StaticDef {}
3437 impl ast::DocCommentsOwner for StaticDef {}
3438 impl ast::TypeAscriptionOwner for StaticDef {}
3440 pub fn body(&self) -> Option<&Expr> {
3441 super::child_opt(self)
3446 #[derive(Debug, PartialEq, Eq, Hash)]
3447 #[repr(transparent)]
3449 pub(crate) syntax: SyntaxNode,
3451 unsafe impl TransparentNewType for Stmt {
3452 type Repr = rowan::SyntaxNode;
3455 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3456 pub enum StmtKind<'a> {
3457 ExprStmt(&'a ExprStmt),
3458 LetStmt(&'a LetStmt),
3460 impl<'a> From<&'a ExprStmt> for &'a Stmt {
3461 fn from(n: &'a ExprStmt) -> &'a Stmt {
3462 Stmt::cast(&n.syntax).unwrap()
3465 impl<'a> From<&'a LetStmt> for &'a Stmt {
3466 fn from(n: &'a LetStmt) -> &'a Stmt {
3467 Stmt::cast(&n.syntax).unwrap()
3472 impl AstNode for Stmt {
3473 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3474 match syntax.kind() {
3476 | LET_STMT => Some(Stmt::from_repr(syntax.into_repr())),
3480 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3483 impl ToOwned for Stmt {
3484 type Owned = TreeArc<Stmt>;
3485 fn to_owned(&self) -> TreeArc<Stmt> { TreeArc::cast(self.syntax.to_owned()) }
3489 pub fn kind(&self) -> StmtKind {
3490 match self.syntax.kind() {
3491 EXPR_STMT => StmtKind::ExprStmt(ExprStmt::cast(&self.syntax).unwrap()),
3492 LET_STMT => StmtKind::LetStmt(LetStmt::cast(&self.syntax).unwrap()),
3493 _ => unreachable!(),
3501 #[derive(Debug, PartialEq, Eq, Hash)]
3502 #[repr(transparent)]
3503 pub struct StructDef {
3504 pub(crate) syntax: SyntaxNode,
3506 unsafe impl TransparentNewType for StructDef {
3507 type Repr = rowan::SyntaxNode;
3510 impl AstNode for StructDef {
3511 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3512 match syntax.kind() {
3513 STRUCT_DEF => Some(StructDef::from_repr(syntax.into_repr())),
3517 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3520 impl ToOwned for StructDef {
3521 type Owned = TreeArc<StructDef>;
3522 fn to_owned(&self) -> TreeArc<StructDef> { TreeArc::cast(self.syntax.to_owned()) }
3526 impl ast::VisibilityOwner for StructDef {}
3527 impl ast::NameOwner for StructDef {}
3528 impl ast::TypeParamsOwner for StructDef {}
3529 impl ast::AttrsOwner for StructDef {}
3530 impl ast::DocCommentsOwner for StructDef {}
3534 #[derive(Debug, PartialEq, Eq, Hash)]
3535 #[repr(transparent)]
3536 pub struct StructLit {
3537 pub(crate) syntax: SyntaxNode,
3539 unsafe impl TransparentNewType for StructLit {
3540 type Repr = rowan::SyntaxNode;
3543 impl AstNode for StructLit {
3544 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3545 match syntax.kind() {
3546 STRUCT_LIT => Some(StructLit::from_repr(syntax.into_repr())),
3550 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3553 impl ToOwned for StructLit {
3554 type Owned = TreeArc<StructLit>;
3555 fn to_owned(&self) -> TreeArc<StructLit> { TreeArc::cast(self.syntax.to_owned()) }
3560 pub fn path(&self) -> Option<&Path> {
3561 super::child_opt(self)
3564 pub fn named_field_list(&self) -> Option<&NamedFieldList> {
3565 super::child_opt(self)
3568 pub fn spread(&self) -> Option<&Expr> {
3569 super::child_opt(self)
3574 #[derive(Debug, PartialEq, Eq, Hash)]
3575 #[repr(transparent)]
3576 pub struct StructPat {
3577 pub(crate) syntax: SyntaxNode,
3579 unsafe impl TransparentNewType for StructPat {
3580 type Repr = rowan::SyntaxNode;
3583 impl AstNode for StructPat {
3584 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3585 match syntax.kind() {
3586 STRUCT_PAT => Some(StructPat::from_repr(syntax.into_repr())),
3590 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3593 impl ToOwned for StructPat {
3594 type Owned = TreeArc<StructPat>;
3595 fn to_owned(&self) -> TreeArc<StructPat> { TreeArc::cast(self.syntax.to_owned()) }
3600 pub fn field_pat_list(&self) -> Option<&FieldPatList> {
3601 super::child_opt(self)
3604 pub fn path(&self) -> Option<&Path> {
3605 super::child_opt(self)
3610 #[derive(Debug, PartialEq, Eq, Hash)]
3611 #[repr(transparent)]
3612 pub struct TokenTree {
3613 pub(crate) syntax: SyntaxNode,
3615 unsafe impl TransparentNewType for TokenTree {
3616 type Repr = rowan::SyntaxNode;
3619 impl AstNode for TokenTree {
3620 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3621 match syntax.kind() {
3622 TOKEN_TREE => Some(TokenTree::from_repr(syntax.into_repr())),
3626 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3629 impl ToOwned for TokenTree {
3630 type Owned = TreeArc<TokenTree>;
3631 fn to_owned(&self) -> TreeArc<TokenTree> { TreeArc::cast(self.syntax.to_owned()) }
3638 #[derive(Debug, PartialEq, Eq, Hash)]
3639 #[repr(transparent)]
3640 pub struct TraitDef {
3641 pub(crate) syntax: SyntaxNode,
3643 unsafe impl TransparentNewType for TraitDef {
3644 type Repr = rowan::SyntaxNode;
3647 impl AstNode for TraitDef {
3648 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3649 match syntax.kind() {
3650 TRAIT_DEF => Some(TraitDef::from_repr(syntax.into_repr())),
3654 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3657 impl ToOwned for TraitDef {
3658 type Owned = TreeArc<TraitDef>;
3659 fn to_owned(&self) -> TreeArc<TraitDef> { TreeArc::cast(self.syntax.to_owned()) }
3663 impl ast::VisibilityOwner for TraitDef {}
3664 impl ast::NameOwner for TraitDef {}
3665 impl ast::AttrsOwner for TraitDef {}
3666 impl ast::DocCommentsOwner for TraitDef {}
3667 impl ast::TypeParamsOwner for TraitDef {}
3668 impl ast::TypeBoundsOwner for TraitDef {}
3670 pub fn item_list(&self) -> Option<&ItemList> {
3671 super::child_opt(self)
3676 #[derive(Debug, PartialEq, Eq, Hash)]
3677 #[repr(transparent)]
3678 pub struct TryExpr {
3679 pub(crate) syntax: SyntaxNode,
3681 unsafe impl TransparentNewType for TryExpr {
3682 type Repr = rowan::SyntaxNode;
3685 impl AstNode for TryExpr {
3686 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3687 match syntax.kind() {
3688 TRY_EXPR => Some(TryExpr::from_repr(syntax.into_repr())),
3692 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3695 impl ToOwned for TryExpr {
3696 type Owned = TreeArc<TryExpr>;
3697 fn to_owned(&self) -> TreeArc<TryExpr> { TreeArc::cast(self.syntax.to_owned()) }
3702 pub fn expr(&self) -> Option<&Expr> {
3703 super::child_opt(self)
3708 #[derive(Debug, PartialEq, Eq, Hash)]
3709 #[repr(transparent)]
3710 pub struct TupleExpr {
3711 pub(crate) syntax: SyntaxNode,
3713 unsafe impl TransparentNewType for TupleExpr {
3714 type Repr = rowan::SyntaxNode;
3717 impl AstNode for TupleExpr {
3718 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3719 match syntax.kind() {
3720 TUPLE_EXPR => Some(TupleExpr::from_repr(syntax.into_repr())),
3724 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3727 impl ToOwned for TupleExpr {
3728 type Owned = TreeArc<TupleExpr>;
3729 fn to_owned(&self) -> TreeArc<TupleExpr> { TreeArc::cast(self.syntax.to_owned()) }
3734 pub fn exprs(&self) -> impl Iterator<Item = &Expr> {
3735 super::children(self)
3740 #[derive(Debug, PartialEq, Eq, Hash)]
3741 #[repr(transparent)]
3742 pub struct TuplePat {
3743 pub(crate) syntax: SyntaxNode,
3745 unsafe impl TransparentNewType for TuplePat {
3746 type Repr = rowan::SyntaxNode;
3749 impl AstNode for TuplePat {
3750 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3751 match syntax.kind() {
3752 TUPLE_PAT => Some(TuplePat::from_repr(syntax.into_repr())),
3756 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3759 impl ToOwned for TuplePat {
3760 type Owned = TreeArc<TuplePat>;
3761 fn to_owned(&self) -> TreeArc<TuplePat> { TreeArc::cast(self.syntax.to_owned()) }
3766 pub fn args(&self) -> impl Iterator<Item = &Pat> {
3767 super::children(self)
3772 #[derive(Debug, PartialEq, Eq, Hash)]
3773 #[repr(transparent)]
3774 pub struct TupleStructPat {
3775 pub(crate) syntax: SyntaxNode,
3777 unsafe impl TransparentNewType for TupleStructPat {
3778 type Repr = rowan::SyntaxNode;
3781 impl AstNode for TupleStructPat {
3782 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3783 match syntax.kind() {
3784 TUPLE_STRUCT_PAT => Some(TupleStructPat::from_repr(syntax.into_repr())),
3788 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3791 impl ToOwned for TupleStructPat {
3792 type Owned = TreeArc<TupleStructPat>;
3793 fn to_owned(&self) -> TreeArc<TupleStructPat> { TreeArc::cast(self.syntax.to_owned()) }
3797 impl TupleStructPat {
3798 pub fn args(&self) -> impl Iterator<Item = &Pat> {
3799 super::children(self)
3802 pub fn path(&self) -> Option<&Path> {
3803 super::child_opt(self)
3808 #[derive(Debug, PartialEq, Eq, Hash)]
3809 #[repr(transparent)]
3810 pub struct TupleType {
3811 pub(crate) syntax: SyntaxNode,
3813 unsafe impl TransparentNewType for TupleType {
3814 type Repr = rowan::SyntaxNode;
3817 impl AstNode for TupleType {
3818 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3819 match syntax.kind() {
3820 TUPLE_TYPE => Some(TupleType::from_repr(syntax.into_repr())),
3824 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3827 impl ToOwned for TupleType {
3828 type Owned = TreeArc<TupleType>;
3829 fn to_owned(&self) -> TreeArc<TupleType> { TreeArc::cast(self.syntax.to_owned()) }
3834 pub fn fields(&self) -> impl Iterator<Item = &TypeRef> {
3835 super::children(self)
3840 #[derive(Debug, PartialEq, Eq, Hash)]
3841 #[repr(transparent)]
3842 pub struct TypeAliasDef {
3843 pub(crate) syntax: SyntaxNode,
3845 unsafe impl TransparentNewType for TypeAliasDef {
3846 type Repr = rowan::SyntaxNode;
3849 impl AstNode for TypeAliasDef {
3850 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3851 match syntax.kind() {
3852 TYPE_ALIAS_DEF => Some(TypeAliasDef::from_repr(syntax.into_repr())),
3856 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3859 impl ToOwned for TypeAliasDef {
3860 type Owned = TreeArc<TypeAliasDef>;
3861 fn to_owned(&self) -> TreeArc<TypeAliasDef> { TreeArc::cast(self.syntax.to_owned()) }
3865 impl ast::VisibilityOwner for TypeAliasDef {}
3866 impl ast::NameOwner for TypeAliasDef {}
3867 impl ast::TypeParamsOwner for TypeAliasDef {}
3868 impl ast::AttrsOwner for TypeAliasDef {}
3869 impl ast::DocCommentsOwner for TypeAliasDef {}
3870 impl ast::TypeBoundsOwner for TypeAliasDef {}
3872 pub fn type_ref(&self) -> Option<&TypeRef> {
3873 super::child_opt(self)
3878 #[derive(Debug, PartialEq, Eq, Hash)]
3879 #[repr(transparent)]
3880 pub struct TypeArg {
3881 pub(crate) syntax: SyntaxNode,
3883 unsafe impl TransparentNewType for TypeArg {
3884 type Repr = rowan::SyntaxNode;
3887 impl AstNode for TypeArg {
3888 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3889 match syntax.kind() {
3890 TYPE_ARG => Some(TypeArg::from_repr(syntax.into_repr())),
3894 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3897 impl ToOwned for TypeArg {
3898 type Owned = TreeArc<TypeArg>;
3899 fn to_owned(&self) -> TreeArc<TypeArg> { TreeArc::cast(self.syntax.to_owned()) }
3904 pub fn type_ref(&self) -> Option<&TypeRef> {
3905 super::child_opt(self)
3910 #[derive(Debug, PartialEq, Eq, Hash)]
3911 #[repr(transparent)]
3912 pub struct TypeArgList {
3913 pub(crate) syntax: SyntaxNode,
3915 unsafe impl TransparentNewType for TypeArgList {
3916 type Repr = rowan::SyntaxNode;
3919 impl AstNode for TypeArgList {
3920 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3921 match syntax.kind() {
3922 TYPE_ARG_LIST => Some(TypeArgList::from_repr(syntax.into_repr())),
3926 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3929 impl ToOwned for TypeArgList {
3930 type Owned = TreeArc<TypeArgList>;
3931 fn to_owned(&self) -> TreeArc<TypeArgList> { TreeArc::cast(self.syntax.to_owned()) }
3936 pub fn type_args(&self) -> impl Iterator<Item = &TypeArg> {
3937 super::children(self)
3940 pub fn lifetime_args(&self) -> impl Iterator<Item = &LifetimeArg> {
3941 super::children(self)
3944 pub fn assoc_type_args(&self) -> impl Iterator<Item = &AssocTypeArg> {
3945 super::children(self)
3950 #[derive(Debug, PartialEq, Eq, Hash)]
3951 #[repr(transparent)]
3952 pub struct TypeBound {
3953 pub(crate) syntax: SyntaxNode,
3955 unsafe impl TransparentNewType for TypeBound {
3956 type Repr = rowan::SyntaxNode;
3959 impl AstNode for TypeBound {
3960 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3961 match syntax.kind() {
3962 TYPE_BOUND => Some(TypeBound::from_repr(syntax.into_repr())),
3966 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3969 impl ToOwned for TypeBound {
3970 type Owned = TreeArc<TypeBound>;
3971 fn to_owned(&self) -> TreeArc<TypeBound> { TreeArc::cast(self.syntax.to_owned()) }
3976 pub fn type_ref(&self) -> Option<&TypeRef> {
3977 super::child_opt(self)
3982 #[derive(Debug, PartialEq, Eq, Hash)]
3983 #[repr(transparent)]
3984 pub struct TypeBoundList {
3985 pub(crate) syntax: SyntaxNode,
3987 unsafe impl TransparentNewType for TypeBoundList {
3988 type Repr = rowan::SyntaxNode;
3991 impl AstNode for TypeBoundList {
3992 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3993 match syntax.kind() {
3994 TYPE_BOUND_LIST => Some(TypeBoundList::from_repr(syntax.into_repr())),
3998 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4001 impl ToOwned for TypeBoundList {
4002 type Owned = TreeArc<TypeBoundList>;
4003 fn to_owned(&self) -> TreeArc<TypeBoundList> { TreeArc::cast(self.syntax.to_owned()) }
4007 impl TypeBoundList {
4008 pub fn bounds(&self) -> impl Iterator<Item = &TypeBound> {
4009 super::children(self)
4014 #[derive(Debug, PartialEq, Eq, Hash)]
4015 #[repr(transparent)]
4016 pub struct TypeParam {
4017 pub(crate) syntax: SyntaxNode,
4019 unsafe impl TransparentNewType for TypeParam {
4020 type Repr = rowan::SyntaxNode;
4023 impl AstNode for TypeParam {
4024 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4025 match syntax.kind() {
4026 TYPE_PARAM => Some(TypeParam::from_repr(syntax.into_repr())),
4030 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4033 impl ToOwned for TypeParam {
4034 type Owned = TreeArc<TypeParam>;
4035 fn to_owned(&self) -> TreeArc<TypeParam> { TreeArc::cast(self.syntax.to_owned()) }
4039 impl ast::NameOwner for TypeParam {}
4040 impl ast::AttrsOwner for TypeParam {}
4041 impl ast::TypeBoundsOwner for TypeParam {}
4045 #[derive(Debug, PartialEq, Eq, Hash)]
4046 #[repr(transparent)]
4047 pub struct TypeParamList {
4048 pub(crate) syntax: SyntaxNode,
4050 unsafe impl TransparentNewType for TypeParamList {
4051 type Repr = rowan::SyntaxNode;
4054 impl AstNode for TypeParamList {
4055 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4056 match syntax.kind() {
4057 TYPE_PARAM_LIST => Some(TypeParamList::from_repr(syntax.into_repr())),
4061 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4064 impl ToOwned for TypeParamList {
4065 type Owned = TreeArc<TypeParamList>;
4066 fn to_owned(&self) -> TreeArc<TypeParamList> { TreeArc::cast(self.syntax.to_owned()) }
4070 impl TypeParamList {
4071 pub fn type_params(&self) -> impl Iterator<Item = &TypeParam> {
4072 super::children(self)
4075 pub fn lifetime_params(&self) -> impl Iterator<Item = &LifetimeParam> {
4076 super::children(self)
4081 #[derive(Debug, PartialEq, Eq, Hash)]
4082 #[repr(transparent)]
4083 pub struct TypeRef {
4084 pub(crate) syntax: SyntaxNode,
4086 unsafe impl TransparentNewType for TypeRef {
4087 type Repr = rowan::SyntaxNode;
4090 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4091 pub enum TypeRefKind<'a> {
4092 ParenType(&'a ParenType),
4093 TupleType(&'a TupleType),
4094 NeverType(&'a NeverType),
4095 PathType(&'a PathType),
4096 PointerType(&'a PointerType),
4097 ArrayType(&'a ArrayType),
4098 SliceType(&'a SliceType),
4099 ReferenceType(&'a ReferenceType),
4100 PlaceholderType(&'a PlaceholderType),
4101 FnPointerType(&'a FnPointerType),
4102 ForType(&'a ForType),
4103 ImplTraitType(&'a ImplTraitType),
4104 DynTraitType(&'a DynTraitType),
4106 impl<'a> From<&'a ParenType> for &'a TypeRef {
4107 fn from(n: &'a ParenType) -> &'a TypeRef {
4108 TypeRef::cast(&n.syntax).unwrap()
4111 impl<'a> From<&'a TupleType> for &'a TypeRef {
4112 fn from(n: &'a TupleType) -> &'a TypeRef {
4113 TypeRef::cast(&n.syntax).unwrap()
4116 impl<'a> From<&'a NeverType> for &'a TypeRef {
4117 fn from(n: &'a NeverType) -> &'a TypeRef {
4118 TypeRef::cast(&n.syntax).unwrap()
4121 impl<'a> From<&'a PathType> for &'a TypeRef {
4122 fn from(n: &'a PathType) -> &'a TypeRef {
4123 TypeRef::cast(&n.syntax).unwrap()
4126 impl<'a> From<&'a PointerType> for &'a TypeRef {
4127 fn from(n: &'a PointerType) -> &'a TypeRef {
4128 TypeRef::cast(&n.syntax).unwrap()
4131 impl<'a> From<&'a ArrayType> for &'a TypeRef {
4132 fn from(n: &'a ArrayType) -> &'a TypeRef {
4133 TypeRef::cast(&n.syntax).unwrap()
4136 impl<'a> From<&'a SliceType> for &'a TypeRef {
4137 fn from(n: &'a SliceType) -> &'a TypeRef {
4138 TypeRef::cast(&n.syntax).unwrap()
4141 impl<'a> From<&'a ReferenceType> for &'a TypeRef {
4142 fn from(n: &'a ReferenceType) -> &'a TypeRef {
4143 TypeRef::cast(&n.syntax).unwrap()
4146 impl<'a> From<&'a PlaceholderType> for &'a TypeRef {
4147 fn from(n: &'a PlaceholderType) -> &'a TypeRef {
4148 TypeRef::cast(&n.syntax).unwrap()
4151 impl<'a> From<&'a FnPointerType> for &'a TypeRef {
4152 fn from(n: &'a FnPointerType) -> &'a TypeRef {
4153 TypeRef::cast(&n.syntax).unwrap()
4156 impl<'a> From<&'a ForType> for &'a TypeRef {
4157 fn from(n: &'a ForType) -> &'a TypeRef {
4158 TypeRef::cast(&n.syntax).unwrap()
4161 impl<'a> From<&'a ImplTraitType> for &'a TypeRef {
4162 fn from(n: &'a ImplTraitType) -> &'a TypeRef {
4163 TypeRef::cast(&n.syntax).unwrap()
4166 impl<'a> From<&'a DynTraitType> for &'a TypeRef {
4167 fn from(n: &'a DynTraitType) -> &'a TypeRef {
4168 TypeRef::cast(&n.syntax).unwrap()
4173 impl AstNode for TypeRef {
4174 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4175 match syntax.kind() {
4188 | DYN_TRAIT_TYPE => Some(TypeRef::from_repr(syntax.into_repr())),
4192 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4195 impl ToOwned for TypeRef {
4196 type Owned = TreeArc<TypeRef>;
4197 fn to_owned(&self) -> TreeArc<TypeRef> { TreeArc::cast(self.syntax.to_owned()) }
4201 pub fn kind(&self) -> TypeRefKind {
4202 match self.syntax.kind() {
4203 PAREN_TYPE => TypeRefKind::ParenType(ParenType::cast(&self.syntax).unwrap()),
4204 TUPLE_TYPE => TypeRefKind::TupleType(TupleType::cast(&self.syntax).unwrap()),
4205 NEVER_TYPE => TypeRefKind::NeverType(NeverType::cast(&self.syntax).unwrap()),
4206 PATH_TYPE => TypeRefKind::PathType(PathType::cast(&self.syntax).unwrap()),
4207 POINTER_TYPE => TypeRefKind::PointerType(PointerType::cast(&self.syntax).unwrap()),
4208 ARRAY_TYPE => TypeRefKind::ArrayType(ArrayType::cast(&self.syntax).unwrap()),
4209 SLICE_TYPE => TypeRefKind::SliceType(SliceType::cast(&self.syntax).unwrap()),
4210 REFERENCE_TYPE => TypeRefKind::ReferenceType(ReferenceType::cast(&self.syntax).unwrap()),
4211 PLACEHOLDER_TYPE => TypeRefKind::PlaceholderType(PlaceholderType::cast(&self.syntax).unwrap()),
4212 FN_POINTER_TYPE => TypeRefKind::FnPointerType(FnPointerType::cast(&self.syntax).unwrap()),
4213 FOR_TYPE => TypeRefKind::ForType(ForType::cast(&self.syntax).unwrap()),
4214 IMPL_TRAIT_TYPE => TypeRefKind::ImplTraitType(ImplTraitType::cast(&self.syntax).unwrap()),
4215 DYN_TRAIT_TYPE => TypeRefKind::DynTraitType(DynTraitType::cast(&self.syntax).unwrap()),
4216 _ => unreachable!(),
4224 #[derive(Debug, PartialEq, Eq, Hash)]
4225 #[repr(transparent)]
4226 pub struct UseItem {
4227 pub(crate) syntax: SyntaxNode,
4229 unsafe impl TransparentNewType for UseItem {
4230 type Repr = rowan::SyntaxNode;
4233 impl AstNode for UseItem {
4234 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4235 match syntax.kind() {
4236 USE_ITEM => Some(UseItem::from_repr(syntax.into_repr())),
4240 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4243 impl ToOwned for UseItem {
4244 type Owned = TreeArc<UseItem>;
4245 fn to_owned(&self) -> TreeArc<UseItem> { TreeArc::cast(self.syntax.to_owned()) }
4249 impl ast::AttrsOwner for UseItem {}
4251 pub fn use_tree(&self) -> Option<&UseTree> {
4252 super::child_opt(self)
4257 #[derive(Debug, PartialEq, Eq, Hash)]
4258 #[repr(transparent)]
4259 pub struct UseTree {
4260 pub(crate) syntax: SyntaxNode,
4262 unsafe impl TransparentNewType for UseTree {
4263 type Repr = rowan::SyntaxNode;
4266 impl AstNode for UseTree {
4267 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4268 match syntax.kind() {
4269 USE_TREE => Some(UseTree::from_repr(syntax.into_repr())),
4273 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4276 impl ToOwned for UseTree {
4277 type Owned = TreeArc<UseTree>;
4278 fn to_owned(&self) -> TreeArc<UseTree> { TreeArc::cast(self.syntax.to_owned()) }
4283 pub fn path(&self) -> Option<&Path> {
4284 super::child_opt(self)
4287 pub fn use_tree_list(&self) -> Option<&UseTreeList> {
4288 super::child_opt(self)
4291 pub fn alias(&self) -> Option<&Alias> {
4292 super::child_opt(self)
4297 #[derive(Debug, PartialEq, Eq, Hash)]
4298 #[repr(transparent)]
4299 pub struct UseTreeList {
4300 pub(crate) syntax: SyntaxNode,
4302 unsafe impl TransparentNewType for UseTreeList {
4303 type Repr = rowan::SyntaxNode;
4306 impl AstNode for UseTreeList {
4307 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4308 match syntax.kind() {
4309 USE_TREE_LIST => Some(UseTreeList::from_repr(syntax.into_repr())),
4313 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4316 impl ToOwned for UseTreeList {
4317 type Owned = TreeArc<UseTreeList>;
4318 fn to_owned(&self) -> TreeArc<UseTreeList> { TreeArc::cast(self.syntax.to_owned()) }
4323 pub fn use_trees(&self) -> impl Iterator<Item = &UseTree> {
4324 super::children(self)
4329 #[derive(Debug, PartialEq, Eq, Hash)]
4330 #[repr(transparent)]
4331 pub struct Visibility {
4332 pub(crate) syntax: SyntaxNode,
4334 unsafe impl TransparentNewType for Visibility {
4335 type Repr = rowan::SyntaxNode;
4338 impl AstNode for Visibility {
4339 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4340 match syntax.kind() {
4341 VISIBILITY => Some(Visibility::from_repr(syntax.into_repr())),
4345 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4348 impl ToOwned for Visibility {
4349 type Owned = TreeArc<Visibility>;
4350 fn to_owned(&self) -> TreeArc<Visibility> { TreeArc::cast(self.syntax.to_owned()) }
4357 #[derive(Debug, PartialEq, Eq, Hash)]
4358 #[repr(transparent)]
4359 pub struct WhereClause {
4360 pub(crate) syntax: SyntaxNode,
4362 unsafe impl TransparentNewType for WhereClause {
4363 type Repr = rowan::SyntaxNode;
4366 impl AstNode for WhereClause {
4367 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4368 match syntax.kind() {
4369 WHERE_CLAUSE => Some(WhereClause::from_repr(syntax.into_repr())),
4373 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4376 impl ToOwned for WhereClause {
4377 type Owned = TreeArc<WhereClause>;
4378 fn to_owned(&self) -> TreeArc<WhereClause> { TreeArc::cast(self.syntax.to_owned()) }
4383 pub fn predicates(&self) -> impl Iterator<Item = &WherePred> {
4384 super::children(self)
4389 #[derive(Debug, PartialEq, Eq, Hash)]
4390 #[repr(transparent)]
4391 pub struct WherePred {
4392 pub(crate) syntax: SyntaxNode,
4394 unsafe impl TransparentNewType for WherePred {
4395 type Repr = rowan::SyntaxNode;
4398 impl AstNode for WherePred {
4399 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4400 match syntax.kind() {
4401 WHERE_PRED => Some(WherePred::from_repr(syntax.into_repr())),
4405 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4408 impl ToOwned for WherePred {
4409 type Owned = TreeArc<WherePred>;
4410 fn to_owned(&self) -> TreeArc<WherePred> { TreeArc::cast(self.syntax.to_owned()) }
4414 impl ast::TypeBoundsOwner for WherePred {}
4416 pub fn type_ref(&self) -> Option<&TypeRef> {
4417 super::child_opt(self)
4422 #[derive(Debug, PartialEq, Eq, Hash)]
4423 #[repr(transparent)]
4424 pub struct WhileExpr {
4425 pub(crate) syntax: SyntaxNode,
4427 unsafe impl TransparentNewType for WhileExpr {
4428 type Repr = rowan::SyntaxNode;
4431 impl AstNode for WhileExpr {
4432 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4433 match syntax.kind() {
4434 WHILE_EXPR => Some(WhileExpr::from_repr(syntax.into_repr())),
4438 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4441 impl ToOwned for WhileExpr {
4442 type Owned = TreeArc<WhileExpr>;
4443 fn to_owned(&self) -> TreeArc<WhileExpr> { TreeArc::cast(self.syntax.to_owned()) }
4447 impl ast::LoopBodyOwner for WhileExpr {}
4449 pub fn condition(&self) -> Option<&Condition> {
4450 super::child_opt(self)