1 // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run
2 // Do not edit manually
4 //! This module contains auto-generated Rust AST. Like `SyntaxNode`s, AST nodes
5 //! are generic over ownership: `X<'a>` things are `Copy` references, `XNode`
6 //! are Arc-based. You can switch between the two variants using `.owned` and
7 //! `.borrowed` functions. Most of the code works with borowed mode, and only
8 //! this mode has all AST accessors.
10 #![cfg_attr(rustfmt, rustfmt_skip)]
12 use rowan::TransparentNewType;
15 SyntaxNode, SyntaxKind::*,
16 syntax_node::{TreeArc},
21 #[derive(Debug, PartialEq, Eq, Hash)]
24 pub(crate) syntax: SyntaxNode,
26 unsafe impl TransparentNewType for Alias {
27 type Repr = rowan::SyntaxNode;
30 impl AstNode for Alias {
31 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
33 ALIAS => Some(Alias::from_repr(syntax.into_repr())),
37 fn syntax(&self) -> &SyntaxNode { &self.syntax }
40 impl ToOwned for Alias {
41 type Owned = TreeArc<Alias>;
42 fn to_owned(&self) -> TreeArc<Alias> { TreeArc::cast(self.syntax.to_owned()) }
46 impl ast::NameOwner for Alias {}
50 #[derive(Debug, PartialEq, Eq, Hash)]
53 pub(crate) syntax: SyntaxNode,
55 unsafe impl TransparentNewType for ArgList {
56 type Repr = rowan::SyntaxNode;
59 impl AstNode for ArgList {
60 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
62 ARG_LIST => Some(ArgList::from_repr(syntax.into_repr())),
66 fn syntax(&self) -> &SyntaxNode { &self.syntax }
69 impl ToOwned for ArgList {
70 type Owned = TreeArc<ArgList>;
71 fn to_owned(&self) -> TreeArc<ArgList> { TreeArc::cast(self.syntax.to_owned()) }
76 pub fn args(&self) -> impl Iterator<Item = &Expr> {
82 #[derive(Debug, PartialEq, Eq, Hash)]
84 pub struct ArrayExpr {
85 pub(crate) syntax: SyntaxNode,
87 unsafe impl TransparentNewType for ArrayExpr {
88 type Repr = rowan::SyntaxNode;
91 impl AstNode for ArrayExpr {
92 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
94 ARRAY_EXPR => Some(ArrayExpr::from_repr(syntax.into_repr())),
98 fn syntax(&self) -> &SyntaxNode { &self.syntax }
101 impl ToOwned for ArrayExpr {
102 type Owned = TreeArc<ArrayExpr>;
103 fn to_owned(&self) -> TreeArc<ArrayExpr> { TreeArc::cast(self.syntax.to_owned()) }
108 pub fn exprs(&self) -> impl Iterator<Item = &Expr> {
109 super::children(self)
114 #[derive(Debug, PartialEq, Eq, Hash)]
116 pub struct ArrayType {
117 pub(crate) syntax: SyntaxNode,
119 unsafe impl TransparentNewType for ArrayType {
120 type Repr = rowan::SyntaxNode;
123 impl AstNode for ArrayType {
124 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
125 match syntax.kind() {
126 ARRAY_TYPE => Some(ArrayType::from_repr(syntax.into_repr())),
130 fn syntax(&self) -> &SyntaxNode { &self.syntax }
133 impl ToOwned for ArrayType {
134 type Owned = TreeArc<ArrayType>;
135 fn to_owned(&self) -> TreeArc<ArrayType> { TreeArc::cast(self.syntax.to_owned()) }
140 pub fn type_ref(&self) -> Option<&TypeRef> {
141 super::child_opt(self)
144 pub fn expr(&self) -> Option<&Expr> {
145 super::child_opt(self)
150 #[derive(Debug, PartialEq, Eq, Hash)]
152 pub struct AssocTypeArg {
153 pub(crate) syntax: SyntaxNode,
155 unsafe impl TransparentNewType for AssocTypeArg {
156 type Repr = rowan::SyntaxNode;
159 impl AstNode for AssocTypeArg {
160 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
161 match syntax.kind() {
162 ASSOC_TYPE_ARG => Some(AssocTypeArg::from_repr(syntax.into_repr())),
166 fn syntax(&self) -> &SyntaxNode { &self.syntax }
169 impl ToOwned for AssocTypeArg {
170 type Owned = TreeArc<AssocTypeArg>;
171 fn to_owned(&self) -> TreeArc<AssocTypeArg> { TreeArc::cast(self.syntax.to_owned()) }
176 pub fn name_ref(&self) -> Option<&NameRef> {
177 super::child_opt(self)
180 pub fn type_ref(&self) -> Option<&TypeRef> {
181 super::child_opt(self)
186 #[derive(Debug, PartialEq, Eq, Hash)]
189 pub(crate) syntax: SyntaxNode,
191 unsafe impl TransparentNewType for Attr {
192 type Repr = rowan::SyntaxNode;
195 impl AstNode for Attr {
196 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
197 match syntax.kind() {
198 ATTR => Some(Attr::from_repr(syntax.into_repr())),
202 fn syntax(&self) -> &SyntaxNode { &self.syntax }
205 impl ToOwned for Attr {
206 type Owned = TreeArc<Attr>;
207 fn to_owned(&self) -> TreeArc<Attr> { TreeArc::cast(self.syntax.to_owned()) }
212 pub fn value(&self) -> Option<&TokenTree> {
213 super::child_opt(self)
218 #[derive(Debug, PartialEq, Eq, Hash)]
221 pub(crate) syntax: SyntaxNode,
223 unsafe impl TransparentNewType for BinExpr {
224 type Repr = rowan::SyntaxNode;
227 impl AstNode for BinExpr {
228 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
229 match syntax.kind() {
230 BIN_EXPR => Some(BinExpr::from_repr(syntax.into_repr())),
234 fn syntax(&self) -> &SyntaxNode { &self.syntax }
237 impl ToOwned for BinExpr {
238 type Owned = TreeArc<BinExpr>;
239 fn to_owned(&self) -> TreeArc<BinExpr> { TreeArc::cast(self.syntax.to_owned()) }
246 #[derive(Debug, PartialEq, Eq, Hash)]
249 pub(crate) syntax: SyntaxNode,
251 unsafe impl TransparentNewType for BindPat {
252 type Repr = rowan::SyntaxNode;
255 impl AstNode for BindPat {
256 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
257 match syntax.kind() {
258 BIND_PAT => Some(BindPat::from_repr(syntax.into_repr())),
262 fn syntax(&self) -> &SyntaxNode { &self.syntax }
265 impl ToOwned for BindPat {
266 type Owned = TreeArc<BindPat>;
267 fn to_owned(&self) -> TreeArc<BindPat> { TreeArc::cast(self.syntax.to_owned()) }
271 impl ast::NameOwner for BindPat {}
273 pub fn pat(&self) -> Option<&Pat> {
274 super::child_opt(self)
279 #[derive(Debug, PartialEq, Eq, Hash)]
282 pub(crate) syntax: SyntaxNode,
284 unsafe impl TransparentNewType for Block {
285 type Repr = rowan::SyntaxNode;
288 impl AstNode for Block {
289 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
290 match syntax.kind() {
291 BLOCK => Some(Block::from_repr(syntax.into_repr())),
295 fn syntax(&self) -> &SyntaxNode { &self.syntax }
298 impl ToOwned for Block {
299 type Owned = TreeArc<Block>;
300 fn to_owned(&self) -> TreeArc<Block> { TreeArc::cast(self.syntax.to_owned()) }
304 impl ast::AttrsOwner for Block {}
306 pub fn statements(&self) -> impl Iterator<Item = &Stmt> {
307 super::children(self)
310 pub fn expr(&self) -> Option<&Expr> {
311 super::child_opt(self)
316 #[derive(Debug, PartialEq, Eq, Hash)]
318 pub struct BlockExpr {
319 pub(crate) syntax: SyntaxNode,
321 unsafe impl TransparentNewType for BlockExpr {
322 type Repr = rowan::SyntaxNode;
325 impl AstNode for BlockExpr {
326 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
327 match syntax.kind() {
328 BLOCK_EXPR => Some(BlockExpr::from_repr(syntax.into_repr())),
332 fn syntax(&self) -> &SyntaxNode { &self.syntax }
335 impl ToOwned for BlockExpr {
336 type Owned = TreeArc<BlockExpr>;
337 fn to_owned(&self) -> TreeArc<BlockExpr> { TreeArc::cast(self.syntax.to_owned()) }
342 pub fn block(&self) -> Option<&Block> {
343 super::child_opt(self)
348 #[derive(Debug, PartialEq, Eq, Hash)]
350 pub struct BreakExpr {
351 pub(crate) syntax: SyntaxNode,
353 unsafe impl TransparentNewType for BreakExpr {
354 type Repr = rowan::SyntaxNode;
357 impl AstNode for BreakExpr {
358 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
359 match syntax.kind() {
360 BREAK_EXPR => Some(BreakExpr::from_repr(syntax.into_repr())),
364 fn syntax(&self) -> &SyntaxNode { &self.syntax }
367 impl ToOwned for BreakExpr {
368 type Owned = TreeArc<BreakExpr>;
369 fn to_owned(&self) -> TreeArc<BreakExpr> { TreeArc::cast(self.syntax.to_owned()) }
374 pub fn expr(&self) -> Option<&Expr> {
375 super::child_opt(self)
380 #[derive(Debug, PartialEq, Eq, Hash)]
382 pub struct CallExpr {
383 pub(crate) syntax: SyntaxNode,
385 unsafe impl TransparentNewType for CallExpr {
386 type Repr = rowan::SyntaxNode;
389 impl AstNode for CallExpr {
390 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
391 match syntax.kind() {
392 CALL_EXPR => Some(CallExpr::from_repr(syntax.into_repr())),
396 fn syntax(&self) -> &SyntaxNode { &self.syntax }
399 impl ToOwned for CallExpr {
400 type Owned = TreeArc<CallExpr>;
401 fn to_owned(&self) -> TreeArc<CallExpr> { TreeArc::cast(self.syntax.to_owned()) }
405 impl ast::ArgListOwner for CallExpr {}
407 pub fn expr(&self) -> Option<&Expr> {
408 super::child_opt(self)
413 #[derive(Debug, PartialEq, Eq, Hash)]
415 pub struct CastExpr {
416 pub(crate) syntax: SyntaxNode,
418 unsafe impl TransparentNewType for CastExpr {
419 type Repr = rowan::SyntaxNode;
422 impl AstNode for CastExpr {
423 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
424 match syntax.kind() {
425 CAST_EXPR => Some(CastExpr::from_repr(syntax.into_repr())),
429 fn syntax(&self) -> &SyntaxNode { &self.syntax }
432 impl ToOwned for CastExpr {
433 type Owned = TreeArc<CastExpr>;
434 fn to_owned(&self) -> TreeArc<CastExpr> { TreeArc::cast(self.syntax.to_owned()) }
439 pub fn expr(&self) -> Option<&Expr> {
440 super::child_opt(self)
443 pub fn type_ref(&self) -> Option<&TypeRef> {
444 super::child_opt(self)
449 #[derive(Debug, PartialEq, Eq, Hash)]
451 pub struct Condition {
452 pub(crate) syntax: SyntaxNode,
454 unsafe impl TransparentNewType for Condition {
455 type Repr = rowan::SyntaxNode;
458 impl AstNode for Condition {
459 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
460 match syntax.kind() {
461 CONDITION => Some(Condition::from_repr(syntax.into_repr())),
465 fn syntax(&self) -> &SyntaxNode { &self.syntax }
468 impl ToOwned for Condition {
469 type Owned = TreeArc<Condition>;
470 fn to_owned(&self) -> TreeArc<Condition> { TreeArc::cast(self.syntax.to_owned()) }
475 pub fn pat(&self) -> Option<&Pat> {
476 super::child_opt(self)
479 pub fn expr(&self) -> Option<&Expr> {
480 super::child_opt(self)
485 #[derive(Debug, PartialEq, Eq, Hash)]
487 pub struct ConstDef {
488 pub(crate) syntax: SyntaxNode,
490 unsafe impl TransparentNewType for ConstDef {
491 type Repr = rowan::SyntaxNode;
494 impl AstNode for ConstDef {
495 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
496 match syntax.kind() {
497 CONST_DEF => Some(ConstDef::from_repr(syntax.into_repr())),
501 fn syntax(&self) -> &SyntaxNode { &self.syntax }
504 impl ToOwned for ConstDef {
505 type Owned = TreeArc<ConstDef>;
506 fn to_owned(&self) -> TreeArc<ConstDef> { TreeArc::cast(self.syntax.to_owned()) }
510 impl ast::VisibilityOwner for ConstDef {}
511 impl ast::NameOwner for ConstDef {}
512 impl ast::TypeParamsOwner for ConstDef {}
513 impl ast::AttrsOwner for ConstDef {}
514 impl ast::DocCommentsOwner for ConstDef {}
515 impl ast::TypeAscriptionOwner for ConstDef {}
517 pub fn body(&self) -> Option<&Expr> {
518 super::child_opt(self)
523 #[derive(Debug, PartialEq, Eq, Hash)]
525 pub struct ContinueExpr {
526 pub(crate) syntax: SyntaxNode,
528 unsafe impl TransparentNewType for ContinueExpr {
529 type Repr = rowan::SyntaxNode;
532 impl AstNode for ContinueExpr {
533 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
534 match syntax.kind() {
535 CONTINUE_EXPR => Some(ContinueExpr::from_repr(syntax.into_repr())),
539 fn syntax(&self) -> &SyntaxNode { &self.syntax }
542 impl ToOwned for ContinueExpr {
543 type Owned = TreeArc<ContinueExpr>;
544 fn to_owned(&self) -> TreeArc<ContinueExpr> { TreeArc::cast(self.syntax.to_owned()) }
551 #[derive(Debug, PartialEq, Eq, Hash)]
553 pub struct DynTraitType {
554 pub(crate) syntax: SyntaxNode,
556 unsafe impl TransparentNewType for DynTraitType {
557 type Repr = rowan::SyntaxNode;
560 impl AstNode for DynTraitType {
561 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
562 match syntax.kind() {
563 DYN_TRAIT_TYPE => Some(DynTraitType::from_repr(syntax.into_repr())),
567 fn syntax(&self) -> &SyntaxNode { &self.syntax }
570 impl ToOwned for DynTraitType {
571 type Owned = TreeArc<DynTraitType>;
572 fn to_owned(&self) -> TreeArc<DynTraitType> { TreeArc::cast(self.syntax.to_owned()) }
576 impl ast::TypeBoundsOwner for DynTraitType {}
580 #[derive(Debug, PartialEq, Eq, Hash)]
583 pub(crate) syntax: SyntaxNode,
585 unsafe impl TransparentNewType for EnumDef {
586 type Repr = rowan::SyntaxNode;
589 impl AstNode for EnumDef {
590 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
591 match syntax.kind() {
592 ENUM_DEF => Some(EnumDef::from_repr(syntax.into_repr())),
596 fn syntax(&self) -> &SyntaxNode { &self.syntax }
599 impl ToOwned for EnumDef {
600 type Owned = TreeArc<EnumDef>;
601 fn to_owned(&self) -> TreeArc<EnumDef> { TreeArc::cast(self.syntax.to_owned()) }
605 impl ast::VisibilityOwner for EnumDef {}
606 impl ast::NameOwner for EnumDef {}
607 impl ast::TypeParamsOwner for EnumDef {}
608 impl ast::AttrsOwner for EnumDef {}
609 impl ast::DocCommentsOwner for EnumDef {}
611 pub fn variant_list(&self) -> Option<&EnumVariantList> {
612 super::child_opt(self)
617 #[derive(Debug, PartialEq, Eq, Hash)]
619 pub struct EnumVariant {
620 pub(crate) syntax: SyntaxNode,
622 unsafe impl TransparentNewType for EnumVariant {
623 type Repr = rowan::SyntaxNode;
626 impl AstNode for EnumVariant {
627 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
628 match syntax.kind() {
629 ENUM_VARIANT => Some(EnumVariant::from_repr(syntax.into_repr())),
633 fn syntax(&self) -> &SyntaxNode { &self.syntax }
636 impl ToOwned for EnumVariant {
637 type Owned = TreeArc<EnumVariant>;
638 fn to_owned(&self) -> TreeArc<EnumVariant> { TreeArc::cast(self.syntax.to_owned()) }
642 impl ast::NameOwner for EnumVariant {}
643 impl ast::DocCommentsOwner for EnumVariant {}
644 impl ast::AttrsOwner for EnumVariant {}
646 pub fn expr(&self) -> Option<&Expr> {
647 super::child_opt(self)
652 #[derive(Debug, PartialEq, Eq, Hash)]
654 pub struct EnumVariantList {
655 pub(crate) syntax: SyntaxNode,
657 unsafe impl TransparentNewType for EnumVariantList {
658 type Repr = rowan::SyntaxNode;
661 impl AstNode for EnumVariantList {
662 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
663 match syntax.kind() {
664 ENUM_VARIANT_LIST => Some(EnumVariantList::from_repr(syntax.into_repr())),
668 fn syntax(&self) -> &SyntaxNode { &self.syntax }
671 impl ToOwned for EnumVariantList {
672 type Owned = TreeArc<EnumVariantList>;
673 fn to_owned(&self) -> TreeArc<EnumVariantList> { TreeArc::cast(self.syntax.to_owned()) }
677 impl EnumVariantList {
678 pub fn variants(&self) -> impl Iterator<Item = &EnumVariant> {
679 super::children(self)
684 #[derive(Debug, PartialEq, Eq, Hash)]
687 pub(crate) syntax: SyntaxNode,
689 unsafe impl TransparentNewType for Expr {
690 type Repr = rowan::SyntaxNode;
693 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
694 pub enum ExprKind<'a> {
695 TupleExpr(&'a TupleExpr),
696 ArrayExpr(&'a ArrayExpr),
697 ParenExpr(&'a ParenExpr),
698 PathExpr(&'a PathExpr),
699 LambdaExpr(&'a LambdaExpr),
701 LoopExpr(&'a LoopExpr),
702 ForExpr(&'a ForExpr),
703 WhileExpr(&'a WhileExpr),
704 ContinueExpr(&'a ContinueExpr),
705 BreakExpr(&'a BreakExpr),
707 BlockExpr(&'a BlockExpr),
708 ReturnExpr(&'a ReturnExpr),
709 MatchExpr(&'a MatchExpr),
710 StructLit(&'a StructLit),
711 CallExpr(&'a CallExpr),
712 IndexExpr(&'a IndexExpr),
713 MethodCallExpr(&'a MethodCallExpr),
714 FieldExpr(&'a FieldExpr),
715 TryExpr(&'a TryExpr),
716 CastExpr(&'a CastExpr),
717 RefExpr(&'a RefExpr),
718 PrefixExpr(&'a PrefixExpr),
719 RangeExpr(&'a RangeExpr),
720 BinExpr(&'a BinExpr),
721 Literal(&'a Literal),
722 MacroCall(&'a MacroCall),
724 impl<'a> From<&'a TupleExpr> for &'a Expr {
725 fn from(n: &'a TupleExpr) -> &'a Expr {
726 Expr::cast(&n.syntax).unwrap()
729 impl<'a> From<&'a ArrayExpr> for &'a Expr {
730 fn from(n: &'a ArrayExpr) -> &'a Expr {
731 Expr::cast(&n.syntax).unwrap()
734 impl<'a> From<&'a ParenExpr> for &'a Expr {
735 fn from(n: &'a ParenExpr) -> &'a Expr {
736 Expr::cast(&n.syntax).unwrap()
739 impl<'a> From<&'a PathExpr> for &'a Expr {
740 fn from(n: &'a PathExpr) -> &'a Expr {
741 Expr::cast(&n.syntax).unwrap()
744 impl<'a> From<&'a LambdaExpr> for &'a Expr {
745 fn from(n: &'a LambdaExpr) -> &'a Expr {
746 Expr::cast(&n.syntax).unwrap()
749 impl<'a> From<&'a IfExpr> for &'a Expr {
750 fn from(n: &'a IfExpr) -> &'a Expr {
751 Expr::cast(&n.syntax).unwrap()
754 impl<'a> From<&'a LoopExpr> for &'a Expr {
755 fn from(n: &'a LoopExpr) -> &'a Expr {
756 Expr::cast(&n.syntax).unwrap()
759 impl<'a> From<&'a ForExpr> for &'a Expr {
760 fn from(n: &'a ForExpr) -> &'a Expr {
761 Expr::cast(&n.syntax).unwrap()
764 impl<'a> From<&'a WhileExpr> for &'a Expr {
765 fn from(n: &'a WhileExpr) -> &'a Expr {
766 Expr::cast(&n.syntax).unwrap()
769 impl<'a> From<&'a ContinueExpr> for &'a Expr {
770 fn from(n: &'a ContinueExpr) -> &'a Expr {
771 Expr::cast(&n.syntax).unwrap()
774 impl<'a> From<&'a BreakExpr> for &'a Expr {
775 fn from(n: &'a BreakExpr) -> &'a Expr {
776 Expr::cast(&n.syntax).unwrap()
779 impl<'a> From<&'a Label> for &'a Expr {
780 fn from(n: &'a Label) -> &'a Expr {
781 Expr::cast(&n.syntax).unwrap()
784 impl<'a> From<&'a BlockExpr> for &'a Expr {
785 fn from(n: &'a BlockExpr) -> &'a Expr {
786 Expr::cast(&n.syntax).unwrap()
789 impl<'a> From<&'a ReturnExpr> for &'a Expr {
790 fn from(n: &'a ReturnExpr) -> &'a Expr {
791 Expr::cast(&n.syntax).unwrap()
794 impl<'a> From<&'a MatchExpr> for &'a Expr {
795 fn from(n: &'a MatchExpr) -> &'a Expr {
796 Expr::cast(&n.syntax).unwrap()
799 impl<'a> From<&'a StructLit> for &'a Expr {
800 fn from(n: &'a StructLit) -> &'a Expr {
801 Expr::cast(&n.syntax).unwrap()
804 impl<'a> From<&'a CallExpr> for &'a Expr {
805 fn from(n: &'a CallExpr) -> &'a Expr {
806 Expr::cast(&n.syntax).unwrap()
809 impl<'a> From<&'a IndexExpr> for &'a Expr {
810 fn from(n: &'a IndexExpr) -> &'a Expr {
811 Expr::cast(&n.syntax).unwrap()
814 impl<'a> From<&'a MethodCallExpr> for &'a Expr {
815 fn from(n: &'a MethodCallExpr) -> &'a Expr {
816 Expr::cast(&n.syntax).unwrap()
819 impl<'a> From<&'a FieldExpr> for &'a Expr {
820 fn from(n: &'a FieldExpr) -> &'a Expr {
821 Expr::cast(&n.syntax).unwrap()
824 impl<'a> From<&'a TryExpr> for &'a Expr {
825 fn from(n: &'a TryExpr) -> &'a Expr {
826 Expr::cast(&n.syntax).unwrap()
829 impl<'a> From<&'a CastExpr> for &'a Expr {
830 fn from(n: &'a CastExpr) -> &'a Expr {
831 Expr::cast(&n.syntax).unwrap()
834 impl<'a> From<&'a RefExpr> for &'a Expr {
835 fn from(n: &'a RefExpr) -> &'a Expr {
836 Expr::cast(&n.syntax).unwrap()
839 impl<'a> From<&'a PrefixExpr> for &'a Expr {
840 fn from(n: &'a PrefixExpr) -> &'a Expr {
841 Expr::cast(&n.syntax).unwrap()
844 impl<'a> From<&'a RangeExpr> for &'a Expr {
845 fn from(n: &'a RangeExpr) -> &'a Expr {
846 Expr::cast(&n.syntax).unwrap()
849 impl<'a> From<&'a BinExpr> for &'a Expr {
850 fn from(n: &'a BinExpr) -> &'a Expr {
851 Expr::cast(&n.syntax).unwrap()
854 impl<'a> From<&'a Literal> for &'a Expr {
855 fn from(n: &'a Literal) -> &'a Expr {
856 Expr::cast(&n.syntax).unwrap()
859 impl<'a> From<&'a MacroCall> for &'a Expr {
860 fn from(n: &'a MacroCall) -> &'a Expr {
861 Expr::cast(&n.syntax).unwrap()
866 impl AstNode for Expr {
867 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
868 match syntax.kind() {
896 | MACRO_CALL => Some(Expr::from_repr(syntax.into_repr())),
900 fn syntax(&self) -> &SyntaxNode { &self.syntax }
903 impl ToOwned for Expr {
904 type Owned = TreeArc<Expr>;
905 fn to_owned(&self) -> TreeArc<Expr> { TreeArc::cast(self.syntax.to_owned()) }
909 pub fn kind(&self) -> ExprKind {
910 match self.syntax.kind() {
911 TUPLE_EXPR => ExprKind::TupleExpr(TupleExpr::cast(&self.syntax).unwrap()),
912 ARRAY_EXPR => ExprKind::ArrayExpr(ArrayExpr::cast(&self.syntax).unwrap()),
913 PAREN_EXPR => ExprKind::ParenExpr(ParenExpr::cast(&self.syntax).unwrap()),
914 PATH_EXPR => ExprKind::PathExpr(PathExpr::cast(&self.syntax).unwrap()),
915 LAMBDA_EXPR => ExprKind::LambdaExpr(LambdaExpr::cast(&self.syntax).unwrap()),
916 IF_EXPR => ExprKind::IfExpr(IfExpr::cast(&self.syntax).unwrap()),
917 LOOP_EXPR => ExprKind::LoopExpr(LoopExpr::cast(&self.syntax).unwrap()),
918 FOR_EXPR => ExprKind::ForExpr(ForExpr::cast(&self.syntax).unwrap()),
919 WHILE_EXPR => ExprKind::WhileExpr(WhileExpr::cast(&self.syntax).unwrap()),
920 CONTINUE_EXPR => ExprKind::ContinueExpr(ContinueExpr::cast(&self.syntax).unwrap()),
921 BREAK_EXPR => ExprKind::BreakExpr(BreakExpr::cast(&self.syntax).unwrap()),
922 LABEL => ExprKind::Label(Label::cast(&self.syntax).unwrap()),
923 BLOCK_EXPR => ExprKind::BlockExpr(BlockExpr::cast(&self.syntax).unwrap()),
924 RETURN_EXPR => ExprKind::ReturnExpr(ReturnExpr::cast(&self.syntax).unwrap()),
925 MATCH_EXPR => ExprKind::MatchExpr(MatchExpr::cast(&self.syntax).unwrap()),
926 STRUCT_LIT => ExprKind::StructLit(StructLit::cast(&self.syntax).unwrap()),
927 CALL_EXPR => ExprKind::CallExpr(CallExpr::cast(&self.syntax).unwrap()),
928 INDEX_EXPR => ExprKind::IndexExpr(IndexExpr::cast(&self.syntax).unwrap()),
929 METHOD_CALL_EXPR => ExprKind::MethodCallExpr(MethodCallExpr::cast(&self.syntax).unwrap()),
930 FIELD_EXPR => ExprKind::FieldExpr(FieldExpr::cast(&self.syntax).unwrap()),
931 TRY_EXPR => ExprKind::TryExpr(TryExpr::cast(&self.syntax).unwrap()),
932 CAST_EXPR => ExprKind::CastExpr(CastExpr::cast(&self.syntax).unwrap()),
933 REF_EXPR => ExprKind::RefExpr(RefExpr::cast(&self.syntax).unwrap()),
934 PREFIX_EXPR => ExprKind::PrefixExpr(PrefixExpr::cast(&self.syntax).unwrap()),
935 RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(&self.syntax).unwrap()),
936 BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(&self.syntax).unwrap()),
937 LITERAL => ExprKind::Literal(Literal::cast(&self.syntax).unwrap()),
938 MACRO_CALL => ExprKind::MacroCall(MacroCall::cast(&self.syntax).unwrap()),
947 #[derive(Debug, PartialEq, Eq, Hash)]
949 pub struct ExprStmt {
950 pub(crate) syntax: SyntaxNode,
952 unsafe impl TransparentNewType for ExprStmt {
953 type Repr = rowan::SyntaxNode;
956 impl AstNode for ExprStmt {
957 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
958 match syntax.kind() {
959 EXPR_STMT => Some(ExprStmt::from_repr(syntax.into_repr())),
963 fn syntax(&self) -> &SyntaxNode { &self.syntax }
966 impl ToOwned for ExprStmt {
967 type Owned = TreeArc<ExprStmt>;
968 fn to_owned(&self) -> TreeArc<ExprStmt> { TreeArc::cast(self.syntax.to_owned()) }
973 pub fn expr(&self) -> Option<&Expr> {
974 super::child_opt(self)
979 #[derive(Debug, PartialEq, Eq, Hash)]
981 pub struct ExternCrateItem {
982 pub(crate) syntax: SyntaxNode,
984 unsafe impl TransparentNewType for ExternCrateItem {
985 type Repr = rowan::SyntaxNode;
988 impl AstNode for ExternCrateItem {
989 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
990 match syntax.kind() {
991 EXTERN_CRATE_ITEM => Some(ExternCrateItem::from_repr(syntax.into_repr())),
995 fn syntax(&self) -> &SyntaxNode { &self.syntax }
998 impl ToOwned for ExternCrateItem {
999 type Owned = TreeArc<ExternCrateItem>;
1000 fn to_owned(&self) -> TreeArc<ExternCrateItem> { TreeArc::cast(self.syntax.to_owned()) }
1004 impl ExternCrateItem {
1005 pub fn name_ref(&self) -> Option<&NameRef> {
1006 super::child_opt(self)
1009 pub fn alias(&self) -> Option<&Alias> {
1010 super::child_opt(self)
1015 #[derive(Debug, PartialEq, Eq, Hash)]
1016 #[repr(transparent)]
1017 pub struct FieldExpr {
1018 pub(crate) syntax: SyntaxNode,
1020 unsafe impl TransparentNewType for FieldExpr {
1021 type Repr = rowan::SyntaxNode;
1024 impl AstNode for FieldExpr {
1025 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1026 match syntax.kind() {
1027 FIELD_EXPR => Some(FieldExpr::from_repr(syntax.into_repr())),
1031 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1034 impl ToOwned for FieldExpr {
1035 type Owned = TreeArc<FieldExpr>;
1036 fn to_owned(&self) -> TreeArc<FieldExpr> { TreeArc::cast(self.syntax.to_owned()) }
1041 pub fn expr(&self) -> Option<&Expr> {
1042 super::child_opt(self)
1045 pub fn name_ref(&self) -> Option<&NameRef> {
1046 super::child_opt(self)
1051 #[derive(Debug, PartialEq, Eq, Hash)]
1052 #[repr(transparent)]
1053 pub struct FieldPat {
1054 pub(crate) syntax: SyntaxNode,
1056 unsafe impl TransparentNewType for FieldPat {
1057 type Repr = rowan::SyntaxNode;
1060 impl AstNode for FieldPat {
1061 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1062 match syntax.kind() {
1063 FIELD_PAT => Some(FieldPat::from_repr(syntax.into_repr())),
1067 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1070 impl ToOwned for FieldPat {
1071 type Owned = TreeArc<FieldPat>;
1072 fn to_owned(&self) -> TreeArc<FieldPat> { TreeArc::cast(self.syntax.to_owned()) }
1076 impl ast::NameOwner for FieldPat {}
1078 pub fn pat(&self) -> Option<&Pat> {
1079 super::child_opt(self)
1084 #[derive(Debug, PartialEq, Eq, Hash)]
1085 #[repr(transparent)]
1086 pub struct FieldPatList {
1087 pub(crate) syntax: SyntaxNode,
1089 unsafe impl TransparentNewType for FieldPatList {
1090 type Repr = rowan::SyntaxNode;
1093 impl AstNode for FieldPatList {
1094 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1095 match syntax.kind() {
1096 FIELD_PAT_LIST => Some(FieldPatList::from_repr(syntax.into_repr())),
1100 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1103 impl ToOwned for FieldPatList {
1104 type Owned = TreeArc<FieldPatList>;
1105 fn to_owned(&self) -> TreeArc<FieldPatList> { TreeArc::cast(self.syntax.to_owned()) }
1110 pub fn field_pats(&self) -> impl Iterator<Item = &FieldPat> {
1111 super::children(self)
1114 pub fn bind_pats(&self) -> impl Iterator<Item = &BindPat> {
1115 super::children(self)
1120 #[derive(Debug, PartialEq, Eq, Hash)]
1121 #[repr(transparent)]
1123 pub(crate) syntax: SyntaxNode,
1125 unsafe impl TransparentNewType for FnDef {
1126 type Repr = rowan::SyntaxNode;
1129 impl AstNode for FnDef {
1130 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1131 match syntax.kind() {
1132 FN_DEF => Some(FnDef::from_repr(syntax.into_repr())),
1136 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1139 impl ToOwned for FnDef {
1140 type Owned = TreeArc<FnDef>;
1141 fn to_owned(&self) -> TreeArc<FnDef> { TreeArc::cast(self.syntax.to_owned()) }
1145 impl ast::VisibilityOwner for FnDef {}
1146 impl ast::NameOwner for FnDef {}
1147 impl ast::TypeParamsOwner for FnDef {}
1148 impl ast::AttrsOwner for FnDef {}
1149 impl ast::DocCommentsOwner for FnDef {}
1151 pub fn param_list(&self) -> Option<&ParamList> {
1152 super::child_opt(self)
1155 pub fn body(&self) -> Option<&Block> {
1156 super::child_opt(self)
1159 pub fn ret_type(&self) -> Option<&RetType> {
1160 super::child_opt(self)
1165 #[derive(Debug, PartialEq, Eq, Hash)]
1166 #[repr(transparent)]
1167 pub struct FnPointerType {
1168 pub(crate) syntax: SyntaxNode,
1170 unsafe impl TransparentNewType for FnPointerType {
1171 type Repr = rowan::SyntaxNode;
1174 impl AstNode for FnPointerType {
1175 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1176 match syntax.kind() {
1177 FN_POINTER_TYPE => Some(FnPointerType::from_repr(syntax.into_repr())),
1181 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1184 impl ToOwned for FnPointerType {
1185 type Owned = TreeArc<FnPointerType>;
1186 fn to_owned(&self) -> TreeArc<FnPointerType> { TreeArc::cast(self.syntax.to_owned()) }
1190 impl FnPointerType {
1191 pub fn param_list(&self) -> Option<&ParamList> {
1192 super::child_opt(self)
1195 pub fn ret_type(&self) -> Option<&RetType> {
1196 super::child_opt(self)
1201 #[derive(Debug, PartialEq, Eq, Hash)]
1202 #[repr(transparent)]
1203 pub struct ForExpr {
1204 pub(crate) syntax: SyntaxNode,
1206 unsafe impl TransparentNewType for ForExpr {
1207 type Repr = rowan::SyntaxNode;
1210 impl AstNode for ForExpr {
1211 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1212 match syntax.kind() {
1213 FOR_EXPR => Some(ForExpr::from_repr(syntax.into_repr())),
1217 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1220 impl ToOwned for ForExpr {
1221 type Owned = TreeArc<ForExpr>;
1222 fn to_owned(&self) -> TreeArc<ForExpr> { TreeArc::cast(self.syntax.to_owned()) }
1226 impl ast::LoopBodyOwner for ForExpr {}
1228 pub fn pat(&self) -> Option<&Pat> {
1229 super::child_opt(self)
1232 pub fn iterable(&self) -> Option<&Expr> {
1233 super::child_opt(self)
1238 #[derive(Debug, PartialEq, Eq, Hash)]
1239 #[repr(transparent)]
1240 pub struct ForType {
1241 pub(crate) syntax: SyntaxNode,
1243 unsafe impl TransparentNewType for ForType {
1244 type Repr = rowan::SyntaxNode;
1247 impl AstNode for ForType {
1248 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1249 match syntax.kind() {
1250 FOR_TYPE => Some(ForType::from_repr(syntax.into_repr())),
1254 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1257 impl ToOwned for ForType {
1258 type Owned = TreeArc<ForType>;
1259 fn to_owned(&self) -> TreeArc<ForType> { TreeArc::cast(self.syntax.to_owned()) }
1264 pub fn type_ref(&self) -> Option<&TypeRef> {
1265 super::child_opt(self)
1270 #[derive(Debug, PartialEq, Eq, Hash)]
1271 #[repr(transparent)]
1273 pub(crate) syntax: SyntaxNode,
1275 unsafe impl TransparentNewType for IfExpr {
1276 type Repr = rowan::SyntaxNode;
1279 impl AstNode for IfExpr {
1280 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1281 match syntax.kind() {
1282 IF_EXPR => Some(IfExpr::from_repr(syntax.into_repr())),
1286 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1289 impl ToOwned for IfExpr {
1290 type Owned = TreeArc<IfExpr>;
1291 fn to_owned(&self) -> TreeArc<IfExpr> { TreeArc::cast(self.syntax.to_owned()) }
1296 pub fn condition(&self) -> Option<&Condition> {
1297 super::child_opt(self)
1302 #[derive(Debug, PartialEq, Eq, Hash)]
1303 #[repr(transparent)]
1304 pub struct ImplBlock {
1305 pub(crate) syntax: SyntaxNode,
1307 unsafe impl TransparentNewType for ImplBlock {
1308 type Repr = rowan::SyntaxNode;
1311 impl AstNode for ImplBlock {
1312 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1313 match syntax.kind() {
1314 IMPL_BLOCK => Some(ImplBlock::from_repr(syntax.into_repr())),
1318 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1321 impl ToOwned for ImplBlock {
1322 type Owned = TreeArc<ImplBlock>;
1323 fn to_owned(&self) -> TreeArc<ImplBlock> { TreeArc::cast(self.syntax.to_owned()) }
1327 impl ast::TypeParamsOwner for ImplBlock {}
1328 impl ast::AttrsOwner for ImplBlock {}
1330 pub fn item_list(&self) -> Option<&ItemList> {
1331 super::child_opt(self)
1336 #[derive(Debug, PartialEq, Eq, Hash)]
1337 #[repr(transparent)]
1338 pub struct ImplItem {
1339 pub(crate) syntax: SyntaxNode,
1341 unsafe impl TransparentNewType for ImplItem {
1342 type Repr = rowan::SyntaxNode;
1345 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1346 pub enum ImplItemKind<'a> {
1348 TypeAliasDef(&'a TypeAliasDef),
1349 ConstDef(&'a ConstDef),
1351 impl<'a> From<&'a FnDef> for &'a ImplItem {
1352 fn from(n: &'a FnDef) -> &'a ImplItem {
1353 ImplItem::cast(&n.syntax).unwrap()
1356 impl<'a> From<&'a TypeAliasDef> for &'a ImplItem {
1357 fn from(n: &'a TypeAliasDef) -> &'a ImplItem {
1358 ImplItem::cast(&n.syntax).unwrap()
1361 impl<'a> From<&'a ConstDef> for &'a ImplItem {
1362 fn from(n: &'a ConstDef) -> &'a ImplItem {
1363 ImplItem::cast(&n.syntax).unwrap()
1368 impl AstNode for ImplItem {
1369 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1370 match syntax.kind() {
1373 | CONST_DEF => Some(ImplItem::from_repr(syntax.into_repr())),
1377 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1380 impl ToOwned for ImplItem {
1381 type Owned = TreeArc<ImplItem>;
1382 fn to_owned(&self) -> TreeArc<ImplItem> { TreeArc::cast(self.syntax.to_owned()) }
1386 pub fn kind(&self) -> ImplItemKind {
1387 match self.syntax.kind() {
1388 FN_DEF => ImplItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
1389 TYPE_ALIAS_DEF => ImplItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
1390 CONST_DEF => ImplItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
1391 _ => unreachable!(),
1399 #[derive(Debug, PartialEq, Eq, Hash)]
1400 #[repr(transparent)]
1401 pub struct ImplTraitType {
1402 pub(crate) syntax: SyntaxNode,
1404 unsafe impl TransparentNewType for ImplTraitType {
1405 type Repr = rowan::SyntaxNode;
1408 impl AstNode for ImplTraitType {
1409 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1410 match syntax.kind() {
1411 IMPL_TRAIT_TYPE => Some(ImplTraitType::from_repr(syntax.into_repr())),
1415 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1418 impl ToOwned for ImplTraitType {
1419 type Owned = TreeArc<ImplTraitType>;
1420 fn to_owned(&self) -> TreeArc<ImplTraitType> { TreeArc::cast(self.syntax.to_owned()) }
1424 impl ast::TypeBoundsOwner for ImplTraitType {}
1425 impl ImplTraitType {}
1428 #[derive(Debug, PartialEq, Eq, Hash)]
1429 #[repr(transparent)]
1430 pub struct IndexExpr {
1431 pub(crate) syntax: SyntaxNode,
1433 unsafe impl TransparentNewType for IndexExpr {
1434 type Repr = rowan::SyntaxNode;
1437 impl AstNode for IndexExpr {
1438 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1439 match syntax.kind() {
1440 INDEX_EXPR => Some(IndexExpr::from_repr(syntax.into_repr())),
1444 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1447 impl ToOwned for IndexExpr {
1448 type Owned = TreeArc<IndexExpr>;
1449 fn to_owned(&self) -> TreeArc<IndexExpr> { TreeArc::cast(self.syntax.to_owned()) }
1456 #[derive(Debug, PartialEq, Eq, Hash)]
1457 #[repr(transparent)]
1458 pub struct ItemList {
1459 pub(crate) syntax: SyntaxNode,
1461 unsafe impl TransparentNewType for ItemList {
1462 type Repr = rowan::SyntaxNode;
1465 impl AstNode for ItemList {
1466 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1467 match syntax.kind() {
1468 ITEM_LIST => Some(ItemList::from_repr(syntax.into_repr())),
1472 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1475 impl ToOwned for ItemList {
1476 type Owned = TreeArc<ItemList>;
1477 fn to_owned(&self) -> TreeArc<ItemList> { TreeArc::cast(self.syntax.to_owned()) }
1481 impl ast::FnDefOwner for ItemList {}
1482 impl ast::ModuleItemOwner for ItemList {}
1484 pub fn impl_items(&self) -> impl Iterator<Item = &ImplItem> {
1485 super::children(self)
1490 #[derive(Debug, PartialEq, Eq, Hash)]
1491 #[repr(transparent)]
1493 pub(crate) syntax: SyntaxNode,
1495 unsafe impl TransparentNewType for Label {
1496 type Repr = rowan::SyntaxNode;
1499 impl AstNode for Label {
1500 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1501 match syntax.kind() {
1502 LABEL => Some(Label::from_repr(syntax.into_repr())),
1506 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1509 impl ToOwned for Label {
1510 type Owned = TreeArc<Label>;
1511 fn to_owned(&self) -> TreeArc<Label> { TreeArc::cast(self.syntax.to_owned()) }
1518 #[derive(Debug, PartialEq, Eq, Hash)]
1519 #[repr(transparent)]
1520 pub struct LambdaExpr {
1521 pub(crate) syntax: SyntaxNode,
1523 unsafe impl TransparentNewType for LambdaExpr {
1524 type Repr = rowan::SyntaxNode;
1527 impl AstNode for LambdaExpr {
1528 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1529 match syntax.kind() {
1530 LAMBDA_EXPR => Some(LambdaExpr::from_repr(syntax.into_repr())),
1534 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1537 impl ToOwned for LambdaExpr {
1538 type Owned = TreeArc<LambdaExpr>;
1539 fn to_owned(&self) -> TreeArc<LambdaExpr> { TreeArc::cast(self.syntax.to_owned()) }
1544 pub fn param_list(&self) -> Option<&ParamList> {
1545 super::child_opt(self)
1548 pub fn body(&self) -> Option<&Expr> {
1549 super::child_opt(self)
1554 #[derive(Debug, PartialEq, Eq, Hash)]
1555 #[repr(transparent)]
1556 pub struct LetStmt {
1557 pub(crate) syntax: SyntaxNode,
1559 unsafe impl TransparentNewType for LetStmt {
1560 type Repr = rowan::SyntaxNode;
1563 impl AstNode for LetStmt {
1564 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1565 match syntax.kind() {
1566 LET_STMT => Some(LetStmt::from_repr(syntax.into_repr())),
1570 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1573 impl ToOwned for LetStmt {
1574 type Owned = TreeArc<LetStmt>;
1575 fn to_owned(&self) -> TreeArc<LetStmt> { TreeArc::cast(self.syntax.to_owned()) }
1579 impl ast::TypeAscriptionOwner for LetStmt {}
1581 pub fn pat(&self) -> Option<&Pat> {
1582 super::child_opt(self)
1585 pub fn initializer(&self) -> Option<&Expr> {
1586 super::child_opt(self)
1591 #[derive(Debug, PartialEq, Eq, Hash)]
1592 #[repr(transparent)]
1593 pub struct LifetimeArg {
1594 pub(crate) syntax: SyntaxNode,
1596 unsafe impl TransparentNewType for LifetimeArg {
1597 type Repr = rowan::SyntaxNode;
1600 impl AstNode for LifetimeArg {
1601 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1602 match syntax.kind() {
1603 LIFETIME_ARG => Some(LifetimeArg::from_repr(syntax.into_repr())),
1607 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1610 impl ToOwned for LifetimeArg {
1611 type Owned = TreeArc<LifetimeArg>;
1612 fn to_owned(&self) -> TreeArc<LifetimeArg> { TreeArc::cast(self.syntax.to_owned()) }
1619 #[derive(Debug, PartialEq, Eq, Hash)]
1620 #[repr(transparent)]
1621 pub struct LifetimeParam {
1622 pub(crate) syntax: SyntaxNode,
1624 unsafe impl TransparentNewType for LifetimeParam {
1625 type Repr = rowan::SyntaxNode;
1628 impl AstNode for LifetimeParam {
1629 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1630 match syntax.kind() {
1631 LIFETIME_PARAM => Some(LifetimeParam::from_repr(syntax.into_repr())),
1635 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1638 impl ToOwned for LifetimeParam {
1639 type Owned = TreeArc<LifetimeParam>;
1640 fn to_owned(&self) -> TreeArc<LifetimeParam> { TreeArc::cast(self.syntax.to_owned()) }
1644 impl ast::AttrsOwner for LifetimeParam {}
1645 impl LifetimeParam {}
1648 #[derive(Debug, PartialEq, Eq, Hash)]
1649 #[repr(transparent)]
1650 pub struct Literal {
1651 pub(crate) syntax: SyntaxNode,
1653 unsafe impl TransparentNewType for Literal {
1654 type Repr = rowan::SyntaxNode;
1657 impl AstNode for Literal {
1658 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1659 match syntax.kind() {
1660 LITERAL => Some(Literal::from_repr(syntax.into_repr())),
1664 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1667 impl ToOwned for Literal {
1668 type Owned = TreeArc<Literal>;
1669 fn to_owned(&self) -> TreeArc<Literal> { TreeArc::cast(self.syntax.to_owned()) }
1676 #[derive(Debug, PartialEq, Eq, Hash)]
1677 #[repr(transparent)]
1678 pub struct LiteralPat {
1679 pub(crate) syntax: SyntaxNode,
1681 unsafe impl TransparentNewType for LiteralPat {
1682 type Repr = rowan::SyntaxNode;
1685 impl AstNode for LiteralPat {
1686 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1687 match syntax.kind() {
1688 LITERAL_PAT => Some(LiteralPat::from_repr(syntax.into_repr())),
1692 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1695 impl ToOwned for LiteralPat {
1696 type Owned = TreeArc<LiteralPat>;
1697 fn to_owned(&self) -> TreeArc<LiteralPat> { TreeArc::cast(self.syntax.to_owned()) }
1702 pub fn literal(&self) -> Option<&Literal> {
1703 super::child_opt(self)
1708 #[derive(Debug, PartialEq, Eq, Hash)]
1709 #[repr(transparent)]
1710 pub struct LoopExpr {
1711 pub(crate) syntax: SyntaxNode,
1713 unsafe impl TransparentNewType for LoopExpr {
1714 type Repr = rowan::SyntaxNode;
1717 impl AstNode for LoopExpr {
1718 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1719 match syntax.kind() {
1720 LOOP_EXPR => Some(LoopExpr::from_repr(syntax.into_repr())),
1724 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1727 impl ToOwned for LoopExpr {
1728 type Owned = TreeArc<LoopExpr>;
1729 fn to_owned(&self) -> TreeArc<LoopExpr> { TreeArc::cast(self.syntax.to_owned()) }
1733 impl ast::LoopBodyOwner for LoopExpr {}
1737 #[derive(Debug, PartialEq, Eq, Hash)]
1738 #[repr(transparent)]
1739 pub struct MacroCall {
1740 pub(crate) syntax: SyntaxNode,
1742 unsafe impl TransparentNewType for MacroCall {
1743 type Repr = rowan::SyntaxNode;
1746 impl AstNode for MacroCall {
1747 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1748 match syntax.kind() {
1749 MACRO_CALL => Some(MacroCall::from_repr(syntax.into_repr())),
1753 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1756 impl ToOwned for MacroCall {
1757 type Owned = TreeArc<MacroCall>;
1758 fn to_owned(&self) -> TreeArc<MacroCall> { TreeArc::cast(self.syntax.to_owned()) }
1762 impl ast::NameOwner for MacroCall {}
1763 impl ast::AttrsOwner for MacroCall {}
1765 pub fn token_tree(&self) -> Option<&TokenTree> {
1766 super::child_opt(self)
1769 pub fn path(&self) -> Option<&Path> {
1770 super::child_opt(self)
1775 #[derive(Debug, PartialEq, Eq, Hash)]
1776 #[repr(transparent)]
1777 pub struct MacroItems {
1778 pub(crate) syntax: SyntaxNode,
1780 unsafe impl TransparentNewType for MacroItems {
1781 type Repr = rowan::SyntaxNode;
1784 impl AstNode for MacroItems {
1785 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1786 match syntax.kind() {
1787 MACRO_ITEMS => Some(MacroItems::from_repr(syntax.into_repr())),
1791 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1794 impl ToOwned for MacroItems {
1795 type Owned = TreeArc<MacroItems>;
1796 fn to_owned(&self) -> TreeArc<MacroItems> { TreeArc::cast(self.syntax.to_owned()) }
1800 impl ast::ModuleItemOwner for MacroItems {}
1801 impl ast::FnDefOwner for MacroItems {}
1805 #[derive(Debug, PartialEq, Eq, Hash)]
1806 #[repr(transparent)]
1807 pub struct MacroStmts {
1808 pub(crate) syntax: SyntaxNode,
1810 unsafe impl TransparentNewType for MacroStmts {
1811 type Repr = rowan::SyntaxNode;
1814 impl AstNode for MacroStmts {
1815 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1816 match syntax.kind() {
1817 MACRO_STMTS => Some(MacroStmts::from_repr(syntax.into_repr())),
1821 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1824 impl ToOwned for MacroStmts {
1825 type Owned = TreeArc<MacroStmts>;
1826 fn to_owned(&self) -> TreeArc<MacroStmts> { TreeArc::cast(self.syntax.to_owned()) }
1831 pub fn statements(&self) -> impl Iterator<Item = &Stmt> {
1832 super::children(self)
1835 pub fn expr(&self) -> Option<&Expr> {
1836 super::child_opt(self)
1841 #[derive(Debug, PartialEq, Eq, Hash)]
1842 #[repr(transparent)]
1843 pub struct MatchArm {
1844 pub(crate) syntax: SyntaxNode,
1846 unsafe impl TransparentNewType for MatchArm {
1847 type Repr = rowan::SyntaxNode;
1850 impl AstNode for MatchArm {
1851 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1852 match syntax.kind() {
1853 MATCH_ARM => Some(MatchArm::from_repr(syntax.into_repr())),
1857 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1860 impl ToOwned for MatchArm {
1861 type Owned = TreeArc<MatchArm>;
1862 fn to_owned(&self) -> TreeArc<MatchArm> { TreeArc::cast(self.syntax.to_owned()) }
1866 impl ast::AttrsOwner for MatchArm {}
1868 pub fn pats(&self) -> impl Iterator<Item = &Pat> {
1869 super::children(self)
1872 pub fn guard(&self) -> Option<&MatchGuard> {
1873 super::child_opt(self)
1876 pub fn expr(&self) -> Option<&Expr> {
1877 super::child_opt(self)
1882 #[derive(Debug, PartialEq, Eq, Hash)]
1883 #[repr(transparent)]
1884 pub struct MatchArmList {
1885 pub(crate) syntax: SyntaxNode,
1887 unsafe impl TransparentNewType for MatchArmList {
1888 type Repr = rowan::SyntaxNode;
1891 impl AstNode for MatchArmList {
1892 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1893 match syntax.kind() {
1894 MATCH_ARM_LIST => Some(MatchArmList::from_repr(syntax.into_repr())),
1898 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1901 impl ToOwned for MatchArmList {
1902 type Owned = TreeArc<MatchArmList>;
1903 fn to_owned(&self) -> TreeArc<MatchArmList> { TreeArc::cast(self.syntax.to_owned()) }
1907 impl ast::AttrsOwner for MatchArmList {}
1909 pub fn arms(&self) -> impl Iterator<Item = &MatchArm> {
1910 super::children(self)
1915 #[derive(Debug, PartialEq, Eq, Hash)]
1916 #[repr(transparent)]
1917 pub struct MatchExpr {
1918 pub(crate) syntax: SyntaxNode,
1920 unsafe impl TransparentNewType for MatchExpr {
1921 type Repr = rowan::SyntaxNode;
1924 impl AstNode for MatchExpr {
1925 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1926 match syntax.kind() {
1927 MATCH_EXPR => Some(MatchExpr::from_repr(syntax.into_repr())),
1931 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1934 impl ToOwned for MatchExpr {
1935 type Owned = TreeArc<MatchExpr>;
1936 fn to_owned(&self) -> TreeArc<MatchExpr> { TreeArc::cast(self.syntax.to_owned()) }
1941 pub fn expr(&self) -> Option<&Expr> {
1942 super::child_opt(self)
1945 pub fn match_arm_list(&self) -> Option<&MatchArmList> {
1946 super::child_opt(self)
1951 #[derive(Debug, PartialEq, Eq, Hash)]
1952 #[repr(transparent)]
1953 pub struct MatchGuard {
1954 pub(crate) syntax: SyntaxNode,
1956 unsafe impl TransparentNewType for MatchGuard {
1957 type Repr = rowan::SyntaxNode;
1960 impl AstNode for MatchGuard {
1961 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1962 match syntax.kind() {
1963 MATCH_GUARD => Some(MatchGuard::from_repr(syntax.into_repr())),
1967 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1970 impl ToOwned for MatchGuard {
1971 type Owned = TreeArc<MatchGuard>;
1972 fn to_owned(&self) -> TreeArc<MatchGuard> { TreeArc::cast(self.syntax.to_owned()) }
1977 pub fn expr(&self) -> Option<&Expr> {
1978 super::child_opt(self)
1983 #[derive(Debug, PartialEq, Eq, Hash)]
1984 #[repr(transparent)]
1985 pub struct MethodCallExpr {
1986 pub(crate) syntax: SyntaxNode,
1988 unsafe impl TransparentNewType for MethodCallExpr {
1989 type Repr = rowan::SyntaxNode;
1992 impl AstNode for MethodCallExpr {
1993 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1994 match syntax.kind() {
1995 METHOD_CALL_EXPR => Some(MethodCallExpr::from_repr(syntax.into_repr())),
1999 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2002 impl ToOwned for MethodCallExpr {
2003 type Owned = TreeArc<MethodCallExpr>;
2004 fn to_owned(&self) -> TreeArc<MethodCallExpr> { TreeArc::cast(self.syntax.to_owned()) }
2008 impl ast::ArgListOwner for MethodCallExpr {}
2009 impl MethodCallExpr {
2010 pub fn expr(&self) -> Option<&Expr> {
2011 super::child_opt(self)
2014 pub fn name_ref(&self) -> Option<&NameRef> {
2015 super::child_opt(self)
2018 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
2019 super::child_opt(self)
2024 #[derive(Debug, PartialEq, Eq, Hash)]
2025 #[repr(transparent)]
2027 pub(crate) syntax: SyntaxNode,
2029 unsafe impl TransparentNewType for Module {
2030 type Repr = rowan::SyntaxNode;
2033 impl AstNode for Module {
2034 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2035 match syntax.kind() {
2036 MODULE => Some(Module::from_repr(syntax.into_repr())),
2040 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2043 impl ToOwned for Module {
2044 type Owned = TreeArc<Module>;
2045 fn to_owned(&self) -> TreeArc<Module> { TreeArc::cast(self.syntax.to_owned()) }
2049 impl ast::VisibilityOwner for Module {}
2050 impl ast::NameOwner for Module {}
2051 impl ast::AttrsOwner for Module {}
2052 impl ast::DocCommentsOwner for Module {}
2054 pub fn item_list(&self) -> Option<&ItemList> {
2055 super::child_opt(self)
2060 #[derive(Debug, PartialEq, Eq, Hash)]
2061 #[repr(transparent)]
2062 pub struct ModuleItem {
2063 pub(crate) syntax: SyntaxNode,
2065 unsafe impl TransparentNewType for ModuleItem {
2066 type Repr = rowan::SyntaxNode;
2069 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2070 pub enum ModuleItemKind<'a> {
2071 StructDef(&'a StructDef),
2072 EnumDef(&'a EnumDef),
2074 TraitDef(&'a TraitDef),
2075 TypeAliasDef(&'a TypeAliasDef),
2076 ImplBlock(&'a ImplBlock),
2077 UseItem(&'a UseItem),
2078 ExternCrateItem(&'a ExternCrateItem),
2079 ConstDef(&'a ConstDef),
2080 StaticDef(&'a StaticDef),
2083 impl<'a> From<&'a StructDef> for &'a ModuleItem {
2084 fn from(n: &'a StructDef) -> &'a ModuleItem {
2085 ModuleItem::cast(&n.syntax).unwrap()
2088 impl<'a> From<&'a EnumDef> for &'a ModuleItem {
2089 fn from(n: &'a EnumDef) -> &'a ModuleItem {
2090 ModuleItem::cast(&n.syntax).unwrap()
2093 impl<'a> From<&'a FnDef> for &'a ModuleItem {
2094 fn from(n: &'a FnDef) -> &'a ModuleItem {
2095 ModuleItem::cast(&n.syntax).unwrap()
2098 impl<'a> From<&'a TraitDef> for &'a ModuleItem {
2099 fn from(n: &'a TraitDef) -> &'a ModuleItem {
2100 ModuleItem::cast(&n.syntax).unwrap()
2103 impl<'a> From<&'a TypeAliasDef> for &'a ModuleItem {
2104 fn from(n: &'a TypeAliasDef) -> &'a ModuleItem {
2105 ModuleItem::cast(&n.syntax).unwrap()
2108 impl<'a> From<&'a ImplBlock> for &'a ModuleItem {
2109 fn from(n: &'a ImplBlock) -> &'a ModuleItem {
2110 ModuleItem::cast(&n.syntax).unwrap()
2113 impl<'a> From<&'a UseItem> for &'a ModuleItem {
2114 fn from(n: &'a UseItem) -> &'a ModuleItem {
2115 ModuleItem::cast(&n.syntax).unwrap()
2118 impl<'a> From<&'a ExternCrateItem> for &'a ModuleItem {
2119 fn from(n: &'a ExternCrateItem) -> &'a ModuleItem {
2120 ModuleItem::cast(&n.syntax).unwrap()
2123 impl<'a> From<&'a ConstDef> for &'a ModuleItem {
2124 fn from(n: &'a ConstDef) -> &'a ModuleItem {
2125 ModuleItem::cast(&n.syntax).unwrap()
2128 impl<'a> From<&'a StaticDef> for &'a ModuleItem {
2129 fn from(n: &'a StaticDef) -> &'a ModuleItem {
2130 ModuleItem::cast(&n.syntax).unwrap()
2133 impl<'a> From<&'a Module> for &'a ModuleItem {
2134 fn from(n: &'a Module) -> &'a ModuleItem {
2135 ModuleItem::cast(&n.syntax).unwrap()
2140 impl AstNode for ModuleItem {
2141 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2142 match syntax.kind() {
2153 | MODULE => Some(ModuleItem::from_repr(syntax.into_repr())),
2157 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2160 impl ToOwned for ModuleItem {
2161 type Owned = TreeArc<ModuleItem>;
2162 fn to_owned(&self) -> TreeArc<ModuleItem> { TreeArc::cast(self.syntax.to_owned()) }
2166 pub fn kind(&self) -> ModuleItemKind {
2167 match self.syntax.kind() {
2168 STRUCT_DEF => ModuleItemKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2169 ENUM_DEF => ModuleItemKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2170 FN_DEF => ModuleItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
2171 TRAIT_DEF => ModuleItemKind::TraitDef(TraitDef::cast(&self.syntax).unwrap()),
2172 TYPE_ALIAS_DEF => ModuleItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
2173 IMPL_BLOCK => ModuleItemKind::ImplBlock(ImplBlock::cast(&self.syntax).unwrap()),
2174 USE_ITEM => ModuleItemKind::UseItem(UseItem::cast(&self.syntax).unwrap()),
2175 EXTERN_CRATE_ITEM => ModuleItemKind::ExternCrateItem(ExternCrateItem::cast(&self.syntax).unwrap()),
2176 CONST_DEF => ModuleItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
2177 STATIC_DEF => ModuleItemKind::StaticDef(StaticDef::cast(&self.syntax).unwrap()),
2178 MODULE => ModuleItemKind::Module(Module::cast(&self.syntax).unwrap()),
2179 _ => unreachable!(),
2187 #[derive(Debug, PartialEq, Eq, Hash)]
2188 #[repr(transparent)]
2190 pub(crate) syntax: SyntaxNode,
2192 unsafe impl TransparentNewType for Name {
2193 type Repr = rowan::SyntaxNode;
2196 impl AstNode for Name {
2197 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2198 match syntax.kind() {
2199 NAME => Some(Name::from_repr(syntax.into_repr())),
2203 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2206 impl ToOwned for Name {
2207 type Owned = TreeArc<Name>;
2208 fn to_owned(&self) -> TreeArc<Name> { TreeArc::cast(self.syntax.to_owned()) }
2215 #[derive(Debug, PartialEq, Eq, Hash)]
2216 #[repr(transparent)]
2217 pub struct NameRef {
2218 pub(crate) syntax: SyntaxNode,
2220 unsafe impl TransparentNewType for NameRef {
2221 type Repr = rowan::SyntaxNode;
2224 impl AstNode for NameRef {
2225 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2226 match syntax.kind() {
2227 NAME_REF => Some(NameRef::from_repr(syntax.into_repr())),
2231 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2234 impl ToOwned for NameRef {
2235 type Owned = TreeArc<NameRef>;
2236 fn to_owned(&self) -> TreeArc<NameRef> { TreeArc::cast(self.syntax.to_owned()) }
2243 #[derive(Debug, PartialEq, Eq, Hash)]
2244 #[repr(transparent)]
2245 pub struct NamedField {
2246 pub(crate) syntax: SyntaxNode,
2248 unsafe impl TransparentNewType for NamedField {
2249 type Repr = rowan::SyntaxNode;
2252 impl AstNode for NamedField {
2253 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2254 match syntax.kind() {
2255 NAMED_FIELD => Some(NamedField::from_repr(syntax.into_repr())),
2259 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2262 impl ToOwned for NamedField {
2263 type Owned = TreeArc<NamedField>;
2264 fn to_owned(&self) -> TreeArc<NamedField> { TreeArc::cast(self.syntax.to_owned()) }
2269 pub fn name_ref(&self) -> Option<&NameRef> {
2270 super::child_opt(self)
2273 pub fn expr(&self) -> Option<&Expr> {
2274 super::child_opt(self)
2279 #[derive(Debug, PartialEq, Eq, Hash)]
2280 #[repr(transparent)]
2281 pub struct NamedFieldDef {
2282 pub(crate) syntax: SyntaxNode,
2284 unsafe impl TransparentNewType for NamedFieldDef {
2285 type Repr = rowan::SyntaxNode;
2288 impl AstNode for NamedFieldDef {
2289 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2290 match syntax.kind() {
2291 NAMED_FIELD_DEF => Some(NamedFieldDef::from_repr(syntax.into_repr())),
2295 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2298 impl ToOwned for NamedFieldDef {
2299 type Owned = TreeArc<NamedFieldDef>;
2300 fn to_owned(&self) -> TreeArc<NamedFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2304 impl ast::VisibilityOwner for NamedFieldDef {}
2305 impl ast::NameOwner for NamedFieldDef {}
2306 impl ast::AttrsOwner for NamedFieldDef {}
2307 impl ast::DocCommentsOwner for NamedFieldDef {}
2308 impl ast::TypeAscriptionOwner for NamedFieldDef {}
2309 impl NamedFieldDef {}
2311 // NamedFieldDefList
2312 #[derive(Debug, PartialEq, Eq, Hash)]
2313 #[repr(transparent)]
2314 pub struct NamedFieldDefList {
2315 pub(crate) syntax: SyntaxNode,
2317 unsafe impl TransparentNewType for NamedFieldDefList {
2318 type Repr = rowan::SyntaxNode;
2321 impl AstNode for NamedFieldDefList {
2322 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2323 match syntax.kind() {
2324 NAMED_FIELD_DEF_LIST => Some(NamedFieldDefList::from_repr(syntax.into_repr())),
2328 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2331 impl ToOwned for NamedFieldDefList {
2332 type Owned = TreeArc<NamedFieldDefList>;
2333 fn to_owned(&self) -> TreeArc<NamedFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
2337 impl NamedFieldDefList {
2338 pub fn fields(&self) -> impl Iterator<Item = &NamedFieldDef> {
2339 super::children(self)
2344 #[derive(Debug, PartialEq, Eq, Hash)]
2345 #[repr(transparent)]
2346 pub struct NamedFieldList {
2347 pub(crate) syntax: SyntaxNode,
2349 unsafe impl TransparentNewType for NamedFieldList {
2350 type Repr = rowan::SyntaxNode;
2353 impl AstNode for NamedFieldList {
2354 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2355 match syntax.kind() {
2356 NAMED_FIELD_LIST => Some(NamedFieldList::from_repr(syntax.into_repr())),
2360 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2363 impl ToOwned for NamedFieldList {
2364 type Owned = TreeArc<NamedFieldList>;
2365 fn to_owned(&self) -> TreeArc<NamedFieldList> { TreeArc::cast(self.syntax.to_owned()) }
2369 impl NamedFieldList {
2370 pub fn fields(&self) -> impl Iterator<Item = &NamedField> {
2371 super::children(self)
2376 #[derive(Debug, PartialEq, Eq, Hash)]
2377 #[repr(transparent)]
2378 pub struct NeverType {
2379 pub(crate) syntax: SyntaxNode,
2381 unsafe impl TransparentNewType for NeverType {
2382 type Repr = rowan::SyntaxNode;
2385 impl AstNode for NeverType {
2386 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2387 match syntax.kind() {
2388 NEVER_TYPE => Some(NeverType::from_repr(syntax.into_repr())),
2392 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2395 impl ToOwned for NeverType {
2396 type Owned = TreeArc<NeverType>;
2397 fn to_owned(&self) -> TreeArc<NeverType> { TreeArc::cast(self.syntax.to_owned()) }
2404 #[derive(Debug, PartialEq, Eq, Hash)]
2405 #[repr(transparent)]
2406 pub struct NominalDef {
2407 pub(crate) syntax: SyntaxNode,
2409 unsafe impl TransparentNewType for NominalDef {
2410 type Repr = rowan::SyntaxNode;
2413 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2414 pub enum NominalDefKind<'a> {
2415 StructDef(&'a StructDef),
2416 EnumDef(&'a EnumDef),
2418 impl<'a> From<&'a StructDef> for &'a NominalDef {
2419 fn from(n: &'a StructDef) -> &'a NominalDef {
2420 NominalDef::cast(&n.syntax).unwrap()
2423 impl<'a> From<&'a EnumDef> for &'a NominalDef {
2424 fn from(n: &'a EnumDef) -> &'a NominalDef {
2425 NominalDef::cast(&n.syntax).unwrap()
2430 impl AstNode for NominalDef {
2431 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2432 match syntax.kind() {
2434 | ENUM_DEF => Some(NominalDef::from_repr(syntax.into_repr())),
2438 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2441 impl ToOwned for NominalDef {
2442 type Owned = TreeArc<NominalDef>;
2443 fn to_owned(&self) -> TreeArc<NominalDef> { TreeArc::cast(self.syntax.to_owned()) }
2447 pub fn kind(&self) -> NominalDefKind {
2448 match self.syntax.kind() {
2449 STRUCT_DEF => NominalDefKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2450 ENUM_DEF => NominalDefKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2451 _ => unreachable!(),
2456 impl ast::NameOwner for NominalDef {}
2457 impl ast::TypeParamsOwner for NominalDef {}
2458 impl ast::AttrsOwner for NominalDef {}
2462 #[derive(Debug, PartialEq, Eq, Hash)]
2463 #[repr(transparent)]
2465 pub(crate) syntax: SyntaxNode,
2467 unsafe impl TransparentNewType for Param {
2468 type Repr = rowan::SyntaxNode;
2471 impl AstNode for Param {
2472 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2473 match syntax.kind() {
2474 PARAM => Some(Param::from_repr(syntax.into_repr())),
2478 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2481 impl ToOwned for Param {
2482 type Owned = TreeArc<Param>;
2483 fn to_owned(&self) -> TreeArc<Param> { TreeArc::cast(self.syntax.to_owned()) }
2487 impl ast::TypeAscriptionOwner for Param {}
2489 pub fn pat(&self) -> Option<&Pat> {
2490 super::child_opt(self)
2495 #[derive(Debug, PartialEq, Eq, Hash)]
2496 #[repr(transparent)]
2497 pub struct ParamList {
2498 pub(crate) syntax: SyntaxNode,
2500 unsafe impl TransparentNewType for ParamList {
2501 type Repr = rowan::SyntaxNode;
2504 impl AstNode for ParamList {
2505 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2506 match syntax.kind() {
2507 PARAM_LIST => Some(ParamList::from_repr(syntax.into_repr())),
2511 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2514 impl ToOwned for ParamList {
2515 type Owned = TreeArc<ParamList>;
2516 fn to_owned(&self) -> TreeArc<ParamList> { TreeArc::cast(self.syntax.to_owned()) }
2521 pub fn params(&self) -> impl Iterator<Item = &Param> {
2522 super::children(self)
2525 pub fn self_param(&self) -> Option<&SelfParam> {
2526 super::child_opt(self)
2531 #[derive(Debug, PartialEq, Eq, Hash)]
2532 #[repr(transparent)]
2533 pub struct ParenExpr {
2534 pub(crate) syntax: SyntaxNode,
2536 unsafe impl TransparentNewType for ParenExpr {
2537 type Repr = rowan::SyntaxNode;
2540 impl AstNode for ParenExpr {
2541 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2542 match syntax.kind() {
2543 PAREN_EXPR => Some(ParenExpr::from_repr(syntax.into_repr())),
2547 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2550 impl ToOwned for ParenExpr {
2551 type Owned = TreeArc<ParenExpr>;
2552 fn to_owned(&self) -> TreeArc<ParenExpr> { TreeArc::cast(self.syntax.to_owned()) }
2557 pub fn expr(&self) -> Option<&Expr> {
2558 super::child_opt(self)
2563 #[derive(Debug, PartialEq, Eq, Hash)]
2564 #[repr(transparent)]
2565 pub struct ParenType {
2566 pub(crate) syntax: SyntaxNode,
2568 unsafe impl TransparentNewType for ParenType {
2569 type Repr = rowan::SyntaxNode;
2572 impl AstNode for ParenType {
2573 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2574 match syntax.kind() {
2575 PAREN_TYPE => Some(ParenType::from_repr(syntax.into_repr())),
2579 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2582 impl ToOwned for ParenType {
2583 type Owned = TreeArc<ParenType>;
2584 fn to_owned(&self) -> TreeArc<ParenType> { TreeArc::cast(self.syntax.to_owned()) }
2589 pub fn type_ref(&self) -> Option<&TypeRef> {
2590 super::child_opt(self)
2595 #[derive(Debug, PartialEq, Eq, Hash)]
2596 #[repr(transparent)]
2598 pub(crate) syntax: SyntaxNode,
2600 unsafe impl TransparentNewType for Pat {
2601 type Repr = rowan::SyntaxNode;
2604 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2605 pub enum PatKind<'a> {
2607 BindPat(&'a BindPat),
2608 PlaceholderPat(&'a PlaceholderPat),
2609 PathPat(&'a PathPat),
2610 StructPat(&'a StructPat),
2611 TupleStructPat(&'a TupleStructPat),
2612 TuplePat(&'a TuplePat),
2613 SlicePat(&'a SlicePat),
2614 RangePat(&'a RangePat),
2615 LiteralPat(&'a LiteralPat),
2617 impl<'a> From<&'a RefPat> for &'a Pat {
2618 fn from(n: &'a RefPat) -> &'a Pat {
2619 Pat::cast(&n.syntax).unwrap()
2622 impl<'a> From<&'a BindPat> for &'a Pat {
2623 fn from(n: &'a BindPat) -> &'a Pat {
2624 Pat::cast(&n.syntax).unwrap()
2627 impl<'a> From<&'a PlaceholderPat> for &'a Pat {
2628 fn from(n: &'a PlaceholderPat) -> &'a Pat {
2629 Pat::cast(&n.syntax).unwrap()
2632 impl<'a> From<&'a PathPat> for &'a Pat {
2633 fn from(n: &'a PathPat) -> &'a Pat {
2634 Pat::cast(&n.syntax).unwrap()
2637 impl<'a> From<&'a StructPat> for &'a Pat {
2638 fn from(n: &'a StructPat) -> &'a Pat {
2639 Pat::cast(&n.syntax).unwrap()
2642 impl<'a> From<&'a TupleStructPat> for &'a Pat {
2643 fn from(n: &'a TupleStructPat) -> &'a Pat {
2644 Pat::cast(&n.syntax).unwrap()
2647 impl<'a> From<&'a TuplePat> for &'a Pat {
2648 fn from(n: &'a TuplePat) -> &'a Pat {
2649 Pat::cast(&n.syntax).unwrap()
2652 impl<'a> From<&'a SlicePat> for &'a Pat {
2653 fn from(n: &'a SlicePat) -> &'a Pat {
2654 Pat::cast(&n.syntax).unwrap()
2657 impl<'a> From<&'a RangePat> for &'a Pat {
2658 fn from(n: &'a RangePat) -> &'a Pat {
2659 Pat::cast(&n.syntax).unwrap()
2662 impl<'a> From<&'a LiteralPat> for &'a Pat {
2663 fn from(n: &'a LiteralPat) -> &'a Pat {
2664 Pat::cast(&n.syntax).unwrap()
2669 impl AstNode for Pat {
2670 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2671 match syntax.kind() {
2681 | LITERAL_PAT => Some(Pat::from_repr(syntax.into_repr())),
2685 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2688 impl ToOwned for Pat {
2689 type Owned = TreeArc<Pat>;
2690 fn to_owned(&self) -> TreeArc<Pat> { TreeArc::cast(self.syntax.to_owned()) }
2694 pub fn kind(&self) -> PatKind {
2695 match self.syntax.kind() {
2696 REF_PAT => PatKind::RefPat(RefPat::cast(&self.syntax).unwrap()),
2697 BIND_PAT => PatKind::BindPat(BindPat::cast(&self.syntax).unwrap()),
2698 PLACEHOLDER_PAT => PatKind::PlaceholderPat(PlaceholderPat::cast(&self.syntax).unwrap()),
2699 PATH_PAT => PatKind::PathPat(PathPat::cast(&self.syntax).unwrap()),
2700 STRUCT_PAT => PatKind::StructPat(StructPat::cast(&self.syntax).unwrap()),
2701 TUPLE_STRUCT_PAT => PatKind::TupleStructPat(TupleStructPat::cast(&self.syntax).unwrap()),
2702 TUPLE_PAT => PatKind::TuplePat(TuplePat::cast(&self.syntax).unwrap()),
2703 SLICE_PAT => PatKind::SlicePat(SlicePat::cast(&self.syntax).unwrap()),
2704 RANGE_PAT => PatKind::RangePat(RangePat::cast(&self.syntax).unwrap()),
2705 LITERAL_PAT => PatKind::LiteralPat(LiteralPat::cast(&self.syntax).unwrap()),
2706 _ => unreachable!(),
2714 #[derive(Debug, PartialEq, Eq, Hash)]
2715 #[repr(transparent)]
2717 pub(crate) syntax: SyntaxNode,
2719 unsafe impl TransparentNewType for Path {
2720 type Repr = rowan::SyntaxNode;
2723 impl AstNode for Path {
2724 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2725 match syntax.kind() {
2726 PATH => Some(Path::from_repr(syntax.into_repr())),
2730 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2733 impl ToOwned for Path {
2734 type Owned = TreeArc<Path>;
2735 fn to_owned(&self) -> TreeArc<Path> { TreeArc::cast(self.syntax.to_owned()) }
2740 pub fn segment(&self) -> Option<&PathSegment> {
2741 super::child_opt(self)
2744 pub fn qualifier(&self) -> Option<&Path> {
2745 super::child_opt(self)
2750 #[derive(Debug, PartialEq, Eq, Hash)]
2751 #[repr(transparent)]
2752 pub struct PathExpr {
2753 pub(crate) syntax: SyntaxNode,
2755 unsafe impl TransparentNewType for PathExpr {
2756 type Repr = rowan::SyntaxNode;
2759 impl AstNode for PathExpr {
2760 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2761 match syntax.kind() {
2762 PATH_EXPR => Some(PathExpr::from_repr(syntax.into_repr())),
2766 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2769 impl ToOwned for PathExpr {
2770 type Owned = TreeArc<PathExpr>;
2771 fn to_owned(&self) -> TreeArc<PathExpr> { TreeArc::cast(self.syntax.to_owned()) }
2776 pub fn path(&self) -> Option<&Path> {
2777 super::child_opt(self)
2782 #[derive(Debug, PartialEq, Eq, Hash)]
2783 #[repr(transparent)]
2784 pub struct PathPat {
2785 pub(crate) syntax: SyntaxNode,
2787 unsafe impl TransparentNewType for PathPat {
2788 type Repr = rowan::SyntaxNode;
2791 impl AstNode for PathPat {
2792 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2793 match syntax.kind() {
2794 PATH_PAT => Some(PathPat::from_repr(syntax.into_repr())),
2798 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2801 impl ToOwned for PathPat {
2802 type Owned = TreeArc<PathPat>;
2803 fn to_owned(&self) -> TreeArc<PathPat> { TreeArc::cast(self.syntax.to_owned()) }
2808 pub fn path(&self) -> Option<&Path> {
2809 super::child_opt(self)
2814 #[derive(Debug, PartialEq, Eq, Hash)]
2815 #[repr(transparent)]
2816 pub struct PathSegment {
2817 pub(crate) syntax: SyntaxNode,
2819 unsafe impl TransparentNewType for PathSegment {
2820 type Repr = rowan::SyntaxNode;
2823 impl AstNode for PathSegment {
2824 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2825 match syntax.kind() {
2826 PATH_SEGMENT => Some(PathSegment::from_repr(syntax.into_repr())),
2830 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2833 impl ToOwned for PathSegment {
2834 type Owned = TreeArc<PathSegment>;
2835 fn to_owned(&self) -> TreeArc<PathSegment> { TreeArc::cast(self.syntax.to_owned()) }
2840 pub fn name_ref(&self) -> Option<&NameRef> {
2841 super::child_opt(self)
2844 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
2845 super::child_opt(self)
2850 #[derive(Debug, PartialEq, Eq, Hash)]
2851 #[repr(transparent)]
2852 pub struct PathType {
2853 pub(crate) syntax: SyntaxNode,
2855 unsafe impl TransparentNewType for PathType {
2856 type Repr = rowan::SyntaxNode;
2859 impl AstNode for PathType {
2860 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2861 match syntax.kind() {
2862 PATH_TYPE => Some(PathType::from_repr(syntax.into_repr())),
2866 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2869 impl ToOwned for PathType {
2870 type Owned = TreeArc<PathType>;
2871 fn to_owned(&self) -> TreeArc<PathType> { TreeArc::cast(self.syntax.to_owned()) }
2876 pub fn path(&self) -> Option<&Path> {
2877 super::child_opt(self)
2882 #[derive(Debug, PartialEq, Eq, Hash)]
2883 #[repr(transparent)]
2884 pub struct PlaceholderPat {
2885 pub(crate) syntax: SyntaxNode,
2887 unsafe impl TransparentNewType for PlaceholderPat {
2888 type Repr = rowan::SyntaxNode;
2891 impl AstNode for PlaceholderPat {
2892 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2893 match syntax.kind() {
2894 PLACEHOLDER_PAT => Some(PlaceholderPat::from_repr(syntax.into_repr())),
2898 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2901 impl ToOwned for PlaceholderPat {
2902 type Owned = TreeArc<PlaceholderPat>;
2903 fn to_owned(&self) -> TreeArc<PlaceholderPat> { TreeArc::cast(self.syntax.to_owned()) }
2907 impl PlaceholderPat {}
2910 #[derive(Debug, PartialEq, Eq, Hash)]
2911 #[repr(transparent)]
2912 pub struct PlaceholderType {
2913 pub(crate) syntax: SyntaxNode,
2915 unsafe impl TransparentNewType for PlaceholderType {
2916 type Repr = rowan::SyntaxNode;
2919 impl AstNode for PlaceholderType {
2920 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2921 match syntax.kind() {
2922 PLACEHOLDER_TYPE => Some(PlaceholderType::from_repr(syntax.into_repr())),
2926 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2929 impl ToOwned for PlaceholderType {
2930 type Owned = TreeArc<PlaceholderType>;
2931 fn to_owned(&self) -> TreeArc<PlaceholderType> { TreeArc::cast(self.syntax.to_owned()) }
2935 impl PlaceholderType {}
2938 #[derive(Debug, PartialEq, Eq, Hash)]
2939 #[repr(transparent)]
2940 pub struct PointerType {
2941 pub(crate) syntax: SyntaxNode,
2943 unsafe impl TransparentNewType for PointerType {
2944 type Repr = rowan::SyntaxNode;
2947 impl AstNode for PointerType {
2948 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2949 match syntax.kind() {
2950 POINTER_TYPE => Some(PointerType::from_repr(syntax.into_repr())),
2954 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2957 impl ToOwned for PointerType {
2958 type Owned = TreeArc<PointerType>;
2959 fn to_owned(&self) -> TreeArc<PointerType> { TreeArc::cast(self.syntax.to_owned()) }
2964 pub fn type_ref(&self) -> Option<&TypeRef> {
2965 super::child_opt(self)
2970 #[derive(Debug, PartialEq, Eq, Hash)]
2971 #[repr(transparent)]
2972 pub struct PosFieldDef {
2973 pub(crate) syntax: SyntaxNode,
2975 unsafe impl TransparentNewType for PosFieldDef {
2976 type Repr = rowan::SyntaxNode;
2979 impl AstNode for PosFieldDef {
2980 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2981 match syntax.kind() {
2982 POS_FIELD_DEF => Some(PosFieldDef::from_repr(syntax.into_repr())),
2986 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2989 impl ToOwned for PosFieldDef {
2990 type Owned = TreeArc<PosFieldDef>;
2991 fn to_owned(&self) -> TreeArc<PosFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2995 impl ast::VisibilityOwner for PosFieldDef {}
2996 impl ast::AttrsOwner for PosFieldDef {}
2998 pub fn type_ref(&self) -> Option<&TypeRef> {
2999 super::child_opt(self)
3004 #[derive(Debug, PartialEq, Eq, Hash)]
3005 #[repr(transparent)]
3006 pub struct PosFieldDefList {
3007 pub(crate) syntax: SyntaxNode,
3009 unsafe impl TransparentNewType for PosFieldDefList {
3010 type Repr = rowan::SyntaxNode;
3013 impl AstNode for PosFieldDefList {
3014 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3015 match syntax.kind() {
3016 POS_FIELD_DEF_LIST => Some(PosFieldDefList::from_repr(syntax.into_repr())),
3020 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3023 impl ToOwned for PosFieldDefList {
3024 type Owned = TreeArc<PosFieldDefList>;
3025 fn to_owned(&self) -> TreeArc<PosFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
3029 impl PosFieldDefList {
3030 pub fn fields(&self) -> impl Iterator<Item = &PosFieldDef> {
3031 super::children(self)
3036 #[derive(Debug, PartialEq, Eq, Hash)]
3037 #[repr(transparent)]
3038 pub struct PrefixExpr {
3039 pub(crate) syntax: SyntaxNode,
3041 unsafe impl TransparentNewType for PrefixExpr {
3042 type Repr = rowan::SyntaxNode;
3045 impl AstNode for PrefixExpr {
3046 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3047 match syntax.kind() {
3048 PREFIX_EXPR => Some(PrefixExpr::from_repr(syntax.into_repr())),
3052 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3055 impl ToOwned for PrefixExpr {
3056 type Owned = TreeArc<PrefixExpr>;
3057 fn to_owned(&self) -> TreeArc<PrefixExpr> { TreeArc::cast(self.syntax.to_owned()) }
3062 pub fn expr(&self) -> Option<&Expr> {
3063 super::child_opt(self)
3068 #[derive(Debug, PartialEq, Eq, Hash)]
3069 #[repr(transparent)]
3070 pub struct RangeExpr {
3071 pub(crate) syntax: SyntaxNode,
3073 unsafe impl TransparentNewType for RangeExpr {
3074 type Repr = rowan::SyntaxNode;
3077 impl AstNode for RangeExpr {
3078 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3079 match syntax.kind() {
3080 RANGE_EXPR => Some(RangeExpr::from_repr(syntax.into_repr())),
3084 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3087 impl ToOwned for RangeExpr {
3088 type Owned = TreeArc<RangeExpr>;
3089 fn to_owned(&self) -> TreeArc<RangeExpr> { TreeArc::cast(self.syntax.to_owned()) }
3096 #[derive(Debug, PartialEq, Eq, Hash)]
3097 #[repr(transparent)]
3098 pub struct RangePat {
3099 pub(crate) syntax: SyntaxNode,
3101 unsafe impl TransparentNewType for RangePat {
3102 type Repr = rowan::SyntaxNode;
3105 impl AstNode for RangePat {
3106 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3107 match syntax.kind() {
3108 RANGE_PAT => Some(RangePat::from_repr(syntax.into_repr())),
3112 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3115 impl ToOwned for RangePat {
3116 type Owned = TreeArc<RangePat>;
3117 fn to_owned(&self) -> TreeArc<RangePat> { TreeArc::cast(self.syntax.to_owned()) }
3124 #[derive(Debug, PartialEq, Eq, Hash)]
3125 #[repr(transparent)]
3126 pub struct RefExpr {
3127 pub(crate) syntax: SyntaxNode,
3129 unsafe impl TransparentNewType for RefExpr {
3130 type Repr = rowan::SyntaxNode;
3133 impl AstNode for RefExpr {
3134 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3135 match syntax.kind() {
3136 REF_EXPR => Some(RefExpr::from_repr(syntax.into_repr())),
3140 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3143 impl ToOwned for RefExpr {
3144 type Owned = TreeArc<RefExpr>;
3145 fn to_owned(&self) -> TreeArc<RefExpr> { TreeArc::cast(self.syntax.to_owned()) }
3150 pub fn expr(&self) -> Option<&Expr> {
3151 super::child_opt(self)
3156 #[derive(Debug, PartialEq, Eq, Hash)]
3157 #[repr(transparent)]
3159 pub(crate) syntax: SyntaxNode,
3161 unsafe impl TransparentNewType for RefPat {
3162 type Repr = rowan::SyntaxNode;
3165 impl AstNode for RefPat {
3166 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3167 match syntax.kind() {
3168 REF_PAT => Some(RefPat::from_repr(syntax.into_repr())),
3172 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3175 impl ToOwned for RefPat {
3176 type Owned = TreeArc<RefPat>;
3177 fn to_owned(&self) -> TreeArc<RefPat> { TreeArc::cast(self.syntax.to_owned()) }
3182 pub fn pat(&self) -> Option<&Pat> {
3183 super::child_opt(self)
3188 #[derive(Debug, PartialEq, Eq, Hash)]
3189 #[repr(transparent)]
3190 pub struct ReferenceType {
3191 pub(crate) syntax: SyntaxNode,
3193 unsafe impl TransparentNewType for ReferenceType {
3194 type Repr = rowan::SyntaxNode;
3197 impl AstNode for ReferenceType {
3198 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3199 match syntax.kind() {
3200 REFERENCE_TYPE => Some(ReferenceType::from_repr(syntax.into_repr())),
3204 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3207 impl ToOwned for ReferenceType {
3208 type Owned = TreeArc<ReferenceType>;
3209 fn to_owned(&self) -> TreeArc<ReferenceType> { TreeArc::cast(self.syntax.to_owned()) }
3213 impl ReferenceType {
3214 pub fn type_ref(&self) -> Option<&TypeRef> {
3215 super::child_opt(self)
3220 #[derive(Debug, PartialEq, Eq, Hash)]
3221 #[repr(transparent)]
3222 pub struct RetType {
3223 pub(crate) syntax: SyntaxNode,
3225 unsafe impl TransparentNewType for RetType {
3226 type Repr = rowan::SyntaxNode;
3229 impl AstNode for RetType {
3230 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3231 match syntax.kind() {
3232 RET_TYPE => Some(RetType::from_repr(syntax.into_repr())),
3236 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3239 impl ToOwned for RetType {
3240 type Owned = TreeArc<RetType>;
3241 fn to_owned(&self) -> TreeArc<RetType> { TreeArc::cast(self.syntax.to_owned()) }
3246 pub fn type_ref(&self) -> Option<&TypeRef> {
3247 super::child_opt(self)
3252 #[derive(Debug, PartialEq, Eq, Hash)]
3253 #[repr(transparent)]
3254 pub struct ReturnExpr {
3255 pub(crate) syntax: SyntaxNode,
3257 unsafe impl TransparentNewType for ReturnExpr {
3258 type Repr = rowan::SyntaxNode;
3261 impl AstNode for ReturnExpr {
3262 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3263 match syntax.kind() {
3264 RETURN_EXPR => Some(ReturnExpr::from_repr(syntax.into_repr())),
3268 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3271 impl ToOwned for ReturnExpr {
3272 type Owned = TreeArc<ReturnExpr>;
3273 fn to_owned(&self) -> TreeArc<ReturnExpr> { TreeArc::cast(self.syntax.to_owned()) }
3278 pub fn expr(&self) -> Option<&Expr> {
3279 super::child_opt(self)
3284 #[derive(Debug, PartialEq, Eq, Hash)]
3285 #[repr(transparent)]
3286 pub struct SelfParam {
3287 pub(crate) syntax: SyntaxNode,
3289 unsafe impl TransparentNewType for SelfParam {
3290 type Repr = rowan::SyntaxNode;
3293 impl AstNode for SelfParam {
3294 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3295 match syntax.kind() {
3296 SELF_PARAM => Some(SelfParam::from_repr(syntax.into_repr())),
3300 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3303 impl ToOwned for SelfParam {
3304 type Owned = TreeArc<SelfParam>;
3305 fn to_owned(&self) -> TreeArc<SelfParam> { TreeArc::cast(self.syntax.to_owned()) }
3309 impl ast::TypeAscriptionOwner for SelfParam {}
3313 #[derive(Debug, PartialEq, Eq, Hash)]
3314 #[repr(transparent)]
3315 pub struct SlicePat {
3316 pub(crate) syntax: SyntaxNode,
3318 unsafe impl TransparentNewType for SlicePat {
3319 type Repr = rowan::SyntaxNode;
3322 impl AstNode for SlicePat {
3323 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3324 match syntax.kind() {
3325 SLICE_PAT => Some(SlicePat::from_repr(syntax.into_repr())),
3329 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3332 impl ToOwned for SlicePat {
3333 type Owned = TreeArc<SlicePat>;
3334 fn to_owned(&self) -> TreeArc<SlicePat> { TreeArc::cast(self.syntax.to_owned()) }
3341 #[derive(Debug, PartialEq, Eq, Hash)]
3342 #[repr(transparent)]
3343 pub struct SliceType {
3344 pub(crate) syntax: SyntaxNode,
3346 unsafe impl TransparentNewType for SliceType {
3347 type Repr = rowan::SyntaxNode;
3350 impl AstNode for SliceType {
3351 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3352 match syntax.kind() {
3353 SLICE_TYPE => Some(SliceType::from_repr(syntax.into_repr())),
3357 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3360 impl ToOwned for SliceType {
3361 type Owned = TreeArc<SliceType>;
3362 fn to_owned(&self) -> TreeArc<SliceType> { TreeArc::cast(self.syntax.to_owned()) }
3367 pub fn type_ref(&self) -> Option<&TypeRef> {
3368 super::child_opt(self)
3373 #[derive(Debug, PartialEq, Eq, Hash)]
3374 #[repr(transparent)]
3375 pub struct SourceFile {
3376 pub(crate) syntax: SyntaxNode,
3378 unsafe impl TransparentNewType for SourceFile {
3379 type Repr = rowan::SyntaxNode;
3382 impl AstNode for SourceFile {
3383 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3384 match syntax.kind() {
3385 SOURCE_FILE => Some(SourceFile::from_repr(syntax.into_repr())),
3389 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3392 impl ToOwned for SourceFile {
3393 type Owned = TreeArc<SourceFile>;
3394 fn to_owned(&self) -> TreeArc<SourceFile> { TreeArc::cast(self.syntax.to_owned()) }
3398 impl ast::ModuleItemOwner for SourceFile {}
3399 impl ast::FnDefOwner for SourceFile {}
3401 pub fn modules(&self) -> impl Iterator<Item = &Module> {
3402 super::children(self)
3407 #[derive(Debug, PartialEq, Eq, Hash)]
3408 #[repr(transparent)]
3409 pub struct StaticDef {
3410 pub(crate) syntax: SyntaxNode,
3412 unsafe impl TransparentNewType for StaticDef {
3413 type Repr = rowan::SyntaxNode;
3416 impl AstNode for StaticDef {
3417 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3418 match syntax.kind() {
3419 STATIC_DEF => Some(StaticDef::from_repr(syntax.into_repr())),
3423 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3426 impl ToOwned for StaticDef {
3427 type Owned = TreeArc<StaticDef>;
3428 fn to_owned(&self) -> TreeArc<StaticDef> { TreeArc::cast(self.syntax.to_owned()) }
3432 impl ast::VisibilityOwner for StaticDef {}
3433 impl ast::NameOwner for StaticDef {}
3434 impl ast::TypeParamsOwner for StaticDef {}
3435 impl ast::AttrsOwner for StaticDef {}
3436 impl ast::DocCommentsOwner for StaticDef {}
3437 impl ast::TypeAscriptionOwner for StaticDef {}
3439 pub fn body(&self) -> Option<&Expr> {
3440 super::child_opt(self)
3445 #[derive(Debug, PartialEq, Eq, Hash)]
3446 #[repr(transparent)]
3448 pub(crate) syntax: SyntaxNode,
3450 unsafe impl TransparentNewType for Stmt {
3451 type Repr = rowan::SyntaxNode;
3454 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3455 pub enum StmtKind<'a> {
3456 ExprStmt(&'a ExprStmt),
3457 LetStmt(&'a LetStmt),
3459 impl<'a> From<&'a ExprStmt> for &'a Stmt {
3460 fn from(n: &'a ExprStmt) -> &'a Stmt {
3461 Stmt::cast(&n.syntax).unwrap()
3464 impl<'a> From<&'a LetStmt> for &'a Stmt {
3465 fn from(n: &'a LetStmt) -> &'a Stmt {
3466 Stmt::cast(&n.syntax).unwrap()
3471 impl AstNode for Stmt {
3472 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3473 match syntax.kind() {
3475 | LET_STMT => Some(Stmt::from_repr(syntax.into_repr())),
3479 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3482 impl ToOwned for Stmt {
3483 type Owned = TreeArc<Stmt>;
3484 fn to_owned(&self) -> TreeArc<Stmt> { TreeArc::cast(self.syntax.to_owned()) }
3488 pub fn kind(&self) -> StmtKind {
3489 match self.syntax.kind() {
3490 EXPR_STMT => StmtKind::ExprStmt(ExprStmt::cast(&self.syntax).unwrap()),
3491 LET_STMT => StmtKind::LetStmt(LetStmt::cast(&self.syntax).unwrap()),
3492 _ => unreachable!(),
3500 #[derive(Debug, PartialEq, Eq, Hash)]
3501 #[repr(transparent)]
3502 pub struct StructDef {
3503 pub(crate) syntax: SyntaxNode,
3505 unsafe impl TransparentNewType for StructDef {
3506 type Repr = rowan::SyntaxNode;
3509 impl AstNode for StructDef {
3510 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3511 match syntax.kind() {
3512 STRUCT_DEF => Some(StructDef::from_repr(syntax.into_repr())),
3516 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3519 impl ToOwned for StructDef {
3520 type Owned = TreeArc<StructDef>;
3521 fn to_owned(&self) -> TreeArc<StructDef> { TreeArc::cast(self.syntax.to_owned()) }
3525 impl ast::VisibilityOwner for StructDef {}
3526 impl ast::NameOwner for StructDef {}
3527 impl ast::TypeParamsOwner for StructDef {}
3528 impl ast::AttrsOwner for StructDef {}
3529 impl ast::DocCommentsOwner for StructDef {}
3533 #[derive(Debug, PartialEq, Eq, Hash)]
3534 #[repr(transparent)]
3535 pub struct StructLit {
3536 pub(crate) syntax: SyntaxNode,
3538 unsafe impl TransparentNewType for StructLit {
3539 type Repr = rowan::SyntaxNode;
3542 impl AstNode for StructLit {
3543 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3544 match syntax.kind() {
3545 STRUCT_LIT => Some(StructLit::from_repr(syntax.into_repr())),
3549 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3552 impl ToOwned for StructLit {
3553 type Owned = TreeArc<StructLit>;
3554 fn to_owned(&self) -> TreeArc<StructLit> { TreeArc::cast(self.syntax.to_owned()) }
3559 pub fn path(&self) -> Option<&Path> {
3560 super::child_opt(self)
3563 pub fn named_field_list(&self) -> Option<&NamedFieldList> {
3564 super::child_opt(self)
3567 pub fn spread(&self) -> Option<&Expr> {
3568 super::child_opt(self)
3573 #[derive(Debug, PartialEq, Eq, Hash)]
3574 #[repr(transparent)]
3575 pub struct StructPat {
3576 pub(crate) syntax: SyntaxNode,
3578 unsafe impl TransparentNewType for StructPat {
3579 type Repr = rowan::SyntaxNode;
3582 impl AstNode for StructPat {
3583 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3584 match syntax.kind() {
3585 STRUCT_PAT => Some(StructPat::from_repr(syntax.into_repr())),
3589 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3592 impl ToOwned for StructPat {
3593 type Owned = TreeArc<StructPat>;
3594 fn to_owned(&self) -> TreeArc<StructPat> { TreeArc::cast(self.syntax.to_owned()) }
3599 pub fn field_pat_list(&self) -> Option<&FieldPatList> {
3600 super::child_opt(self)
3603 pub fn path(&self) -> Option<&Path> {
3604 super::child_opt(self)
3609 #[derive(Debug, PartialEq, Eq, Hash)]
3610 #[repr(transparent)]
3611 pub struct TokenTree {
3612 pub(crate) syntax: SyntaxNode,
3614 unsafe impl TransparentNewType for TokenTree {
3615 type Repr = rowan::SyntaxNode;
3618 impl AstNode for TokenTree {
3619 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3620 match syntax.kind() {
3621 TOKEN_TREE => Some(TokenTree::from_repr(syntax.into_repr())),
3625 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3628 impl ToOwned for TokenTree {
3629 type Owned = TreeArc<TokenTree>;
3630 fn to_owned(&self) -> TreeArc<TokenTree> { TreeArc::cast(self.syntax.to_owned()) }
3637 #[derive(Debug, PartialEq, Eq, Hash)]
3638 #[repr(transparent)]
3639 pub struct TraitDef {
3640 pub(crate) syntax: SyntaxNode,
3642 unsafe impl TransparentNewType for TraitDef {
3643 type Repr = rowan::SyntaxNode;
3646 impl AstNode for TraitDef {
3647 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3648 match syntax.kind() {
3649 TRAIT_DEF => Some(TraitDef::from_repr(syntax.into_repr())),
3653 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3656 impl ToOwned for TraitDef {
3657 type Owned = TreeArc<TraitDef>;
3658 fn to_owned(&self) -> TreeArc<TraitDef> { TreeArc::cast(self.syntax.to_owned()) }
3662 impl ast::VisibilityOwner for TraitDef {}
3663 impl ast::NameOwner for TraitDef {}
3664 impl ast::AttrsOwner for TraitDef {}
3665 impl ast::DocCommentsOwner for TraitDef {}
3666 impl ast::TypeParamsOwner for TraitDef {}
3667 impl ast::TypeBoundsOwner for TraitDef {}
3669 pub fn item_list(&self) -> Option<&ItemList> {
3670 super::child_opt(self)
3675 #[derive(Debug, PartialEq, Eq, Hash)]
3676 #[repr(transparent)]
3677 pub struct TryExpr {
3678 pub(crate) syntax: SyntaxNode,
3680 unsafe impl TransparentNewType for TryExpr {
3681 type Repr = rowan::SyntaxNode;
3684 impl AstNode for TryExpr {
3685 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3686 match syntax.kind() {
3687 TRY_EXPR => Some(TryExpr::from_repr(syntax.into_repr())),
3691 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3694 impl ToOwned for TryExpr {
3695 type Owned = TreeArc<TryExpr>;
3696 fn to_owned(&self) -> TreeArc<TryExpr> { TreeArc::cast(self.syntax.to_owned()) }
3701 pub fn expr(&self) -> Option<&Expr> {
3702 super::child_opt(self)
3707 #[derive(Debug, PartialEq, Eq, Hash)]
3708 #[repr(transparent)]
3709 pub struct TupleExpr {
3710 pub(crate) syntax: SyntaxNode,
3712 unsafe impl TransparentNewType for TupleExpr {
3713 type Repr = rowan::SyntaxNode;
3716 impl AstNode for TupleExpr {
3717 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3718 match syntax.kind() {
3719 TUPLE_EXPR => Some(TupleExpr::from_repr(syntax.into_repr())),
3723 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3726 impl ToOwned for TupleExpr {
3727 type Owned = TreeArc<TupleExpr>;
3728 fn to_owned(&self) -> TreeArc<TupleExpr> { TreeArc::cast(self.syntax.to_owned()) }
3733 pub fn exprs(&self) -> impl Iterator<Item = &Expr> {
3734 super::children(self)
3739 #[derive(Debug, PartialEq, Eq, Hash)]
3740 #[repr(transparent)]
3741 pub struct TuplePat {
3742 pub(crate) syntax: SyntaxNode,
3744 unsafe impl TransparentNewType for TuplePat {
3745 type Repr = rowan::SyntaxNode;
3748 impl AstNode for TuplePat {
3749 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3750 match syntax.kind() {
3751 TUPLE_PAT => Some(TuplePat::from_repr(syntax.into_repr())),
3755 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3758 impl ToOwned for TuplePat {
3759 type Owned = TreeArc<TuplePat>;
3760 fn to_owned(&self) -> TreeArc<TuplePat> { TreeArc::cast(self.syntax.to_owned()) }
3765 pub fn args(&self) -> impl Iterator<Item = &Pat> {
3766 super::children(self)
3771 #[derive(Debug, PartialEq, Eq, Hash)]
3772 #[repr(transparent)]
3773 pub struct TupleStructPat {
3774 pub(crate) syntax: SyntaxNode,
3776 unsafe impl TransparentNewType for TupleStructPat {
3777 type Repr = rowan::SyntaxNode;
3780 impl AstNode for TupleStructPat {
3781 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3782 match syntax.kind() {
3783 TUPLE_STRUCT_PAT => Some(TupleStructPat::from_repr(syntax.into_repr())),
3787 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3790 impl ToOwned for TupleStructPat {
3791 type Owned = TreeArc<TupleStructPat>;
3792 fn to_owned(&self) -> TreeArc<TupleStructPat> { TreeArc::cast(self.syntax.to_owned()) }
3796 impl TupleStructPat {
3797 pub fn args(&self) -> impl Iterator<Item = &Pat> {
3798 super::children(self)
3801 pub fn path(&self) -> Option<&Path> {
3802 super::child_opt(self)
3807 #[derive(Debug, PartialEq, Eq, Hash)]
3808 #[repr(transparent)]
3809 pub struct TupleType {
3810 pub(crate) syntax: SyntaxNode,
3812 unsafe impl TransparentNewType for TupleType {
3813 type Repr = rowan::SyntaxNode;
3816 impl AstNode for TupleType {
3817 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3818 match syntax.kind() {
3819 TUPLE_TYPE => Some(TupleType::from_repr(syntax.into_repr())),
3823 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3826 impl ToOwned for TupleType {
3827 type Owned = TreeArc<TupleType>;
3828 fn to_owned(&self) -> TreeArc<TupleType> { TreeArc::cast(self.syntax.to_owned()) }
3833 pub fn fields(&self) -> impl Iterator<Item = &TypeRef> {
3834 super::children(self)
3839 #[derive(Debug, PartialEq, Eq, Hash)]
3840 #[repr(transparent)]
3841 pub struct TypeAliasDef {
3842 pub(crate) syntax: SyntaxNode,
3844 unsafe impl TransparentNewType for TypeAliasDef {
3845 type Repr = rowan::SyntaxNode;
3848 impl AstNode for TypeAliasDef {
3849 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3850 match syntax.kind() {
3851 TYPE_ALIAS_DEF => Some(TypeAliasDef::from_repr(syntax.into_repr())),
3855 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3858 impl ToOwned for TypeAliasDef {
3859 type Owned = TreeArc<TypeAliasDef>;
3860 fn to_owned(&self) -> TreeArc<TypeAliasDef> { TreeArc::cast(self.syntax.to_owned()) }
3864 impl ast::VisibilityOwner for TypeAliasDef {}
3865 impl ast::NameOwner for TypeAliasDef {}
3866 impl ast::TypeParamsOwner for TypeAliasDef {}
3867 impl ast::AttrsOwner for TypeAliasDef {}
3868 impl ast::DocCommentsOwner for TypeAliasDef {}
3869 impl ast::TypeBoundsOwner for TypeAliasDef {}
3871 pub fn type_ref(&self) -> Option<&TypeRef> {
3872 super::child_opt(self)
3877 #[derive(Debug, PartialEq, Eq, Hash)]
3878 #[repr(transparent)]
3879 pub struct TypeArg {
3880 pub(crate) syntax: SyntaxNode,
3882 unsafe impl TransparentNewType for TypeArg {
3883 type Repr = rowan::SyntaxNode;
3886 impl AstNode for TypeArg {
3887 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3888 match syntax.kind() {
3889 TYPE_ARG => Some(TypeArg::from_repr(syntax.into_repr())),
3893 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3896 impl ToOwned for TypeArg {
3897 type Owned = TreeArc<TypeArg>;
3898 fn to_owned(&self) -> TreeArc<TypeArg> { TreeArc::cast(self.syntax.to_owned()) }
3903 pub fn type_ref(&self) -> Option<&TypeRef> {
3904 super::child_opt(self)
3909 #[derive(Debug, PartialEq, Eq, Hash)]
3910 #[repr(transparent)]
3911 pub struct TypeArgList {
3912 pub(crate) syntax: SyntaxNode,
3914 unsafe impl TransparentNewType for TypeArgList {
3915 type Repr = rowan::SyntaxNode;
3918 impl AstNode for TypeArgList {
3919 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3920 match syntax.kind() {
3921 TYPE_ARG_LIST => Some(TypeArgList::from_repr(syntax.into_repr())),
3925 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3928 impl ToOwned for TypeArgList {
3929 type Owned = TreeArc<TypeArgList>;
3930 fn to_owned(&self) -> TreeArc<TypeArgList> { TreeArc::cast(self.syntax.to_owned()) }
3935 pub fn type_args(&self) -> impl Iterator<Item = &TypeArg> {
3936 super::children(self)
3939 pub fn lifetime_args(&self) -> impl Iterator<Item = &LifetimeArg> {
3940 super::children(self)
3943 pub fn assoc_type_args(&self) -> impl Iterator<Item = &AssocTypeArg> {
3944 super::children(self)
3949 #[derive(Debug, PartialEq, Eq, Hash)]
3950 #[repr(transparent)]
3951 pub struct TypeBound {
3952 pub(crate) syntax: SyntaxNode,
3954 unsafe impl TransparentNewType for TypeBound {
3955 type Repr = rowan::SyntaxNode;
3958 impl AstNode for TypeBound {
3959 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3960 match syntax.kind() {
3961 TYPE_BOUND => Some(TypeBound::from_repr(syntax.into_repr())),
3965 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3968 impl ToOwned for TypeBound {
3969 type Owned = TreeArc<TypeBound>;
3970 fn to_owned(&self) -> TreeArc<TypeBound> { TreeArc::cast(self.syntax.to_owned()) }
3975 pub fn type_ref(&self) -> Option<&TypeRef> {
3976 super::child_opt(self)
3981 #[derive(Debug, PartialEq, Eq, Hash)]
3982 #[repr(transparent)]
3983 pub struct TypeBoundList {
3984 pub(crate) syntax: SyntaxNode,
3986 unsafe impl TransparentNewType for TypeBoundList {
3987 type Repr = rowan::SyntaxNode;
3990 impl AstNode for TypeBoundList {
3991 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3992 match syntax.kind() {
3993 TYPE_BOUND_LIST => Some(TypeBoundList::from_repr(syntax.into_repr())),
3997 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4000 impl ToOwned for TypeBoundList {
4001 type Owned = TreeArc<TypeBoundList>;
4002 fn to_owned(&self) -> TreeArc<TypeBoundList> { TreeArc::cast(self.syntax.to_owned()) }
4006 impl TypeBoundList {
4007 pub fn bounds(&self) -> impl Iterator<Item = &TypeBound> {
4008 super::children(self)
4013 #[derive(Debug, PartialEq, Eq, Hash)]
4014 #[repr(transparent)]
4015 pub struct TypeParam {
4016 pub(crate) syntax: SyntaxNode,
4018 unsafe impl TransparentNewType for TypeParam {
4019 type Repr = rowan::SyntaxNode;
4022 impl AstNode for TypeParam {
4023 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4024 match syntax.kind() {
4025 TYPE_PARAM => Some(TypeParam::from_repr(syntax.into_repr())),
4029 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4032 impl ToOwned for TypeParam {
4033 type Owned = TreeArc<TypeParam>;
4034 fn to_owned(&self) -> TreeArc<TypeParam> { TreeArc::cast(self.syntax.to_owned()) }
4038 impl ast::NameOwner for TypeParam {}
4039 impl ast::AttrsOwner for TypeParam {}
4040 impl ast::TypeBoundsOwner for TypeParam {}
4044 #[derive(Debug, PartialEq, Eq, Hash)]
4045 #[repr(transparent)]
4046 pub struct TypeParamList {
4047 pub(crate) syntax: SyntaxNode,
4049 unsafe impl TransparentNewType for TypeParamList {
4050 type Repr = rowan::SyntaxNode;
4053 impl AstNode for TypeParamList {
4054 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4055 match syntax.kind() {
4056 TYPE_PARAM_LIST => Some(TypeParamList::from_repr(syntax.into_repr())),
4060 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4063 impl ToOwned for TypeParamList {
4064 type Owned = TreeArc<TypeParamList>;
4065 fn to_owned(&self) -> TreeArc<TypeParamList> { TreeArc::cast(self.syntax.to_owned()) }
4069 impl TypeParamList {
4070 pub fn type_params(&self) -> impl Iterator<Item = &TypeParam> {
4071 super::children(self)
4074 pub fn lifetime_params(&self) -> impl Iterator<Item = &LifetimeParam> {
4075 super::children(self)
4080 #[derive(Debug, PartialEq, Eq, Hash)]
4081 #[repr(transparent)]
4082 pub struct TypeRef {
4083 pub(crate) syntax: SyntaxNode,
4085 unsafe impl TransparentNewType for TypeRef {
4086 type Repr = rowan::SyntaxNode;
4089 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4090 pub enum TypeRefKind<'a> {
4091 ParenType(&'a ParenType),
4092 TupleType(&'a TupleType),
4093 NeverType(&'a NeverType),
4094 PathType(&'a PathType),
4095 PointerType(&'a PointerType),
4096 ArrayType(&'a ArrayType),
4097 SliceType(&'a SliceType),
4098 ReferenceType(&'a ReferenceType),
4099 PlaceholderType(&'a PlaceholderType),
4100 FnPointerType(&'a FnPointerType),
4101 ForType(&'a ForType),
4102 ImplTraitType(&'a ImplTraitType),
4103 DynTraitType(&'a DynTraitType),
4105 impl<'a> From<&'a ParenType> for &'a TypeRef {
4106 fn from(n: &'a ParenType) -> &'a TypeRef {
4107 TypeRef::cast(&n.syntax).unwrap()
4110 impl<'a> From<&'a TupleType> for &'a TypeRef {
4111 fn from(n: &'a TupleType) -> &'a TypeRef {
4112 TypeRef::cast(&n.syntax).unwrap()
4115 impl<'a> From<&'a NeverType> for &'a TypeRef {
4116 fn from(n: &'a NeverType) -> &'a TypeRef {
4117 TypeRef::cast(&n.syntax).unwrap()
4120 impl<'a> From<&'a PathType> for &'a TypeRef {
4121 fn from(n: &'a PathType) -> &'a TypeRef {
4122 TypeRef::cast(&n.syntax).unwrap()
4125 impl<'a> From<&'a PointerType> for &'a TypeRef {
4126 fn from(n: &'a PointerType) -> &'a TypeRef {
4127 TypeRef::cast(&n.syntax).unwrap()
4130 impl<'a> From<&'a ArrayType> for &'a TypeRef {
4131 fn from(n: &'a ArrayType) -> &'a TypeRef {
4132 TypeRef::cast(&n.syntax).unwrap()
4135 impl<'a> From<&'a SliceType> for &'a TypeRef {
4136 fn from(n: &'a SliceType) -> &'a TypeRef {
4137 TypeRef::cast(&n.syntax).unwrap()
4140 impl<'a> From<&'a ReferenceType> for &'a TypeRef {
4141 fn from(n: &'a ReferenceType) -> &'a TypeRef {
4142 TypeRef::cast(&n.syntax).unwrap()
4145 impl<'a> From<&'a PlaceholderType> for &'a TypeRef {
4146 fn from(n: &'a PlaceholderType) -> &'a TypeRef {
4147 TypeRef::cast(&n.syntax).unwrap()
4150 impl<'a> From<&'a FnPointerType> for &'a TypeRef {
4151 fn from(n: &'a FnPointerType) -> &'a TypeRef {
4152 TypeRef::cast(&n.syntax).unwrap()
4155 impl<'a> From<&'a ForType> for &'a TypeRef {
4156 fn from(n: &'a ForType) -> &'a TypeRef {
4157 TypeRef::cast(&n.syntax).unwrap()
4160 impl<'a> From<&'a ImplTraitType> for &'a TypeRef {
4161 fn from(n: &'a ImplTraitType) -> &'a TypeRef {
4162 TypeRef::cast(&n.syntax).unwrap()
4165 impl<'a> From<&'a DynTraitType> for &'a TypeRef {
4166 fn from(n: &'a DynTraitType) -> &'a TypeRef {
4167 TypeRef::cast(&n.syntax).unwrap()
4172 impl AstNode for TypeRef {
4173 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4174 match syntax.kind() {
4187 | DYN_TRAIT_TYPE => Some(TypeRef::from_repr(syntax.into_repr())),
4191 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4194 impl ToOwned for TypeRef {
4195 type Owned = TreeArc<TypeRef>;
4196 fn to_owned(&self) -> TreeArc<TypeRef> { TreeArc::cast(self.syntax.to_owned()) }
4200 pub fn kind(&self) -> TypeRefKind {
4201 match self.syntax.kind() {
4202 PAREN_TYPE => TypeRefKind::ParenType(ParenType::cast(&self.syntax).unwrap()),
4203 TUPLE_TYPE => TypeRefKind::TupleType(TupleType::cast(&self.syntax).unwrap()),
4204 NEVER_TYPE => TypeRefKind::NeverType(NeverType::cast(&self.syntax).unwrap()),
4205 PATH_TYPE => TypeRefKind::PathType(PathType::cast(&self.syntax).unwrap()),
4206 POINTER_TYPE => TypeRefKind::PointerType(PointerType::cast(&self.syntax).unwrap()),
4207 ARRAY_TYPE => TypeRefKind::ArrayType(ArrayType::cast(&self.syntax).unwrap()),
4208 SLICE_TYPE => TypeRefKind::SliceType(SliceType::cast(&self.syntax).unwrap()),
4209 REFERENCE_TYPE => TypeRefKind::ReferenceType(ReferenceType::cast(&self.syntax).unwrap()),
4210 PLACEHOLDER_TYPE => TypeRefKind::PlaceholderType(PlaceholderType::cast(&self.syntax).unwrap()),
4211 FN_POINTER_TYPE => TypeRefKind::FnPointerType(FnPointerType::cast(&self.syntax).unwrap()),
4212 FOR_TYPE => TypeRefKind::ForType(ForType::cast(&self.syntax).unwrap()),
4213 IMPL_TRAIT_TYPE => TypeRefKind::ImplTraitType(ImplTraitType::cast(&self.syntax).unwrap()),
4214 DYN_TRAIT_TYPE => TypeRefKind::DynTraitType(DynTraitType::cast(&self.syntax).unwrap()),
4215 _ => unreachable!(),
4223 #[derive(Debug, PartialEq, Eq, Hash)]
4224 #[repr(transparent)]
4225 pub struct UseItem {
4226 pub(crate) syntax: SyntaxNode,
4228 unsafe impl TransparentNewType for UseItem {
4229 type Repr = rowan::SyntaxNode;
4232 impl AstNode for UseItem {
4233 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4234 match syntax.kind() {
4235 USE_ITEM => Some(UseItem::from_repr(syntax.into_repr())),
4239 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4242 impl ToOwned for UseItem {
4243 type Owned = TreeArc<UseItem>;
4244 fn to_owned(&self) -> TreeArc<UseItem> { TreeArc::cast(self.syntax.to_owned()) }
4248 impl ast::AttrsOwner for UseItem {}
4250 pub fn use_tree(&self) -> Option<&UseTree> {
4251 super::child_opt(self)
4256 #[derive(Debug, PartialEq, Eq, Hash)]
4257 #[repr(transparent)]
4258 pub struct UseTree {
4259 pub(crate) syntax: SyntaxNode,
4261 unsafe impl TransparentNewType for UseTree {
4262 type Repr = rowan::SyntaxNode;
4265 impl AstNode for UseTree {
4266 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4267 match syntax.kind() {
4268 USE_TREE => Some(UseTree::from_repr(syntax.into_repr())),
4272 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4275 impl ToOwned for UseTree {
4276 type Owned = TreeArc<UseTree>;
4277 fn to_owned(&self) -> TreeArc<UseTree> { TreeArc::cast(self.syntax.to_owned()) }
4282 pub fn path(&self) -> Option<&Path> {
4283 super::child_opt(self)
4286 pub fn use_tree_list(&self) -> Option<&UseTreeList> {
4287 super::child_opt(self)
4290 pub fn alias(&self) -> Option<&Alias> {
4291 super::child_opt(self)
4296 #[derive(Debug, PartialEq, Eq, Hash)]
4297 #[repr(transparent)]
4298 pub struct UseTreeList {
4299 pub(crate) syntax: SyntaxNode,
4301 unsafe impl TransparentNewType for UseTreeList {
4302 type Repr = rowan::SyntaxNode;
4305 impl AstNode for UseTreeList {
4306 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4307 match syntax.kind() {
4308 USE_TREE_LIST => Some(UseTreeList::from_repr(syntax.into_repr())),
4312 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4315 impl ToOwned for UseTreeList {
4316 type Owned = TreeArc<UseTreeList>;
4317 fn to_owned(&self) -> TreeArc<UseTreeList> { TreeArc::cast(self.syntax.to_owned()) }
4322 pub fn use_trees(&self) -> impl Iterator<Item = &UseTree> {
4323 super::children(self)
4328 #[derive(Debug, PartialEq, Eq, Hash)]
4329 #[repr(transparent)]
4330 pub struct Visibility {
4331 pub(crate) syntax: SyntaxNode,
4333 unsafe impl TransparentNewType for Visibility {
4334 type Repr = rowan::SyntaxNode;
4337 impl AstNode for Visibility {
4338 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4339 match syntax.kind() {
4340 VISIBILITY => Some(Visibility::from_repr(syntax.into_repr())),
4344 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4347 impl ToOwned for Visibility {
4348 type Owned = TreeArc<Visibility>;
4349 fn to_owned(&self) -> TreeArc<Visibility> { TreeArc::cast(self.syntax.to_owned()) }
4356 #[derive(Debug, PartialEq, Eq, Hash)]
4357 #[repr(transparent)]
4358 pub struct WhereClause {
4359 pub(crate) syntax: SyntaxNode,
4361 unsafe impl TransparentNewType for WhereClause {
4362 type Repr = rowan::SyntaxNode;
4365 impl AstNode for WhereClause {
4366 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4367 match syntax.kind() {
4368 WHERE_CLAUSE => Some(WhereClause::from_repr(syntax.into_repr())),
4372 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4375 impl ToOwned for WhereClause {
4376 type Owned = TreeArc<WhereClause>;
4377 fn to_owned(&self) -> TreeArc<WhereClause> { TreeArc::cast(self.syntax.to_owned()) }
4382 pub fn predicates(&self) -> impl Iterator<Item = &WherePred> {
4383 super::children(self)
4388 #[derive(Debug, PartialEq, Eq, Hash)]
4389 #[repr(transparent)]
4390 pub struct WherePred {
4391 pub(crate) syntax: SyntaxNode,
4393 unsafe impl TransparentNewType for WherePred {
4394 type Repr = rowan::SyntaxNode;
4397 impl AstNode for WherePred {
4398 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4399 match syntax.kind() {
4400 WHERE_PRED => Some(WherePred::from_repr(syntax.into_repr())),
4404 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4407 impl ToOwned for WherePred {
4408 type Owned = TreeArc<WherePred>;
4409 fn to_owned(&self) -> TreeArc<WherePred> { TreeArc::cast(self.syntax.to_owned()) }
4413 impl ast::TypeBoundsOwner for WherePred {}
4415 pub fn type_ref(&self) -> Option<&TypeRef> {
4416 super::child_opt(self)
4421 #[derive(Debug, PartialEq, Eq, Hash)]
4422 #[repr(transparent)]
4423 pub struct WhileExpr {
4424 pub(crate) syntax: SyntaxNode,
4426 unsafe impl TransparentNewType for WhileExpr {
4427 type Repr = rowan::SyntaxNode;
4430 impl AstNode for WhileExpr {
4431 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4432 match syntax.kind() {
4433 WHILE_EXPR => Some(WhileExpr::from_repr(syntax.into_repr())),
4437 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4440 impl ToOwned for WhileExpr {
4441 type Owned = TreeArc<WhileExpr>;
4442 fn to_owned(&self) -> TreeArc<WhileExpr> { TreeArc::cast(self.syntax.to_owned()) }
4446 impl ast::LoopBodyOwner for WhileExpr {}
4448 pub fn condition(&self) -> Option<&Condition> {
4449 super::child_opt(self)