1 // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run
2 // Do not edit manually
4 //! This module contains auto-generated Rust AST. Like `SyntaxNode`s, AST nodes
5 //! are generic over ownership: `X<'a>` things are `Copy` references, `XNode`
6 //! are Arc-based. You can switch between the two variants using `.owned` and
7 //! `.borrowed` functions. Most of the code works with borowed mode, and only
8 //! this mode has all AST accessors.
10 #![cfg_attr(rustfmt, rustfmt_skip)]
12 use rowan::TransparentNewType;
15 SyntaxNode, SyntaxKind::*,
16 syntax_node::{RaTypes, TreeArc},
21 #[derive(Debug, PartialEq, Eq, Hash)]
24 pub(crate) syntax: SyntaxNode,
26 unsafe impl TransparentNewType for Alias {
27 type Repr = rowan::SyntaxNode<RaTypes>;
30 impl AstNode for Alias {
31 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
33 ALIAS => Some(Alias::from_repr(syntax.into_repr())),
37 fn syntax(&self) -> &SyntaxNode { &self.syntax }
40 impl ToOwned for Alias {
41 type Owned = TreeArc<Alias>;
42 fn to_owned(&self) -> TreeArc<Alias> { TreeArc::cast(self.syntax.to_owned()) }
46 impl ast::NameOwner for Alias {}
50 #[derive(Debug, PartialEq, Eq, Hash)]
53 pub(crate) syntax: SyntaxNode,
55 unsafe impl TransparentNewType for ArgList {
56 type Repr = rowan::SyntaxNode<RaTypes>;
59 impl AstNode for ArgList {
60 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
62 ARG_LIST => Some(ArgList::from_repr(syntax.into_repr())),
66 fn syntax(&self) -> &SyntaxNode { &self.syntax }
69 impl ToOwned for ArgList {
70 type Owned = TreeArc<ArgList>;
71 fn to_owned(&self) -> TreeArc<ArgList> { TreeArc::cast(self.syntax.to_owned()) }
76 pub fn args(&self) -> impl Iterator<Item = &Expr> {
82 #[derive(Debug, PartialEq, Eq, Hash)]
84 pub struct ArrayExpr {
85 pub(crate) syntax: SyntaxNode,
87 unsafe impl TransparentNewType for ArrayExpr {
88 type Repr = rowan::SyntaxNode<RaTypes>;
91 impl AstNode for ArrayExpr {
92 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
94 ARRAY_EXPR => Some(ArrayExpr::from_repr(syntax.into_repr())),
98 fn syntax(&self) -> &SyntaxNode { &self.syntax }
101 impl ToOwned for ArrayExpr {
102 type Owned = TreeArc<ArrayExpr>;
103 fn to_owned(&self) -> TreeArc<ArrayExpr> { TreeArc::cast(self.syntax.to_owned()) }
108 pub fn exprs(&self) -> impl Iterator<Item = &Expr> {
109 super::children(self)
114 #[derive(Debug, PartialEq, Eq, Hash)]
116 pub struct ArrayType {
117 pub(crate) syntax: SyntaxNode,
119 unsafe impl TransparentNewType for ArrayType {
120 type Repr = rowan::SyntaxNode<RaTypes>;
123 impl AstNode for ArrayType {
124 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
125 match syntax.kind() {
126 ARRAY_TYPE => Some(ArrayType::from_repr(syntax.into_repr())),
130 fn syntax(&self) -> &SyntaxNode { &self.syntax }
133 impl ToOwned for ArrayType {
134 type Owned = TreeArc<ArrayType>;
135 fn to_owned(&self) -> TreeArc<ArrayType> { TreeArc::cast(self.syntax.to_owned()) }
140 pub fn type_ref(&self) -> Option<&TypeRef> {
141 super::child_opt(self)
144 pub fn expr(&self) -> Option<&Expr> {
145 super::child_opt(self)
150 #[derive(Debug, PartialEq, Eq, Hash)]
152 pub struct AssocTypeArg {
153 pub(crate) syntax: SyntaxNode,
155 unsafe impl TransparentNewType for AssocTypeArg {
156 type Repr = rowan::SyntaxNode<RaTypes>;
159 impl AstNode for AssocTypeArg {
160 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
161 match syntax.kind() {
162 ASSOC_TYPE_ARG => Some(AssocTypeArg::from_repr(syntax.into_repr())),
166 fn syntax(&self) -> &SyntaxNode { &self.syntax }
169 impl ToOwned for AssocTypeArg {
170 type Owned = TreeArc<AssocTypeArg>;
171 fn to_owned(&self) -> TreeArc<AssocTypeArg> { TreeArc::cast(self.syntax.to_owned()) }
176 pub fn name_ref(&self) -> Option<&NameRef> {
177 super::child_opt(self)
180 pub fn type_ref(&self) -> Option<&TypeRef> {
181 super::child_opt(self)
186 #[derive(Debug, PartialEq, Eq, Hash)]
189 pub(crate) syntax: SyntaxNode,
191 unsafe impl TransparentNewType for Attr {
192 type Repr = rowan::SyntaxNode<RaTypes>;
195 impl AstNode for Attr {
196 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
197 match syntax.kind() {
198 ATTR => Some(Attr::from_repr(syntax.into_repr())),
202 fn syntax(&self) -> &SyntaxNode { &self.syntax }
205 impl ToOwned for Attr {
206 type Owned = TreeArc<Attr>;
207 fn to_owned(&self) -> TreeArc<Attr> { TreeArc::cast(self.syntax.to_owned()) }
212 pub fn value(&self) -> Option<&TokenTree> {
213 super::child_opt(self)
218 #[derive(Debug, PartialEq, Eq, Hash)]
221 pub(crate) syntax: SyntaxNode,
223 unsafe impl TransparentNewType for BinExpr {
224 type Repr = rowan::SyntaxNode<RaTypes>;
227 impl AstNode for BinExpr {
228 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
229 match syntax.kind() {
230 BIN_EXPR => Some(BinExpr::from_repr(syntax.into_repr())),
234 fn syntax(&self) -> &SyntaxNode { &self.syntax }
237 impl ToOwned for BinExpr {
238 type Owned = TreeArc<BinExpr>;
239 fn to_owned(&self) -> TreeArc<BinExpr> { TreeArc::cast(self.syntax.to_owned()) }
246 #[derive(Debug, PartialEq, Eq, Hash)]
249 pub(crate) syntax: SyntaxNode,
251 unsafe impl TransparentNewType for BindPat {
252 type Repr = rowan::SyntaxNode<RaTypes>;
255 impl AstNode for BindPat {
256 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
257 match syntax.kind() {
258 BIND_PAT => Some(BindPat::from_repr(syntax.into_repr())),
262 fn syntax(&self) -> &SyntaxNode { &self.syntax }
265 impl ToOwned for BindPat {
266 type Owned = TreeArc<BindPat>;
267 fn to_owned(&self) -> TreeArc<BindPat> { TreeArc::cast(self.syntax.to_owned()) }
271 impl ast::NameOwner for BindPat {}
273 pub fn pat(&self) -> Option<&Pat> {
274 super::child_opt(self)
279 #[derive(Debug, PartialEq, Eq, Hash)]
282 pub(crate) syntax: SyntaxNode,
284 unsafe impl TransparentNewType for Block {
285 type Repr = rowan::SyntaxNode<RaTypes>;
288 impl AstNode for Block {
289 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
290 match syntax.kind() {
291 BLOCK => Some(Block::from_repr(syntax.into_repr())),
295 fn syntax(&self) -> &SyntaxNode { &self.syntax }
298 impl ToOwned for Block {
299 type Owned = TreeArc<Block>;
300 fn to_owned(&self) -> TreeArc<Block> { TreeArc::cast(self.syntax.to_owned()) }
304 impl ast::AttrsOwner for Block {}
306 pub fn statements(&self) -> impl Iterator<Item = &Stmt> {
307 super::children(self)
310 pub fn expr(&self) -> Option<&Expr> {
311 super::child_opt(self)
316 #[derive(Debug, PartialEq, Eq, Hash)]
318 pub struct BlockExpr {
319 pub(crate) syntax: SyntaxNode,
321 unsafe impl TransparentNewType for BlockExpr {
322 type Repr = rowan::SyntaxNode<RaTypes>;
325 impl AstNode for BlockExpr {
326 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
327 match syntax.kind() {
328 BLOCK_EXPR => Some(BlockExpr::from_repr(syntax.into_repr())),
332 fn syntax(&self) -> &SyntaxNode { &self.syntax }
335 impl ToOwned for BlockExpr {
336 type Owned = TreeArc<BlockExpr>;
337 fn to_owned(&self) -> TreeArc<BlockExpr> { TreeArc::cast(self.syntax.to_owned()) }
342 pub fn block(&self) -> Option<&Block> {
343 super::child_opt(self)
348 #[derive(Debug, PartialEq, Eq, Hash)]
350 pub struct BreakExpr {
351 pub(crate) syntax: SyntaxNode,
353 unsafe impl TransparentNewType for BreakExpr {
354 type Repr = rowan::SyntaxNode<RaTypes>;
357 impl AstNode for BreakExpr {
358 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
359 match syntax.kind() {
360 BREAK_EXPR => Some(BreakExpr::from_repr(syntax.into_repr())),
364 fn syntax(&self) -> &SyntaxNode { &self.syntax }
367 impl ToOwned for BreakExpr {
368 type Owned = TreeArc<BreakExpr>;
369 fn to_owned(&self) -> TreeArc<BreakExpr> { TreeArc::cast(self.syntax.to_owned()) }
374 pub fn expr(&self) -> Option<&Expr> {
375 super::child_opt(self)
380 #[derive(Debug, PartialEq, Eq, Hash)]
383 pub(crate) syntax: SyntaxNode,
385 unsafe impl TransparentNewType for Byte {
386 type Repr = rowan::SyntaxNode<RaTypes>;
389 impl AstNode for Byte {
390 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
391 match syntax.kind() {
392 BYTE => Some(Byte::from_repr(syntax.into_repr())),
396 fn syntax(&self) -> &SyntaxNode { &self.syntax }
399 impl ToOwned for Byte {
400 type Owned = TreeArc<Byte>;
401 fn to_owned(&self) -> TreeArc<Byte> { TreeArc::cast(self.syntax.to_owned()) }
405 impl ast::AstToken for Byte {}
409 #[derive(Debug, PartialEq, Eq, Hash)]
411 pub struct ByteString {
412 pub(crate) syntax: SyntaxNode,
414 unsafe impl TransparentNewType for ByteString {
415 type Repr = rowan::SyntaxNode<RaTypes>;
418 impl AstNode for ByteString {
419 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
420 match syntax.kind() {
421 BYTE_STRING => Some(ByteString::from_repr(syntax.into_repr())),
425 fn syntax(&self) -> &SyntaxNode { &self.syntax }
428 impl ToOwned for ByteString {
429 type Owned = TreeArc<ByteString>;
430 fn to_owned(&self) -> TreeArc<ByteString> { TreeArc::cast(self.syntax.to_owned()) }
434 impl ast::AstToken for ByteString {}
438 #[derive(Debug, PartialEq, Eq, Hash)]
440 pub struct CallExpr {
441 pub(crate) syntax: SyntaxNode,
443 unsafe impl TransparentNewType for CallExpr {
444 type Repr = rowan::SyntaxNode<RaTypes>;
447 impl AstNode for CallExpr {
448 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
449 match syntax.kind() {
450 CALL_EXPR => Some(CallExpr::from_repr(syntax.into_repr())),
454 fn syntax(&self) -> &SyntaxNode { &self.syntax }
457 impl ToOwned for CallExpr {
458 type Owned = TreeArc<CallExpr>;
459 fn to_owned(&self) -> TreeArc<CallExpr> { TreeArc::cast(self.syntax.to_owned()) }
463 impl ast::ArgListOwner for CallExpr {}
465 pub fn expr(&self) -> Option<&Expr> {
466 super::child_opt(self)
471 #[derive(Debug, PartialEq, Eq, Hash)]
473 pub struct CastExpr {
474 pub(crate) syntax: SyntaxNode,
476 unsafe impl TransparentNewType for CastExpr {
477 type Repr = rowan::SyntaxNode<RaTypes>;
480 impl AstNode for CastExpr {
481 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
482 match syntax.kind() {
483 CAST_EXPR => Some(CastExpr::from_repr(syntax.into_repr())),
487 fn syntax(&self) -> &SyntaxNode { &self.syntax }
490 impl ToOwned for CastExpr {
491 type Owned = TreeArc<CastExpr>;
492 fn to_owned(&self) -> TreeArc<CastExpr> { TreeArc::cast(self.syntax.to_owned()) }
497 pub fn expr(&self) -> Option<&Expr> {
498 super::child_opt(self)
501 pub fn type_ref(&self) -> Option<&TypeRef> {
502 super::child_opt(self)
507 #[derive(Debug, PartialEq, Eq, Hash)]
510 pub(crate) syntax: SyntaxNode,
512 unsafe impl TransparentNewType for Char {
513 type Repr = rowan::SyntaxNode<RaTypes>;
516 impl AstNode for Char {
517 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
518 match syntax.kind() {
519 CHAR => Some(Char::from_repr(syntax.into_repr())),
523 fn syntax(&self) -> &SyntaxNode { &self.syntax }
526 impl ToOwned for Char {
527 type Owned = TreeArc<Char>;
528 fn to_owned(&self) -> TreeArc<Char> { TreeArc::cast(self.syntax.to_owned()) }
532 impl ast::AstToken for Char {}
536 #[derive(Debug, PartialEq, Eq, Hash)]
539 pub(crate) syntax: SyntaxNode,
541 unsafe impl TransparentNewType for Comment {
542 type Repr = rowan::SyntaxNode<RaTypes>;
545 impl AstNode for Comment {
546 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
547 match syntax.kind() {
548 COMMENT => Some(Comment::from_repr(syntax.into_repr())),
552 fn syntax(&self) -> &SyntaxNode { &self.syntax }
555 impl ToOwned for Comment {
556 type Owned = TreeArc<Comment>;
557 fn to_owned(&self) -> TreeArc<Comment> { TreeArc::cast(self.syntax.to_owned()) }
561 impl ast::AstToken for Comment {}
565 #[derive(Debug, PartialEq, Eq, Hash)]
567 pub struct Condition {
568 pub(crate) syntax: SyntaxNode,
570 unsafe impl TransparentNewType for Condition {
571 type Repr = rowan::SyntaxNode<RaTypes>;
574 impl AstNode for Condition {
575 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
576 match syntax.kind() {
577 CONDITION => Some(Condition::from_repr(syntax.into_repr())),
581 fn syntax(&self) -> &SyntaxNode { &self.syntax }
584 impl ToOwned for Condition {
585 type Owned = TreeArc<Condition>;
586 fn to_owned(&self) -> TreeArc<Condition> { TreeArc::cast(self.syntax.to_owned()) }
591 pub fn pat(&self) -> Option<&Pat> {
592 super::child_opt(self)
595 pub fn expr(&self) -> Option<&Expr> {
596 super::child_opt(self)
601 #[derive(Debug, PartialEq, Eq, Hash)]
603 pub struct ConstDef {
604 pub(crate) syntax: SyntaxNode,
606 unsafe impl TransparentNewType for ConstDef {
607 type Repr = rowan::SyntaxNode<RaTypes>;
610 impl AstNode for ConstDef {
611 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
612 match syntax.kind() {
613 CONST_DEF => Some(ConstDef::from_repr(syntax.into_repr())),
617 fn syntax(&self) -> &SyntaxNode { &self.syntax }
620 impl ToOwned for ConstDef {
621 type Owned = TreeArc<ConstDef>;
622 fn to_owned(&self) -> TreeArc<ConstDef> { TreeArc::cast(self.syntax.to_owned()) }
626 impl ast::VisibilityOwner for ConstDef {}
627 impl ast::NameOwner for ConstDef {}
628 impl ast::TypeParamsOwner for ConstDef {}
629 impl ast::AttrsOwner for ConstDef {}
630 impl ast::DocCommentsOwner for ConstDef {}
631 impl ast::TypeAscriptionOwner for ConstDef {}
635 #[derive(Debug, PartialEq, Eq, Hash)]
637 pub struct ContinueExpr {
638 pub(crate) syntax: SyntaxNode,
640 unsafe impl TransparentNewType for ContinueExpr {
641 type Repr = rowan::SyntaxNode<RaTypes>;
644 impl AstNode for ContinueExpr {
645 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
646 match syntax.kind() {
647 CONTINUE_EXPR => Some(ContinueExpr::from_repr(syntax.into_repr())),
651 fn syntax(&self) -> &SyntaxNode { &self.syntax }
654 impl ToOwned for ContinueExpr {
655 type Owned = TreeArc<ContinueExpr>;
656 fn to_owned(&self) -> TreeArc<ContinueExpr> { TreeArc::cast(self.syntax.to_owned()) }
663 #[derive(Debug, PartialEq, Eq, Hash)]
665 pub struct DynTraitType {
666 pub(crate) syntax: SyntaxNode,
668 unsafe impl TransparentNewType for DynTraitType {
669 type Repr = rowan::SyntaxNode<RaTypes>;
672 impl AstNode for DynTraitType {
673 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
674 match syntax.kind() {
675 DYN_TRAIT_TYPE => Some(DynTraitType::from_repr(syntax.into_repr())),
679 fn syntax(&self) -> &SyntaxNode { &self.syntax }
682 impl ToOwned for DynTraitType {
683 type Owned = TreeArc<DynTraitType>;
684 fn to_owned(&self) -> TreeArc<DynTraitType> { TreeArc::cast(self.syntax.to_owned()) }
688 impl ast::TypeBoundsOwner for DynTraitType {}
692 #[derive(Debug, PartialEq, Eq, Hash)]
695 pub(crate) syntax: SyntaxNode,
697 unsafe impl TransparentNewType for EnumDef {
698 type Repr = rowan::SyntaxNode<RaTypes>;
701 impl AstNode for EnumDef {
702 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
703 match syntax.kind() {
704 ENUM_DEF => Some(EnumDef::from_repr(syntax.into_repr())),
708 fn syntax(&self) -> &SyntaxNode { &self.syntax }
711 impl ToOwned for EnumDef {
712 type Owned = TreeArc<EnumDef>;
713 fn to_owned(&self) -> TreeArc<EnumDef> { TreeArc::cast(self.syntax.to_owned()) }
717 impl ast::VisibilityOwner for EnumDef {}
718 impl ast::NameOwner for EnumDef {}
719 impl ast::TypeParamsOwner for EnumDef {}
720 impl ast::AttrsOwner for EnumDef {}
721 impl ast::DocCommentsOwner for EnumDef {}
723 pub fn variant_list(&self) -> Option<&EnumVariantList> {
724 super::child_opt(self)
729 #[derive(Debug, PartialEq, Eq, Hash)]
731 pub struct EnumVariant {
732 pub(crate) syntax: SyntaxNode,
734 unsafe impl TransparentNewType for EnumVariant {
735 type Repr = rowan::SyntaxNode<RaTypes>;
738 impl AstNode for EnumVariant {
739 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
740 match syntax.kind() {
741 ENUM_VARIANT => Some(EnumVariant::from_repr(syntax.into_repr())),
745 fn syntax(&self) -> &SyntaxNode { &self.syntax }
748 impl ToOwned for EnumVariant {
749 type Owned = TreeArc<EnumVariant>;
750 fn to_owned(&self) -> TreeArc<EnumVariant> { TreeArc::cast(self.syntax.to_owned()) }
754 impl ast::NameOwner for EnumVariant {}
755 impl ast::DocCommentsOwner for EnumVariant {}
756 impl ast::AttrsOwner for EnumVariant {}
758 pub fn expr(&self) -> Option<&Expr> {
759 super::child_opt(self)
764 #[derive(Debug, PartialEq, Eq, Hash)]
766 pub struct EnumVariantList {
767 pub(crate) syntax: SyntaxNode,
769 unsafe impl TransparentNewType for EnumVariantList {
770 type Repr = rowan::SyntaxNode<RaTypes>;
773 impl AstNode for EnumVariantList {
774 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
775 match syntax.kind() {
776 ENUM_VARIANT_LIST => Some(EnumVariantList::from_repr(syntax.into_repr())),
780 fn syntax(&self) -> &SyntaxNode { &self.syntax }
783 impl ToOwned for EnumVariantList {
784 type Owned = TreeArc<EnumVariantList>;
785 fn to_owned(&self) -> TreeArc<EnumVariantList> { TreeArc::cast(self.syntax.to_owned()) }
789 impl EnumVariantList {
790 pub fn variants(&self) -> impl Iterator<Item = &EnumVariant> {
791 super::children(self)
796 #[derive(Debug, PartialEq, Eq, Hash)]
799 pub(crate) syntax: SyntaxNode,
801 unsafe impl TransparentNewType for Expr {
802 type Repr = rowan::SyntaxNode<RaTypes>;
805 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
806 pub enum ExprKind<'a> {
807 TupleExpr(&'a TupleExpr),
808 ArrayExpr(&'a ArrayExpr),
809 ParenExpr(&'a ParenExpr),
810 PathExpr(&'a PathExpr),
811 LambdaExpr(&'a LambdaExpr),
813 LoopExpr(&'a LoopExpr),
814 ForExpr(&'a ForExpr),
815 WhileExpr(&'a WhileExpr),
816 ContinueExpr(&'a ContinueExpr),
817 BreakExpr(&'a BreakExpr),
819 BlockExpr(&'a BlockExpr),
820 ReturnExpr(&'a ReturnExpr),
821 MatchExpr(&'a MatchExpr),
822 StructLit(&'a StructLit),
823 CallExpr(&'a CallExpr),
824 IndexExpr(&'a IndexExpr),
825 MethodCallExpr(&'a MethodCallExpr),
826 FieldExpr(&'a FieldExpr),
827 TryExpr(&'a TryExpr),
828 CastExpr(&'a CastExpr),
829 RefExpr(&'a RefExpr),
830 PrefixExpr(&'a PrefixExpr),
831 RangeExpr(&'a RangeExpr),
832 BinExpr(&'a BinExpr),
833 Literal(&'a Literal),
835 impl<'a> From<&'a TupleExpr> for &'a Expr {
836 fn from(n: &'a TupleExpr) -> &'a Expr {
837 Expr::cast(&n.syntax).unwrap()
840 impl<'a> From<&'a ArrayExpr> for &'a Expr {
841 fn from(n: &'a ArrayExpr) -> &'a Expr {
842 Expr::cast(&n.syntax).unwrap()
845 impl<'a> From<&'a ParenExpr> for &'a Expr {
846 fn from(n: &'a ParenExpr) -> &'a Expr {
847 Expr::cast(&n.syntax).unwrap()
850 impl<'a> From<&'a PathExpr> for &'a Expr {
851 fn from(n: &'a PathExpr) -> &'a Expr {
852 Expr::cast(&n.syntax).unwrap()
855 impl<'a> From<&'a LambdaExpr> for &'a Expr {
856 fn from(n: &'a LambdaExpr) -> &'a Expr {
857 Expr::cast(&n.syntax).unwrap()
860 impl<'a> From<&'a IfExpr> for &'a Expr {
861 fn from(n: &'a IfExpr) -> &'a Expr {
862 Expr::cast(&n.syntax).unwrap()
865 impl<'a> From<&'a LoopExpr> for &'a Expr {
866 fn from(n: &'a LoopExpr) -> &'a Expr {
867 Expr::cast(&n.syntax).unwrap()
870 impl<'a> From<&'a ForExpr> for &'a Expr {
871 fn from(n: &'a ForExpr) -> &'a Expr {
872 Expr::cast(&n.syntax).unwrap()
875 impl<'a> From<&'a WhileExpr> for &'a Expr {
876 fn from(n: &'a WhileExpr) -> &'a Expr {
877 Expr::cast(&n.syntax).unwrap()
880 impl<'a> From<&'a ContinueExpr> for &'a Expr {
881 fn from(n: &'a ContinueExpr) -> &'a Expr {
882 Expr::cast(&n.syntax).unwrap()
885 impl<'a> From<&'a BreakExpr> for &'a Expr {
886 fn from(n: &'a BreakExpr) -> &'a Expr {
887 Expr::cast(&n.syntax).unwrap()
890 impl<'a> From<&'a Label> for &'a Expr {
891 fn from(n: &'a Label) -> &'a Expr {
892 Expr::cast(&n.syntax).unwrap()
895 impl<'a> From<&'a BlockExpr> for &'a Expr {
896 fn from(n: &'a BlockExpr) -> &'a Expr {
897 Expr::cast(&n.syntax).unwrap()
900 impl<'a> From<&'a ReturnExpr> for &'a Expr {
901 fn from(n: &'a ReturnExpr) -> &'a Expr {
902 Expr::cast(&n.syntax).unwrap()
905 impl<'a> From<&'a MatchExpr> for &'a Expr {
906 fn from(n: &'a MatchExpr) -> &'a Expr {
907 Expr::cast(&n.syntax).unwrap()
910 impl<'a> From<&'a StructLit> for &'a Expr {
911 fn from(n: &'a StructLit) -> &'a Expr {
912 Expr::cast(&n.syntax).unwrap()
915 impl<'a> From<&'a CallExpr> for &'a Expr {
916 fn from(n: &'a CallExpr) -> &'a Expr {
917 Expr::cast(&n.syntax).unwrap()
920 impl<'a> From<&'a IndexExpr> for &'a Expr {
921 fn from(n: &'a IndexExpr) -> &'a Expr {
922 Expr::cast(&n.syntax).unwrap()
925 impl<'a> From<&'a MethodCallExpr> for &'a Expr {
926 fn from(n: &'a MethodCallExpr) -> &'a Expr {
927 Expr::cast(&n.syntax).unwrap()
930 impl<'a> From<&'a FieldExpr> for &'a Expr {
931 fn from(n: &'a FieldExpr) -> &'a Expr {
932 Expr::cast(&n.syntax).unwrap()
935 impl<'a> From<&'a TryExpr> for &'a Expr {
936 fn from(n: &'a TryExpr) -> &'a Expr {
937 Expr::cast(&n.syntax).unwrap()
940 impl<'a> From<&'a CastExpr> for &'a Expr {
941 fn from(n: &'a CastExpr) -> &'a Expr {
942 Expr::cast(&n.syntax).unwrap()
945 impl<'a> From<&'a RefExpr> for &'a Expr {
946 fn from(n: &'a RefExpr) -> &'a Expr {
947 Expr::cast(&n.syntax).unwrap()
950 impl<'a> From<&'a PrefixExpr> for &'a Expr {
951 fn from(n: &'a PrefixExpr) -> &'a Expr {
952 Expr::cast(&n.syntax).unwrap()
955 impl<'a> From<&'a RangeExpr> for &'a Expr {
956 fn from(n: &'a RangeExpr) -> &'a Expr {
957 Expr::cast(&n.syntax).unwrap()
960 impl<'a> From<&'a BinExpr> for &'a Expr {
961 fn from(n: &'a BinExpr) -> &'a Expr {
962 Expr::cast(&n.syntax).unwrap()
965 impl<'a> From<&'a Literal> for &'a Expr {
966 fn from(n: &'a Literal) -> &'a Expr {
967 Expr::cast(&n.syntax).unwrap()
972 impl AstNode for Expr {
973 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
974 match syntax.kind() {
1001 | LITERAL => Some(Expr::from_repr(syntax.into_repr())),
1005 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1008 impl ToOwned for Expr {
1009 type Owned = TreeArc<Expr>;
1010 fn to_owned(&self) -> TreeArc<Expr> { TreeArc::cast(self.syntax.to_owned()) }
1014 pub fn kind(&self) -> ExprKind {
1015 match self.syntax.kind() {
1016 TUPLE_EXPR => ExprKind::TupleExpr(TupleExpr::cast(&self.syntax).unwrap()),
1017 ARRAY_EXPR => ExprKind::ArrayExpr(ArrayExpr::cast(&self.syntax).unwrap()),
1018 PAREN_EXPR => ExprKind::ParenExpr(ParenExpr::cast(&self.syntax).unwrap()),
1019 PATH_EXPR => ExprKind::PathExpr(PathExpr::cast(&self.syntax).unwrap()),
1020 LAMBDA_EXPR => ExprKind::LambdaExpr(LambdaExpr::cast(&self.syntax).unwrap()),
1021 IF_EXPR => ExprKind::IfExpr(IfExpr::cast(&self.syntax).unwrap()),
1022 LOOP_EXPR => ExprKind::LoopExpr(LoopExpr::cast(&self.syntax).unwrap()),
1023 FOR_EXPR => ExprKind::ForExpr(ForExpr::cast(&self.syntax).unwrap()),
1024 WHILE_EXPR => ExprKind::WhileExpr(WhileExpr::cast(&self.syntax).unwrap()),
1025 CONTINUE_EXPR => ExprKind::ContinueExpr(ContinueExpr::cast(&self.syntax).unwrap()),
1026 BREAK_EXPR => ExprKind::BreakExpr(BreakExpr::cast(&self.syntax).unwrap()),
1027 LABEL => ExprKind::Label(Label::cast(&self.syntax).unwrap()),
1028 BLOCK_EXPR => ExprKind::BlockExpr(BlockExpr::cast(&self.syntax).unwrap()),
1029 RETURN_EXPR => ExprKind::ReturnExpr(ReturnExpr::cast(&self.syntax).unwrap()),
1030 MATCH_EXPR => ExprKind::MatchExpr(MatchExpr::cast(&self.syntax).unwrap()),
1031 STRUCT_LIT => ExprKind::StructLit(StructLit::cast(&self.syntax).unwrap()),
1032 CALL_EXPR => ExprKind::CallExpr(CallExpr::cast(&self.syntax).unwrap()),
1033 INDEX_EXPR => ExprKind::IndexExpr(IndexExpr::cast(&self.syntax).unwrap()),
1034 METHOD_CALL_EXPR => ExprKind::MethodCallExpr(MethodCallExpr::cast(&self.syntax).unwrap()),
1035 FIELD_EXPR => ExprKind::FieldExpr(FieldExpr::cast(&self.syntax).unwrap()),
1036 TRY_EXPR => ExprKind::TryExpr(TryExpr::cast(&self.syntax).unwrap()),
1037 CAST_EXPR => ExprKind::CastExpr(CastExpr::cast(&self.syntax).unwrap()),
1038 REF_EXPR => ExprKind::RefExpr(RefExpr::cast(&self.syntax).unwrap()),
1039 PREFIX_EXPR => ExprKind::PrefixExpr(PrefixExpr::cast(&self.syntax).unwrap()),
1040 RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(&self.syntax).unwrap()),
1041 BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(&self.syntax).unwrap()),
1042 LITERAL => ExprKind::Literal(Literal::cast(&self.syntax).unwrap()),
1043 _ => unreachable!(),
1051 #[derive(Debug, PartialEq, Eq, Hash)]
1052 #[repr(transparent)]
1053 pub struct ExprStmt {
1054 pub(crate) syntax: SyntaxNode,
1056 unsafe impl TransparentNewType for ExprStmt {
1057 type Repr = rowan::SyntaxNode<RaTypes>;
1060 impl AstNode for ExprStmt {
1061 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1062 match syntax.kind() {
1063 EXPR_STMT => Some(ExprStmt::from_repr(syntax.into_repr())),
1067 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1070 impl ToOwned for ExprStmt {
1071 type Owned = TreeArc<ExprStmt>;
1072 fn to_owned(&self) -> TreeArc<ExprStmt> { TreeArc::cast(self.syntax.to_owned()) }
1077 pub fn expr(&self) -> Option<&Expr> {
1078 super::child_opt(self)
1083 #[derive(Debug, PartialEq, Eq, Hash)]
1084 #[repr(transparent)]
1085 pub struct ExternCrateItem {
1086 pub(crate) syntax: SyntaxNode,
1088 unsafe impl TransparentNewType for ExternCrateItem {
1089 type Repr = rowan::SyntaxNode<RaTypes>;
1092 impl AstNode for ExternCrateItem {
1093 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1094 match syntax.kind() {
1095 EXTERN_CRATE_ITEM => Some(ExternCrateItem::from_repr(syntax.into_repr())),
1099 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1102 impl ToOwned for ExternCrateItem {
1103 type Owned = TreeArc<ExternCrateItem>;
1104 fn to_owned(&self) -> TreeArc<ExternCrateItem> { TreeArc::cast(self.syntax.to_owned()) }
1108 impl ExternCrateItem {
1109 pub fn name_ref(&self) -> Option<&NameRef> {
1110 super::child_opt(self)
1113 pub fn alias(&self) -> Option<&Alias> {
1114 super::child_opt(self)
1119 #[derive(Debug, PartialEq, Eq, Hash)]
1120 #[repr(transparent)]
1121 pub struct FalseKw {
1122 pub(crate) syntax: SyntaxNode,
1124 unsafe impl TransparentNewType for FalseKw {
1125 type Repr = rowan::SyntaxNode<RaTypes>;
1128 impl AstNode for FalseKw {
1129 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1130 match syntax.kind() {
1131 FALSE_KW => Some(FalseKw::from_repr(syntax.into_repr())),
1135 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1138 impl ToOwned for FalseKw {
1139 type Owned = TreeArc<FalseKw>;
1140 fn to_owned(&self) -> TreeArc<FalseKw> { TreeArc::cast(self.syntax.to_owned()) }
1144 impl ast::AstToken for FalseKw {}
1148 #[derive(Debug, PartialEq, Eq, Hash)]
1149 #[repr(transparent)]
1150 pub struct FieldExpr {
1151 pub(crate) syntax: SyntaxNode,
1153 unsafe impl TransparentNewType for FieldExpr {
1154 type Repr = rowan::SyntaxNode<RaTypes>;
1157 impl AstNode for FieldExpr {
1158 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1159 match syntax.kind() {
1160 FIELD_EXPR => Some(FieldExpr::from_repr(syntax.into_repr())),
1164 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1167 impl ToOwned for FieldExpr {
1168 type Owned = TreeArc<FieldExpr>;
1169 fn to_owned(&self) -> TreeArc<FieldExpr> { TreeArc::cast(self.syntax.to_owned()) }
1174 pub fn expr(&self) -> Option<&Expr> {
1175 super::child_opt(self)
1178 pub fn name_ref(&self) -> Option<&NameRef> {
1179 super::child_opt(self)
1184 #[derive(Debug, PartialEq, Eq, Hash)]
1185 #[repr(transparent)]
1186 pub struct FieldPat {
1187 pub(crate) syntax: SyntaxNode,
1189 unsafe impl TransparentNewType for FieldPat {
1190 type Repr = rowan::SyntaxNode<RaTypes>;
1193 impl AstNode for FieldPat {
1194 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1195 match syntax.kind() {
1196 FIELD_PAT => Some(FieldPat::from_repr(syntax.into_repr())),
1200 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1203 impl ToOwned for FieldPat {
1204 type Owned = TreeArc<FieldPat>;
1205 fn to_owned(&self) -> TreeArc<FieldPat> { TreeArc::cast(self.syntax.to_owned()) }
1209 impl ast::NameOwner for FieldPat {}
1211 pub fn pat(&self) -> Option<&Pat> {
1212 super::child_opt(self)
1217 #[derive(Debug, PartialEq, Eq, Hash)]
1218 #[repr(transparent)]
1219 pub struct FieldPatList {
1220 pub(crate) syntax: SyntaxNode,
1222 unsafe impl TransparentNewType for FieldPatList {
1223 type Repr = rowan::SyntaxNode<RaTypes>;
1226 impl AstNode for FieldPatList {
1227 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1228 match syntax.kind() {
1229 FIELD_PAT_LIST => Some(FieldPatList::from_repr(syntax.into_repr())),
1233 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1236 impl ToOwned for FieldPatList {
1237 type Owned = TreeArc<FieldPatList>;
1238 fn to_owned(&self) -> TreeArc<FieldPatList> { TreeArc::cast(self.syntax.to_owned()) }
1243 pub fn field_pats(&self) -> impl Iterator<Item = &FieldPat> {
1244 super::children(self)
1247 pub fn bind_pats(&self) -> impl Iterator<Item = &BindPat> {
1248 super::children(self)
1253 #[derive(Debug, PartialEq, Eq, Hash)]
1254 #[repr(transparent)]
1255 pub struct FloatNumber {
1256 pub(crate) syntax: SyntaxNode,
1258 unsafe impl TransparentNewType for FloatNumber {
1259 type Repr = rowan::SyntaxNode<RaTypes>;
1262 impl AstNode for FloatNumber {
1263 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1264 match syntax.kind() {
1265 FLOAT_NUMBER => Some(FloatNumber::from_repr(syntax.into_repr())),
1269 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1272 impl ToOwned for FloatNumber {
1273 type Owned = TreeArc<FloatNumber>;
1274 fn to_owned(&self) -> TreeArc<FloatNumber> { TreeArc::cast(self.syntax.to_owned()) }
1278 impl ast::AstToken for FloatNumber {}
1282 #[derive(Debug, PartialEq, Eq, Hash)]
1283 #[repr(transparent)]
1285 pub(crate) syntax: SyntaxNode,
1287 unsafe impl TransparentNewType for FnDef {
1288 type Repr = rowan::SyntaxNode<RaTypes>;
1291 impl AstNode for FnDef {
1292 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1293 match syntax.kind() {
1294 FN_DEF => Some(FnDef::from_repr(syntax.into_repr())),
1298 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1301 impl ToOwned for FnDef {
1302 type Owned = TreeArc<FnDef>;
1303 fn to_owned(&self) -> TreeArc<FnDef> { TreeArc::cast(self.syntax.to_owned()) }
1307 impl ast::VisibilityOwner for FnDef {}
1308 impl ast::NameOwner for FnDef {}
1309 impl ast::TypeParamsOwner for FnDef {}
1310 impl ast::AttrsOwner for FnDef {}
1311 impl ast::DocCommentsOwner for FnDef {}
1313 pub fn param_list(&self) -> Option<&ParamList> {
1314 super::child_opt(self)
1317 pub fn body(&self) -> Option<&Block> {
1318 super::child_opt(self)
1321 pub fn ret_type(&self) -> Option<&RetType> {
1322 super::child_opt(self)
1327 #[derive(Debug, PartialEq, Eq, Hash)]
1328 #[repr(transparent)]
1329 pub struct FnPointerType {
1330 pub(crate) syntax: SyntaxNode,
1332 unsafe impl TransparentNewType for FnPointerType {
1333 type Repr = rowan::SyntaxNode<RaTypes>;
1336 impl AstNode for FnPointerType {
1337 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1338 match syntax.kind() {
1339 FN_POINTER_TYPE => Some(FnPointerType::from_repr(syntax.into_repr())),
1343 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1346 impl ToOwned for FnPointerType {
1347 type Owned = TreeArc<FnPointerType>;
1348 fn to_owned(&self) -> TreeArc<FnPointerType> { TreeArc::cast(self.syntax.to_owned()) }
1352 impl FnPointerType {
1353 pub fn param_list(&self) -> Option<&ParamList> {
1354 super::child_opt(self)
1357 pub fn ret_type(&self) -> Option<&RetType> {
1358 super::child_opt(self)
1363 #[derive(Debug, PartialEq, Eq, Hash)]
1364 #[repr(transparent)]
1365 pub struct ForExpr {
1366 pub(crate) syntax: SyntaxNode,
1368 unsafe impl TransparentNewType for ForExpr {
1369 type Repr = rowan::SyntaxNode<RaTypes>;
1372 impl AstNode for ForExpr {
1373 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1374 match syntax.kind() {
1375 FOR_EXPR => Some(ForExpr::from_repr(syntax.into_repr())),
1379 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1382 impl ToOwned for ForExpr {
1383 type Owned = TreeArc<ForExpr>;
1384 fn to_owned(&self) -> TreeArc<ForExpr> { TreeArc::cast(self.syntax.to_owned()) }
1388 impl ast::LoopBodyOwner for ForExpr {}
1390 pub fn pat(&self) -> Option<&Pat> {
1391 super::child_opt(self)
1394 pub fn iterable(&self) -> Option<&Expr> {
1395 super::child_opt(self)
1400 #[derive(Debug, PartialEq, Eq, Hash)]
1401 #[repr(transparent)]
1402 pub struct ForType {
1403 pub(crate) syntax: SyntaxNode,
1405 unsafe impl TransparentNewType for ForType {
1406 type Repr = rowan::SyntaxNode<RaTypes>;
1409 impl AstNode for ForType {
1410 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1411 match syntax.kind() {
1412 FOR_TYPE => Some(ForType::from_repr(syntax.into_repr())),
1416 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1419 impl ToOwned for ForType {
1420 type Owned = TreeArc<ForType>;
1421 fn to_owned(&self) -> TreeArc<ForType> { TreeArc::cast(self.syntax.to_owned()) }
1426 pub fn type_ref(&self) -> Option<&TypeRef> {
1427 super::child_opt(self)
1432 #[derive(Debug, PartialEq, Eq, Hash)]
1433 #[repr(transparent)]
1435 pub(crate) syntax: SyntaxNode,
1437 unsafe impl TransparentNewType for IfExpr {
1438 type Repr = rowan::SyntaxNode<RaTypes>;
1441 impl AstNode for IfExpr {
1442 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1443 match syntax.kind() {
1444 IF_EXPR => Some(IfExpr::from_repr(syntax.into_repr())),
1448 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1451 impl ToOwned for IfExpr {
1452 type Owned = TreeArc<IfExpr>;
1453 fn to_owned(&self) -> TreeArc<IfExpr> { TreeArc::cast(self.syntax.to_owned()) }
1458 pub fn condition(&self) -> Option<&Condition> {
1459 super::child_opt(self)
1464 #[derive(Debug, PartialEq, Eq, Hash)]
1465 #[repr(transparent)]
1466 pub struct ImplBlock {
1467 pub(crate) syntax: SyntaxNode,
1469 unsafe impl TransparentNewType for ImplBlock {
1470 type Repr = rowan::SyntaxNode<RaTypes>;
1473 impl AstNode for ImplBlock {
1474 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1475 match syntax.kind() {
1476 IMPL_BLOCK => Some(ImplBlock::from_repr(syntax.into_repr())),
1480 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1483 impl ToOwned for ImplBlock {
1484 type Owned = TreeArc<ImplBlock>;
1485 fn to_owned(&self) -> TreeArc<ImplBlock> { TreeArc::cast(self.syntax.to_owned()) }
1489 impl ast::TypeParamsOwner for ImplBlock {}
1491 pub fn item_list(&self) -> Option<&ItemList> {
1492 super::child_opt(self)
1497 #[derive(Debug, PartialEq, Eq, Hash)]
1498 #[repr(transparent)]
1499 pub struct ImplItem {
1500 pub(crate) syntax: SyntaxNode,
1502 unsafe impl TransparentNewType for ImplItem {
1503 type Repr = rowan::SyntaxNode<RaTypes>;
1506 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1507 pub enum ImplItemKind<'a> {
1509 TypeAliasDef(&'a TypeAliasDef),
1510 ConstDef(&'a ConstDef),
1512 impl<'a> From<&'a FnDef> for &'a ImplItem {
1513 fn from(n: &'a FnDef) -> &'a ImplItem {
1514 ImplItem::cast(&n.syntax).unwrap()
1517 impl<'a> From<&'a TypeAliasDef> for &'a ImplItem {
1518 fn from(n: &'a TypeAliasDef) -> &'a ImplItem {
1519 ImplItem::cast(&n.syntax).unwrap()
1522 impl<'a> From<&'a ConstDef> for &'a ImplItem {
1523 fn from(n: &'a ConstDef) -> &'a ImplItem {
1524 ImplItem::cast(&n.syntax).unwrap()
1529 impl AstNode for ImplItem {
1530 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1531 match syntax.kind() {
1534 | CONST_DEF => Some(ImplItem::from_repr(syntax.into_repr())),
1538 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1541 impl ToOwned for ImplItem {
1542 type Owned = TreeArc<ImplItem>;
1543 fn to_owned(&self) -> TreeArc<ImplItem> { TreeArc::cast(self.syntax.to_owned()) }
1547 pub fn kind(&self) -> ImplItemKind {
1548 match self.syntax.kind() {
1549 FN_DEF => ImplItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
1550 TYPE_ALIAS_DEF => ImplItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
1551 CONST_DEF => ImplItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
1552 _ => unreachable!(),
1560 #[derive(Debug, PartialEq, Eq, Hash)]
1561 #[repr(transparent)]
1562 pub struct ImplTraitType {
1563 pub(crate) syntax: SyntaxNode,
1565 unsafe impl TransparentNewType for ImplTraitType {
1566 type Repr = rowan::SyntaxNode<RaTypes>;
1569 impl AstNode for ImplTraitType {
1570 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1571 match syntax.kind() {
1572 IMPL_TRAIT_TYPE => Some(ImplTraitType::from_repr(syntax.into_repr())),
1576 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1579 impl ToOwned for ImplTraitType {
1580 type Owned = TreeArc<ImplTraitType>;
1581 fn to_owned(&self) -> TreeArc<ImplTraitType> { TreeArc::cast(self.syntax.to_owned()) }
1585 impl ast::TypeBoundsOwner for ImplTraitType {}
1586 impl ImplTraitType {}
1589 #[derive(Debug, PartialEq, Eq, Hash)]
1590 #[repr(transparent)]
1591 pub struct IndexExpr {
1592 pub(crate) syntax: SyntaxNode,
1594 unsafe impl TransparentNewType for IndexExpr {
1595 type Repr = rowan::SyntaxNode<RaTypes>;
1598 impl AstNode for IndexExpr {
1599 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1600 match syntax.kind() {
1601 INDEX_EXPR => Some(IndexExpr::from_repr(syntax.into_repr())),
1605 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1608 impl ToOwned for IndexExpr {
1609 type Owned = TreeArc<IndexExpr>;
1610 fn to_owned(&self) -> TreeArc<IndexExpr> { TreeArc::cast(self.syntax.to_owned()) }
1617 #[derive(Debug, PartialEq, Eq, Hash)]
1618 #[repr(transparent)]
1619 pub struct IntNumber {
1620 pub(crate) syntax: SyntaxNode,
1622 unsafe impl TransparentNewType for IntNumber {
1623 type Repr = rowan::SyntaxNode<RaTypes>;
1626 impl AstNode for IntNumber {
1627 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1628 match syntax.kind() {
1629 INT_NUMBER => Some(IntNumber::from_repr(syntax.into_repr())),
1633 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1636 impl ToOwned for IntNumber {
1637 type Owned = TreeArc<IntNumber>;
1638 fn to_owned(&self) -> TreeArc<IntNumber> { TreeArc::cast(self.syntax.to_owned()) }
1642 impl ast::AstToken for IntNumber {}
1646 #[derive(Debug, PartialEq, Eq, Hash)]
1647 #[repr(transparent)]
1648 pub struct ItemList {
1649 pub(crate) syntax: SyntaxNode,
1651 unsafe impl TransparentNewType for ItemList {
1652 type Repr = rowan::SyntaxNode<RaTypes>;
1655 impl AstNode for ItemList {
1656 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1657 match syntax.kind() {
1658 ITEM_LIST => Some(ItemList::from_repr(syntax.into_repr())),
1662 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1665 impl ToOwned for ItemList {
1666 type Owned = TreeArc<ItemList>;
1667 fn to_owned(&self) -> TreeArc<ItemList> { TreeArc::cast(self.syntax.to_owned()) }
1671 impl ast::FnDefOwner for ItemList {}
1672 impl ast::ModuleItemOwner for ItemList {}
1674 pub fn impl_items(&self) -> impl Iterator<Item = &ImplItem> {
1675 super::children(self)
1680 #[derive(Debug, PartialEq, Eq, Hash)]
1681 #[repr(transparent)]
1683 pub(crate) syntax: SyntaxNode,
1685 unsafe impl TransparentNewType for Label {
1686 type Repr = rowan::SyntaxNode<RaTypes>;
1689 impl AstNode for Label {
1690 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1691 match syntax.kind() {
1692 LABEL => Some(Label::from_repr(syntax.into_repr())),
1696 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1699 impl ToOwned for Label {
1700 type Owned = TreeArc<Label>;
1701 fn to_owned(&self) -> TreeArc<Label> { TreeArc::cast(self.syntax.to_owned()) }
1708 #[derive(Debug, PartialEq, Eq, Hash)]
1709 #[repr(transparent)]
1710 pub struct LambdaExpr {
1711 pub(crate) syntax: SyntaxNode,
1713 unsafe impl TransparentNewType for LambdaExpr {
1714 type Repr = rowan::SyntaxNode<RaTypes>;
1717 impl AstNode for LambdaExpr {
1718 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1719 match syntax.kind() {
1720 LAMBDA_EXPR => Some(LambdaExpr::from_repr(syntax.into_repr())),
1724 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1727 impl ToOwned for LambdaExpr {
1728 type Owned = TreeArc<LambdaExpr>;
1729 fn to_owned(&self) -> TreeArc<LambdaExpr> { TreeArc::cast(self.syntax.to_owned()) }
1734 pub fn param_list(&self) -> Option<&ParamList> {
1735 super::child_opt(self)
1738 pub fn body(&self) -> Option<&Expr> {
1739 super::child_opt(self)
1744 #[derive(Debug, PartialEq, Eq, Hash)]
1745 #[repr(transparent)]
1746 pub struct LetStmt {
1747 pub(crate) syntax: SyntaxNode,
1749 unsafe impl TransparentNewType for LetStmt {
1750 type Repr = rowan::SyntaxNode<RaTypes>;
1753 impl AstNode for LetStmt {
1754 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1755 match syntax.kind() {
1756 LET_STMT => Some(LetStmt::from_repr(syntax.into_repr())),
1760 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1763 impl ToOwned for LetStmt {
1764 type Owned = TreeArc<LetStmt>;
1765 fn to_owned(&self) -> TreeArc<LetStmt> { TreeArc::cast(self.syntax.to_owned()) }
1769 impl ast::TypeAscriptionOwner for LetStmt {}
1771 pub fn pat(&self) -> Option<&Pat> {
1772 super::child_opt(self)
1775 pub fn initializer(&self) -> Option<&Expr> {
1776 super::child_opt(self)
1781 #[derive(Debug, PartialEq, Eq, Hash)]
1782 #[repr(transparent)]
1783 pub struct Lifetime {
1784 pub(crate) syntax: SyntaxNode,
1786 unsafe impl TransparentNewType for Lifetime {
1787 type Repr = rowan::SyntaxNode<RaTypes>;
1790 impl AstNode for Lifetime {
1791 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1792 match syntax.kind() {
1793 LIFETIME => Some(Lifetime::from_repr(syntax.into_repr())),
1797 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1800 impl ToOwned for Lifetime {
1801 type Owned = TreeArc<Lifetime>;
1802 fn to_owned(&self) -> TreeArc<Lifetime> { TreeArc::cast(self.syntax.to_owned()) }
1806 impl ast::AstToken for Lifetime {}
1810 #[derive(Debug, PartialEq, Eq, Hash)]
1811 #[repr(transparent)]
1812 pub struct LifetimeArg {
1813 pub(crate) syntax: SyntaxNode,
1815 unsafe impl TransparentNewType for LifetimeArg {
1816 type Repr = rowan::SyntaxNode<RaTypes>;
1819 impl AstNode for LifetimeArg {
1820 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1821 match syntax.kind() {
1822 LIFETIME_ARG => Some(LifetimeArg::from_repr(syntax.into_repr())),
1826 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1829 impl ToOwned for LifetimeArg {
1830 type Owned = TreeArc<LifetimeArg>;
1831 fn to_owned(&self) -> TreeArc<LifetimeArg> { TreeArc::cast(self.syntax.to_owned()) }
1836 pub fn lifetime(&self) -> Option<&Lifetime> {
1837 super::child_opt(self)
1842 #[derive(Debug, PartialEq, Eq, Hash)]
1843 #[repr(transparent)]
1844 pub struct LifetimeParam {
1845 pub(crate) syntax: SyntaxNode,
1847 unsafe impl TransparentNewType for LifetimeParam {
1848 type Repr = rowan::SyntaxNode<RaTypes>;
1851 impl AstNode for LifetimeParam {
1852 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1853 match syntax.kind() {
1854 LIFETIME_PARAM => Some(LifetimeParam::from_repr(syntax.into_repr())),
1858 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1861 impl ToOwned for LifetimeParam {
1862 type Owned = TreeArc<LifetimeParam>;
1863 fn to_owned(&self) -> TreeArc<LifetimeParam> { TreeArc::cast(self.syntax.to_owned()) }
1867 impl ast::AttrsOwner for LifetimeParam {}
1868 impl LifetimeParam {
1869 pub fn lifetime(&self) -> Option<&Lifetime> {
1870 super::child_opt(self)
1875 #[derive(Debug, PartialEq, Eq, Hash)]
1876 #[repr(transparent)]
1877 pub struct Literal {
1878 pub(crate) syntax: SyntaxNode,
1880 unsafe impl TransparentNewType for Literal {
1881 type Repr = rowan::SyntaxNode<RaTypes>;
1884 impl AstNode for Literal {
1885 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1886 match syntax.kind() {
1887 LITERAL => Some(Literal::from_repr(syntax.into_repr())),
1891 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1894 impl ToOwned for Literal {
1895 type Owned = TreeArc<Literal>;
1896 fn to_owned(&self) -> TreeArc<Literal> { TreeArc::cast(self.syntax.to_owned()) }
1901 pub fn literal_expr(&self) -> Option<&LiteralExpr> {
1902 super::child_opt(self)
1907 #[derive(Debug, PartialEq, Eq, Hash)]
1908 #[repr(transparent)]
1909 pub struct LiteralExpr {
1910 pub(crate) syntax: SyntaxNode,
1912 unsafe impl TransparentNewType for LiteralExpr {
1913 type Repr = rowan::SyntaxNode<RaTypes>;
1916 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1917 pub enum LiteralExprKind<'a> {
1919 ByteString(&'a ByteString),
1920 RawString(&'a RawString),
1921 RawByteString(&'a RawByteString),
1924 IntNumber(&'a IntNumber),
1925 FloatNumber(&'a FloatNumber),
1927 FalseKw(&'a FalseKw),
1929 impl<'a> From<&'a String> for &'a LiteralExpr {
1930 fn from(n: &'a String) -> &'a LiteralExpr {
1931 LiteralExpr::cast(&n.syntax).unwrap()
1934 impl<'a> From<&'a ByteString> for &'a LiteralExpr {
1935 fn from(n: &'a ByteString) -> &'a LiteralExpr {
1936 LiteralExpr::cast(&n.syntax).unwrap()
1939 impl<'a> From<&'a RawString> for &'a LiteralExpr {
1940 fn from(n: &'a RawString) -> &'a LiteralExpr {
1941 LiteralExpr::cast(&n.syntax).unwrap()
1944 impl<'a> From<&'a RawByteString> for &'a LiteralExpr {
1945 fn from(n: &'a RawByteString) -> &'a LiteralExpr {
1946 LiteralExpr::cast(&n.syntax).unwrap()
1949 impl<'a> From<&'a Char> for &'a LiteralExpr {
1950 fn from(n: &'a Char) -> &'a LiteralExpr {
1951 LiteralExpr::cast(&n.syntax).unwrap()
1954 impl<'a> From<&'a Byte> for &'a LiteralExpr {
1955 fn from(n: &'a Byte) -> &'a LiteralExpr {
1956 LiteralExpr::cast(&n.syntax).unwrap()
1959 impl<'a> From<&'a IntNumber> for &'a LiteralExpr {
1960 fn from(n: &'a IntNumber) -> &'a LiteralExpr {
1961 LiteralExpr::cast(&n.syntax).unwrap()
1964 impl<'a> From<&'a FloatNumber> for &'a LiteralExpr {
1965 fn from(n: &'a FloatNumber) -> &'a LiteralExpr {
1966 LiteralExpr::cast(&n.syntax).unwrap()
1969 impl<'a> From<&'a TrueKw> for &'a LiteralExpr {
1970 fn from(n: &'a TrueKw) -> &'a LiteralExpr {
1971 LiteralExpr::cast(&n.syntax).unwrap()
1974 impl<'a> From<&'a FalseKw> for &'a LiteralExpr {
1975 fn from(n: &'a FalseKw) -> &'a LiteralExpr {
1976 LiteralExpr::cast(&n.syntax).unwrap()
1981 impl AstNode for LiteralExpr {
1982 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1983 match syntax.kind() {
1993 | FALSE_KW => Some(LiteralExpr::from_repr(syntax.into_repr())),
1997 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2000 impl ToOwned for LiteralExpr {
2001 type Owned = TreeArc<LiteralExpr>;
2002 fn to_owned(&self) -> TreeArc<LiteralExpr> { TreeArc::cast(self.syntax.to_owned()) }
2006 pub fn kind(&self) -> LiteralExprKind {
2007 match self.syntax.kind() {
2008 STRING => LiteralExprKind::String(String::cast(&self.syntax).unwrap()),
2009 BYTE_STRING => LiteralExprKind::ByteString(ByteString::cast(&self.syntax).unwrap()),
2010 RAW_STRING => LiteralExprKind::RawString(RawString::cast(&self.syntax).unwrap()),
2011 RAW_BYTE_STRING => LiteralExprKind::RawByteString(RawByteString::cast(&self.syntax).unwrap()),
2012 CHAR => LiteralExprKind::Char(Char::cast(&self.syntax).unwrap()),
2013 BYTE => LiteralExprKind::Byte(Byte::cast(&self.syntax).unwrap()),
2014 INT_NUMBER => LiteralExprKind::IntNumber(IntNumber::cast(&self.syntax).unwrap()),
2015 FLOAT_NUMBER => LiteralExprKind::FloatNumber(FloatNumber::cast(&self.syntax).unwrap()),
2016 TRUE_KW => LiteralExprKind::TrueKw(TrueKw::cast(&self.syntax).unwrap()),
2017 FALSE_KW => LiteralExprKind::FalseKw(FalseKw::cast(&self.syntax).unwrap()),
2018 _ => unreachable!(),
2026 #[derive(Debug, PartialEq, Eq, Hash)]
2027 #[repr(transparent)]
2028 pub struct LiteralPat {
2029 pub(crate) syntax: SyntaxNode,
2031 unsafe impl TransparentNewType for LiteralPat {
2032 type Repr = rowan::SyntaxNode<RaTypes>;
2035 impl AstNode for LiteralPat {
2036 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2037 match syntax.kind() {
2038 LITERAL_PAT => Some(LiteralPat::from_repr(syntax.into_repr())),
2042 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2045 impl ToOwned for LiteralPat {
2046 type Owned = TreeArc<LiteralPat>;
2047 fn to_owned(&self) -> TreeArc<LiteralPat> { TreeArc::cast(self.syntax.to_owned()) }
2052 pub fn literal(&self) -> Option<&Literal> {
2053 super::child_opt(self)
2058 #[derive(Debug, PartialEq, Eq, Hash)]
2059 #[repr(transparent)]
2060 pub struct LoopExpr {
2061 pub(crate) syntax: SyntaxNode,
2063 unsafe impl TransparentNewType for LoopExpr {
2064 type Repr = rowan::SyntaxNode<RaTypes>;
2067 impl AstNode for LoopExpr {
2068 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2069 match syntax.kind() {
2070 LOOP_EXPR => Some(LoopExpr::from_repr(syntax.into_repr())),
2074 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2077 impl ToOwned for LoopExpr {
2078 type Owned = TreeArc<LoopExpr>;
2079 fn to_owned(&self) -> TreeArc<LoopExpr> { TreeArc::cast(self.syntax.to_owned()) }
2083 impl ast::LoopBodyOwner for LoopExpr {}
2087 #[derive(Debug, PartialEq, Eq, Hash)]
2088 #[repr(transparent)]
2089 pub struct MacroCall {
2090 pub(crate) syntax: SyntaxNode,
2092 unsafe impl TransparentNewType for MacroCall {
2093 type Repr = rowan::SyntaxNode<RaTypes>;
2096 impl AstNode for MacroCall {
2097 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2098 match syntax.kind() {
2099 MACRO_CALL => Some(MacroCall::from_repr(syntax.into_repr())),
2103 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2106 impl ToOwned for MacroCall {
2107 type Owned = TreeArc<MacroCall>;
2108 fn to_owned(&self) -> TreeArc<MacroCall> { TreeArc::cast(self.syntax.to_owned()) }
2112 impl ast::NameOwner for MacroCall {}
2113 impl ast::AttrsOwner for MacroCall {}
2115 pub fn token_tree(&self) -> Option<&TokenTree> {
2116 super::child_opt(self)
2119 pub fn path(&self) -> Option<&Path> {
2120 super::child_opt(self)
2125 #[derive(Debug, PartialEq, Eq, Hash)]
2126 #[repr(transparent)]
2127 pub struct MatchArm {
2128 pub(crate) syntax: SyntaxNode,
2130 unsafe impl TransparentNewType for MatchArm {
2131 type Repr = rowan::SyntaxNode<RaTypes>;
2134 impl AstNode for MatchArm {
2135 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2136 match syntax.kind() {
2137 MATCH_ARM => Some(MatchArm::from_repr(syntax.into_repr())),
2141 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2144 impl ToOwned for MatchArm {
2145 type Owned = TreeArc<MatchArm>;
2146 fn to_owned(&self) -> TreeArc<MatchArm> { TreeArc::cast(self.syntax.to_owned()) }
2150 impl ast::AttrsOwner for MatchArm {}
2152 pub fn pats(&self) -> impl Iterator<Item = &Pat> {
2153 super::children(self)
2156 pub fn guard(&self) -> Option<&MatchGuard> {
2157 super::child_opt(self)
2160 pub fn expr(&self) -> Option<&Expr> {
2161 super::child_opt(self)
2166 #[derive(Debug, PartialEq, Eq, Hash)]
2167 #[repr(transparent)]
2168 pub struct MatchArmList {
2169 pub(crate) syntax: SyntaxNode,
2171 unsafe impl TransparentNewType for MatchArmList {
2172 type Repr = rowan::SyntaxNode<RaTypes>;
2175 impl AstNode for MatchArmList {
2176 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2177 match syntax.kind() {
2178 MATCH_ARM_LIST => Some(MatchArmList::from_repr(syntax.into_repr())),
2182 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2185 impl ToOwned for MatchArmList {
2186 type Owned = TreeArc<MatchArmList>;
2187 fn to_owned(&self) -> TreeArc<MatchArmList> { TreeArc::cast(self.syntax.to_owned()) }
2191 impl ast::AttrsOwner for MatchArmList {}
2193 pub fn arms(&self) -> impl Iterator<Item = &MatchArm> {
2194 super::children(self)
2199 #[derive(Debug, PartialEq, Eq, Hash)]
2200 #[repr(transparent)]
2201 pub struct MatchExpr {
2202 pub(crate) syntax: SyntaxNode,
2204 unsafe impl TransparentNewType for MatchExpr {
2205 type Repr = rowan::SyntaxNode<RaTypes>;
2208 impl AstNode for MatchExpr {
2209 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2210 match syntax.kind() {
2211 MATCH_EXPR => Some(MatchExpr::from_repr(syntax.into_repr())),
2215 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2218 impl ToOwned for MatchExpr {
2219 type Owned = TreeArc<MatchExpr>;
2220 fn to_owned(&self) -> TreeArc<MatchExpr> { TreeArc::cast(self.syntax.to_owned()) }
2225 pub fn expr(&self) -> Option<&Expr> {
2226 super::child_opt(self)
2229 pub fn match_arm_list(&self) -> Option<&MatchArmList> {
2230 super::child_opt(self)
2235 #[derive(Debug, PartialEq, Eq, Hash)]
2236 #[repr(transparent)]
2237 pub struct MatchGuard {
2238 pub(crate) syntax: SyntaxNode,
2240 unsafe impl TransparentNewType for MatchGuard {
2241 type Repr = rowan::SyntaxNode<RaTypes>;
2244 impl AstNode for MatchGuard {
2245 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2246 match syntax.kind() {
2247 MATCH_GUARD => Some(MatchGuard::from_repr(syntax.into_repr())),
2251 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2254 impl ToOwned for MatchGuard {
2255 type Owned = TreeArc<MatchGuard>;
2256 fn to_owned(&self) -> TreeArc<MatchGuard> { TreeArc::cast(self.syntax.to_owned()) }
2261 pub fn expr(&self) -> Option<&Expr> {
2262 super::child_opt(self)
2267 #[derive(Debug, PartialEq, Eq, Hash)]
2268 #[repr(transparent)]
2269 pub struct MethodCallExpr {
2270 pub(crate) syntax: SyntaxNode,
2272 unsafe impl TransparentNewType for MethodCallExpr {
2273 type Repr = rowan::SyntaxNode<RaTypes>;
2276 impl AstNode for MethodCallExpr {
2277 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2278 match syntax.kind() {
2279 METHOD_CALL_EXPR => Some(MethodCallExpr::from_repr(syntax.into_repr())),
2283 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2286 impl ToOwned for MethodCallExpr {
2287 type Owned = TreeArc<MethodCallExpr>;
2288 fn to_owned(&self) -> TreeArc<MethodCallExpr> { TreeArc::cast(self.syntax.to_owned()) }
2292 impl ast::ArgListOwner for MethodCallExpr {}
2293 impl MethodCallExpr {
2294 pub fn expr(&self) -> Option<&Expr> {
2295 super::child_opt(self)
2298 pub fn name_ref(&self) -> Option<&NameRef> {
2299 super::child_opt(self)
2302 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
2303 super::child_opt(self)
2308 #[derive(Debug, PartialEq, Eq, Hash)]
2309 #[repr(transparent)]
2311 pub(crate) syntax: SyntaxNode,
2313 unsafe impl TransparentNewType for Module {
2314 type Repr = rowan::SyntaxNode<RaTypes>;
2317 impl AstNode for Module {
2318 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2319 match syntax.kind() {
2320 MODULE => Some(Module::from_repr(syntax.into_repr())),
2324 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2327 impl ToOwned for Module {
2328 type Owned = TreeArc<Module>;
2329 fn to_owned(&self) -> TreeArc<Module> { TreeArc::cast(self.syntax.to_owned()) }
2333 impl ast::VisibilityOwner for Module {}
2334 impl ast::NameOwner for Module {}
2335 impl ast::AttrsOwner for Module {}
2336 impl ast::DocCommentsOwner for Module {}
2338 pub fn item_list(&self) -> Option<&ItemList> {
2339 super::child_opt(self)
2344 #[derive(Debug, PartialEq, Eq, Hash)]
2345 #[repr(transparent)]
2346 pub struct ModuleItem {
2347 pub(crate) syntax: SyntaxNode,
2349 unsafe impl TransparentNewType for ModuleItem {
2350 type Repr = rowan::SyntaxNode<RaTypes>;
2353 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2354 pub enum ModuleItemKind<'a> {
2355 StructDef(&'a StructDef),
2356 EnumDef(&'a EnumDef),
2358 TraitDef(&'a TraitDef),
2359 TypeAliasDef(&'a TypeAliasDef),
2360 ImplBlock(&'a ImplBlock),
2361 UseItem(&'a UseItem),
2362 ExternCrateItem(&'a ExternCrateItem),
2363 ConstDef(&'a ConstDef),
2364 StaticDef(&'a StaticDef),
2367 impl<'a> From<&'a StructDef> for &'a ModuleItem {
2368 fn from(n: &'a StructDef) -> &'a ModuleItem {
2369 ModuleItem::cast(&n.syntax).unwrap()
2372 impl<'a> From<&'a EnumDef> for &'a ModuleItem {
2373 fn from(n: &'a EnumDef) -> &'a ModuleItem {
2374 ModuleItem::cast(&n.syntax).unwrap()
2377 impl<'a> From<&'a FnDef> for &'a ModuleItem {
2378 fn from(n: &'a FnDef) -> &'a ModuleItem {
2379 ModuleItem::cast(&n.syntax).unwrap()
2382 impl<'a> From<&'a TraitDef> for &'a ModuleItem {
2383 fn from(n: &'a TraitDef) -> &'a ModuleItem {
2384 ModuleItem::cast(&n.syntax).unwrap()
2387 impl<'a> From<&'a TypeAliasDef> for &'a ModuleItem {
2388 fn from(n: &'a TypeAliasDef) -> &'a ModuleItem {
2389 ModuleItem::cast(&n.syntax).unwrap()
2392 impl<'a> From<&'a ImplBlock> for &'a ModuleItem {
2393 fn from(n: &'a ImplBlock) -> &'a ModuleItem {
2394 ModuleItem::cast(&n.syntax).unwrap()
2397 impl<'a> From<&'a UseItem> for &'a ModuleItem {
2398 fn from(n: &'a UseItem) -> &'a ModuleItem {
2399 ModuleItem::cast(&n.syntax).unwrap()
2402 impl<'a> From<&'a ExternCrateItem> for &'a ModuleItem {
2403 fn from(n: &'a ExternCrateItem) -> &'a ModuleItem {
2404 ModuleItem::cast(&n.syntax).unwrap()
2407 impl<'a> From<&'a ConstDef> for &'a ModuleItem {
2408 fn from(n: &'a ConstDef) -> &'a ModuleItem {
2409 ModuleItem::cast(&n.syntax).unwrap()
2412 impl<'a> From<&'a StaticDef> for &'a ModuleItem {
2413 fn from(n: &'a StaticDef) -> &'a ModuleItem {
2414 ModuleItem::cast(&n.syntax).unwrap()
2417 impl<'a> From<&'a Module> for &'a ModuleItem {
2418 fn from(n: &'a Module) -> &'a ModuleItem {
2419 ModuleItem::cast(&n.syntax).unwrap()
2424 impl AstNode for ModuleItem {
2425 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2426 match syntax.kind() {
2437 | MODULE => Some(ModuleItem::from_repr(syntax.into_repr())),
2441 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2444 impl ToOwned for ModuleItem {
2445 type Owned = TreeArc<ModuleItem>;
2446 fn to_owned(&self) -> TreeArc<ModuleItem> { TreeArc::cast(self.syntax.to_owned()) }
2450 pub fn kind(&self) -> ModuleItemKind {
2451 match self.syntax.kind() {
2452 STRUCT_DEF => ModuleItemKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2453 ENUM_DEF => ModuleItemKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2454 FN_DEF => ModuleItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
2455 TRAIT_DEF => ModuleItemKind::TraitDef(TraitDef::cast(&self.syntax).unwrap()),
2456 TYPE_ALIAS_DEF => ModuleItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
2457 IMPL_BLOCK => ModuleItemKind::ImplBlock(ImplBlock::cast(&self.syntax).unwrap()),
2458 USE_ITEM => ModuleItemKind::UseItem(UseItem::cast(&self.syntax).unwrap()),
2459 EXTERN_CRATE_ITEM => ModuleItemKind::ExternCrateItem(ExternCrateItem::cast(&self.syntax).unwrap()),
2460 CONST_DEF => ModuleItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
2461 STATIC_DEF => ModuleItemKind::StaticDef(StaticDef::cast(&self.syntax).unwrap()),
2462 MODULE => ModuleItemKind::Module(Module::cast(&self.syntax).unwrap()),
2463 _ => unreachable!(),
2471 #[derive(Debug, PartialEq, Eq, Hash)]
2472 #[repr(transparent)]
2474 pub(crate) syntax: SyntaxNode,
2476 unsafe impl TransparentNewType for Name {
2477 type Repr = rowan::SyntaxNode<RaTypes>;
2480 impl AstNode for Name {
2481 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2482 match syntax.kind() {
2483 NAME => Some(Name::from_repr(syntax.into_repr())),
2487 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2490 impl ToOwned for Name {
2491 type Owned = TreeArc<Name>;
2492 fn to_owned(&self) -> TreeArc<Name> { TreeArc::cast(self.syntax.to_owned()) }
2499 #[derive(Debug, PartialEq, Eq, Hash)]
2500 #[repr(transparent)]
2501 pub struct NameRef {
2502 pub(crate) syntax: SyntaxNode,
2504 unsafe impl TransparentNewType for NameRef {
2505 type Repr = rowan::SyntaxNode<RaTypes>;
2508 impl AstNode for NameRef {
2509 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2510 match syntax.kind() {
2511 NAME_REF => Some(NameRef::from_repr(syntax.into_repr())),
2515 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2518 impl ToOwned for NameRef {
2519 type Owned = TreeArc<NameRef>;
2520 fn to_owned(&self) -> TreeArc<NameRef> { TreeArc::cast(self.syntax.to_owned()) }
2527 #[derive(Debug, PartialEq, Eq, Hash)]
2528 #[repr(transparent)]
2529 pub struct NamedField {
2530 pub(crate) syntax: SyntaxNode,
2532 unsafe impl TransparentNewType for NamedField {
2533 type Repr = rowan::SyntaxNode<RaTypes>;
2536 impl AstNode for NamedField {
2537 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2538 match syntax.kind() {
2539 NAMED_FIELD => Some(NamedField::from_repr(syntax.into_repr())),
2543 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2546 impl ToOwned for NamedField {
2547 type Owned = TreeArc<NamedField>;
2548 fn to_owned(&self) -> TreeArc<NamedField> { TreeArc::cast(self.syntax.to_owned()) }
2553 pub fn name_ref(&self) -> Option<&NameRef> {
2554 super::child_opt(self)
2557 pub fn expr(&self) -> Option<&Expr> {
2558 super::child_opt(self)
2563 #[derive(Debug, PartialEq, Eq, Hash)]
2564 #[repr(transparent)]
2565 pub struct NamedFieldDef {
2566 pub(crate) syntax: SyntaxNode,
2568 unsafe impl TransparentNewType for NamedFieldDef {
2569 type Repr = rowan::SyntaxNode<RaTypes>;
2572 impl AstNode for NamedFieldDef {
2573 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2574 match syntax.kind() {
2575 NAMED_FIELD_DEF => Some(NamedFieldDef::from_repr(syntax.into_repr())),
2579 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2582 impl ToOwned for NamedFieldDef {
2583 type Owned = TreeArc<NamedFieldDef>;
2584 fn to_owned(&self) -> TreeArc<NamedFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2588 impl ast::VisibilityOwner for NamedFieldDef {}
2589 impl ast::NameOwner for NamedFieldDef {}
2590 impl ast::AttrsOwner for NamedFieldDef {}
2591 impl ast::DocCommentsOwner for NamedFieldDef {}
2592 impl ast::TypeAscriptionOwner for NamedFieldDef {}
2593 impl NamedFieldDef {}
2595 // NamedFieldDefList
2596 #[derive(Debug, PartialEq, Eq, Hash)]
2597 #[repr(transparent)]
2598 pub struct NamedFieldDefList {
2599 pub(crate) syntax: SyntaxNode,
2601 unsafe impl TransparentNewType for NamedFieldDefList {
2602 type Repr = rowan::SyntaxNode<RaTypes>;
2605 impl AstNode for NamedFieldDefList {
2606 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2607 match syntax.kind() {
2608 NAMED_FIELD_DEF_LIST => Some(NamedFieldDefList::from_repr(syntax.into_repr())),
2612 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2615 impl ToOwned for NamedFieldDefList {
2616 type Owned = TreeArc<NamedFieldDefList>;
2617 fn to_owned(&self) -> TreeArc<NamedFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
2621 impl NamedFieldDefList {
2622 pub fn fields(&self) -> impl Iterator<Item = &NamedFieldDef> {
2623 super::children(self)
2628 #[derive(Debug, PartialEq, Eq, Hash)]
2629 #[repr(transparent)]
2630 pub struct NamedFieldList {
2631 pub(crate) syntax: SyntaxNode,
2633 unsafe impl TransparentNewType for NamedFieldList {
2634 type Repr = rowan::SyntaxNode<RaTypes>;
2637 impl AstNode for NamedFieldList {
2638 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2639 match syntax.kind() {
2640 NAMED_FIELD_LIST => Some(NamedFieldList::from_repr(syntax.into_repr())),
2644 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2647 impl ToOwned for NamedFieldList {
2648 type Owned = TreeArc<NamedFieldList>;
2649 fn to_owned(&self) -> TreeArc<NamedFieldList> { TreeArc::cast(self.syntax.to_owned()) }
2653 impl NamedFieldList {
2654 pub fn fields(&self) -> impl Iterator<Item = &NamedField> {
2655 super::children(self)
2660 #[derive(Debug, PartialEq, Eq, Hash)]
2661 #[repr(transparent)]
2662 pub struct NeverType {
2663 pub(crate) syntax: SyntaxNode,
2665 unsafe impl TransparentNewType for NeverType {
2666 type Repr = rowan::SyntaxNode<RaTypes>;
2669 impl AstNode for NeverType {
2670 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2671 match syntax.kind() {
2672 NEVER_TYPE => Some(NeverType::from_repr(syntax.into_repr())),
2676 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2679 impl ToOwned for NeverType {
2680 type Owned = TreeArc<NeverType>;
2681 fn to_owned(&self) -> TreeArc<NeverType> { TreeArc::cast(self.syntax.to_owned()) }
2688 #[derive(Debug, PartialEq, Eq, Hash)]
2689 #[repr(transparent)]
2690 pub struct NominalDef {
2691 pub(crate) syntax: SyntaxNode,
2693 unsafe impl TransparentNewType for NominalDef {
2694 type Repr = rowan::SyntaxNode<RaTypes>;
2697 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2698 pub enum NominalDefKind<'a> {
2699 StructDef(&'a StructDef),
2700 EnumDef(&'a EnumDef),
2702 impl<'a> From<&'a StructDef> for &'a NominalDef {
2703 fn from(n: &'a StructDef) -> &'a NominalDef {
2704 NominalDef::cast(&n.syntax).unwrap()
2707 impl<'a> From<&'a EnumDef> for &'a NominalDef {
2708 fn from(n: &'a EnumDef) -> &'a NominalDef {
2709 NominalDef::cast(&n.syntax).unwrap()
2714 impl AstNode for NominalDef {
2715 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2716 match syntax.kind() {
2718 | ENUM_DEF => Some(NominalDef::from_repr(syntax.into_repr())),
2722 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2725 impl ToOwned for NominalDef {
2726 type Owned = TreeArc<NominalDef>;
2727 fn to_owned(&self) -> TreeArc<NominalDef> { TreeArc::cast(self.syntax.to_owned()) }
2731 pub fn kind(&self) -> NominalDefKind {
2732 match self.syntax.kind() {
2733 STRUCT_DEF => NominalDefKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2734 ENUM_DEF => NominalDefKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2735 _ => unreachable!(),
2740 impl ast::NameOwner for NominalDef {}
2741 impl ast::TypeParamsOwner for NominalDef {}
2742 impl ast::AttrsOwner for NominalDef {}
2746 #[derive(Debug, PartialEq, Eq, Hash)]
2747 #[repr(transparent)]
2749 pub(crate) syntax: SyntaxNode,
2751 unsafe impl TransparentNewType for Param {
2752 type Repr = rowan::SyntaxNode<RaTypes>;
2755 impl AstNode for Param {
2756 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2757 match syntax.kind() {
2758 PARAM => Some(Param::from_repr(syntax.into_repr())),
2762 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2765 impl ToOwned for Param {
2766 type Owned = TreeArc<Param>;
2767 fn to_owned(&self) -> TreeArc<Param> { TreeArc::cast(self.syntax.to_owned()) }
2771 impl ast::TypeAscriptionOwner for Param {}
2773 pub fn pat(&self) -> Option<&Pat> {
2774 super::child_opt(self)
2779 #[derive(Debug, PartialEq, Eq, Hash)]
2780 #[repr(transparent)]
2781 pub struct ParamList {
2782 pub(crate) syntax: SyntaxNode,
2784 unsafe impl TransparentNewType for ParamList {
2785 type Repr = rowan::SyntaxNode<RaTypes>;
2788 impl AstNode for ParamList {
2789 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2790 match syntax.kind() {
2791 PARAM_LIST => Some(ParamList::from_repr(syntax.into_repr())),
2795 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2798 impl ToOwned for ParamList {
2799 type Owned = TreeArc<ParamList>;
2800 fn to_owned(&self) -> TreeArc<ParamList> { TreeArc::cast(self.syntax.to_owned()) }
2805 pub fn params(&self) -> impl Iterator<Item = &Param> {
2806 super::children(self)
2809 pub fn self_param(&self) -> Option<&SelfParam> {
2810 super::child_opt(self)
2815 #[derive(Debug, PartialEq, Eq, Hash)]
2816 #[repr(transparent)]
2817 pub struct ParenExpr {
2818 pub(crate) syntax: SyntaxNode,
2820 unsafe impl TransparentNewType for ParenExpr {
2821 type Repr = rowan::SyntaxNode<RaTypes>;
2824 impl AstNode for ParenExpr {
2825 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2826 match syntax.kind() {
2827 PAREN_EXPR => Some(ParenExpr::from_repr(syntax.into_repr())),
2831 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2834 impl ToOwned for ParenExpr {
2835 type Owned = TreeArc<ParenExpr>;
2836 fn to_owned(&self) -> TreeArc<ParenExpr> { TreeArc::cast(self.syntax.to_owned()) }
2841 pub fn expr(&self) -> Option<&Expr> {
2842 super::child_opt(self)
2847 #[derive(Debug, PartialEq, Eq, Hash)]
2848 #[repr(transparent)]
2849 pub struct ParenType {
2850 pub(crate) syntax: SyntaxNode,
2852 unsafe impl TransparentNewType for ParenType {
2853 type Repr = rowan::SyntaxNode<RaTypes>;
2856 impl AstNode for ParenType {
2857 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2858 match syntax.kind() {
2859 PAREN_TYPE => Some(ParenType::from_repr(syntax.into_repr())),
2863 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2866 impl ToOwned for ParenType {
2867 type Owned = TreeArc<ParenType>;
2868 fn to_owned(&self) -> TreeArc<ParenType> { TreeArc::cast(self.syntax.to_owned()) }
2873 pub fn type_ref(&self) -> Option<&TypeRef> {
2874 super::child_opt(self)
2879 #[derive(Debug, PartialEq, Eq, Hash)]
2880 #[repr(transparent)]
2882 pub(crate) syntax: SyntaxNode,
2884 unsafe impl TransparentNewType for Pat {
2885 type Repr = rowan::SyntaxNode<RaTypes>;
2888 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2889 pub enum PatKind<'a> {
2891 BindPat(&'a BindPat),
2892 PlaceholderPat(&'a PlaceholderPat),
2893 PathPat(&'a PathPat),
2894 StructPat(&'a StructPat),
2895 TupleStructPat(&'a TupleStructPat),
2896 TuplePat(&'a TuplePat),
2897 SlicePat(&'a SlicePat),
2898 RangePat(&'a RangePat),
2899 LiteralPat(&'a LiteralPat),
2901 impl<'a> From<&'a RefPat> for &'a Pat {
2902 fn from(n: &'a RefPat) -> &'a Pat {
2903 Pat::cast(&n.syntax).unwrap()
2906 impl<'a> From<&'a BindPat> for &'a Pat {
2907 fn from(n: &'a BindPat) -> &'a Pat {
2908 Pat::cast(&n.syntax).unwrap()
2911 impl<'a> From<&'a PlaceholderPat> for &'a Pat {
2912 fn from(n: &'a PlaceholderPat) -> &'a Pat {
2913 Pat::cast(&n.syntax).unwrap()
2916 impl<'a> From<&'a PathPat> for &'a Pat {
2917 fn from(n: &'a PathPat) -> &'a Pat {
2918 Pat::cast(&n.syntax).unwrap()
2921 impl<'a> From<&'a StructPat> for &'a Pat {
2922 fn from(n: &'a StructPat) -> &'a Pat {
2923 Pat::cast(&n.syntax).unwrap()
2926 impl<'a> From<&'a TupleStructPat> for &'a Pat {
2927 fn from(n: &'a TupleStructPat) -> &'a Pat {
2928 Pat::cast(&n.syntax).unwrap()
2931 impl<'a> From<&'a TuplePat> for &'a Pat {
2932 fn from(n: &'a TuplePat) -> &'a Pat {
2933 Pat::cast(&n.syntax).unwrap()
2936 impl<'a> From<&'a SlicePat> for &'a Pat {
2937 fn from(n: &'a SlicePat) -> &'a Pat {
2938 Pat::cast(&n.syntax).unwrap()
2941 impl<'a> From<&'a RangePat> for &'a Pat {
2942 fn from(n: &'a RangePat) -> &'a Pat {
2943 Pat::cast(&n.syntax).unwrap()
2946 impl<'a> From<&'a LiteralPat> for &'a Pat {
2947 fn from(n: &'a LiteralPat) -> &'a Pat {
2948 Pat::cast(&n.syntax).unwrap()
2953 impl AstNode for Pat {
2954 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2955 match syntax.kind() {
2965 | LITERAL_PAT => Some(Pat::from_repr(syntax.into_repr())),
2969 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2972 impl ToOwned for Pat {
2973 type Owned = TreeArc<Pat>;
2974 fn to_owned(&self) -> TreeArc<Pat> { TreeArc::cast(self.syntax.to_owned()) }
2978 pub fn kind(&self) -> PatKind {
2979 match self.syntax.kind() {
2980 REF_PAT => PatKind::RefPat(RefPat::cast(&self.syntax).unwrap()),
2981 BIND_PAT => PatKind::BindPat(BindPat::cast(&self.syntax).unwrap()),
2982 PLACEHOLDER_PAT => PatKind::PlaceholderPat(PlaceholderPat::cast(&self.syntax).unwrap()),
2983 PATH_PAT => PatKind::PathPat(PathPat::cast(&self.syntax).unwrap()),
2984 STRUCT_PAT => PatKind::StructPat(StructPat::cast(&self.syntax).unwrap()),
2985 TUPLE_STRUCT_PAT => PatKind::TupleStructPat(TupleStructPat::cast(&self.syntax).unwrap()),
2986 TUPLE_PAT => PatKind::TuplePat(TuplePat::cast(&self.syntax).unwrap()),
2987 SLICE_PAT => PatKind::SlicePat(SlicePat::cast(&self.syntax).unwrap()),
2988 RANGE_PAT => PatKind::RangePat(RangePat::cast(&self.syntax).unwrap()),
2989 LITERAL_PAT => PatKind::LiteralPat(LiteralPat::cast(&self.syntax).unwrap()),
2990 _ => unreachable!(),
2998 #[derive(Debug, PartialEq, Eq, Hash)]
2999 #[repr(transparent)]
3001 pub(crate) syntax: SyntaxNode,
3003 unsafe impl TransparentNewType for Path {
3004 type Repr = rowan::SyntaxNode<RaTypes>;
3007 impl AstNode for Path {
3008 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3009 match syntax.kind() {
3010 PATH => Some(Path::from_repr(syntax.into_repr())),
3014 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3017 impl ToOwned for Path {
3018 type Owned = TreeArc<Path>;
3019 fn to_owned(&self) -> TreeArc<Path> { TreeArc::cast(self.syntax.to_owned()) }
3024 pub fn segment(&self) -> Option<&PathSegment> {
3025 super::child_opt(self)
3028 pub fn qualifier(&self) -> Option<&Path> {
3029 super::child_opt(self)
3034 #[derive(Debug, PartialEq, Eq, Hash)]
3035 #[repr(transparent)]
3036 pub struct PathExpr {
3037 pub(crate) syntax: SyntaxNode,
3039 unsafe impl TransparentNewType for PathExpr {
3040 type Repr = rowan::SyntaxNode<RaTypes>;
3043 impl AstNode for PathExpr {
3044 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3045 match syntax.kind() {
3046 PATH_EXPR => Some(PathExpr::from_repr(syntax.into_repr())),
3050 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3053 impl ToOwned for PathExpr {
3054 type Owned = TreeArc<PathExpr>;
3055 fn to_owned(&self) -> TreeArc<PathExpr> { TreeArc::cast(self.syntax.to_owned()) }
3060 pub fn path(&self) -> Option<&Path> {
3061 super::child_opt(self)
3066 #[derive(Debug, PartialEq, Eq, Hash)]
3067 #[repr(transparent)]
3068 pub struct PathPat {
3069 pub(crate) syntax: SyntaxNode,
3071 unsafe impl TransparentNewType for PathPat {
3072 type Repr = rowan::SyntaxNode<RaTypes>;
3075 impl AstNode for PathPat {
3076 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3077 match syntax.kind() {
3078 PATH_PAT => Some(PathPat::from_repr(syntax.into_repr())),
3082 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3085 impl ToOwned for PathPat {
3086 type Owned = TreeArc<PathPat>;
3087 fn to_owned(&self) -> TreeArc<PathPat> { TreeArc::cast(self.syntax.to_owned()) }
3092 pub fn path(&self) -> Option<&Path> {
3093 super::child_opt(self)
3098 #[derive(Debug, PartialEq, Eq, Hash)]
3099 #[repr(transparent)]
3100 pub struct PathSegment {
3101 pub(crate) syntax: SyntaxNode,
3103 unsafe impl TransparentNewType for PathSegment {
3104 type Repr = rowan::SyntaxNode<RaTypes>;
3107 impl AstNode for PathSegment {
3108 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3109 match syntax.kind() {
3110 PATH_SEGMENT => Some(PathSegment::from_repr(syntax.into_repr())),
3114 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3117 impl ToOwned for PathSegment {
3118 type Owned = TreeArc<PathSegment>;
3119 fn to_owned(&self) -> TreeArc<PathSegment> { TreeArc::cast(self.syntax.to_owned()) }
3124 pub fn name_ref(&self) -> Option<&NameRef> {
3125 super::child_opt(self)
3128 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
3129 super::child_opt(self)
3134 #[derive(Debug, PartialEq, Eq, Hash)]
3135 #[repr(transparent)]
3136 pub struct PathType {
3137 pub(crate) syntax: SyntaxNode,
3139 unsafe impl TransparentNewType for PathType {
3140 type Repr = rowan::SyntaxNode<RaTypes>;
3143 impl AstNode for PathType {
3144 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3145 match syntax.kind() {
3146 PATH_TYPE => Some(PathType::from_repr(syntax.into_repr())),
3150 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3153 impl ToOwned for PathType {
3154 type Owned = TreeArc<PathType>;
3155 fn to_owned(&self) -> TreeArc<PathType> { TreeArc::cast(self.syntax.to_owned()) }
3160 pub fn path(&self) -> Option<&Path> {
3161 super::child_opt(self)
3166 #[derive(Debug, PartialEq, Eq, Hash)]
3167 #[repr(transparent)]
3168 pub struct PlaceholderPat {
3169 pub(crate) syntax: SyntaxNode,
3171 unsafe impl TransparentNewType for PlaceholderPat {
3172 type Repr = rowan::SyntaxNode<RaTypes>;
3175 impl AstNode for PlaceholderPat {
3176 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3177 match syntax.kind() {
3178 PLACEHOLDER_PAT => Some(PlaceholderPat::from_repr(syntax.into_repr())),
3182 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3185 impl ToOwned for PlaceholderPat {
3186 type Owned = TreeArc<PlaceholderPat>;
3187 fn to_owned(&self) -> TreeArc<PlaceholderPat> { TreeArc::cast(self.syntax.to_owned()) }
3191 impl PlaceholderPat {}
3194 #[derive(Debug, PartialEq, Eq, Hash)]
3195 #[repr(transparent)]
3196 pub struct PlaceholderType {
3197 pub(crate) syntax: SyntaxNode,
3199 unsafe impl TransparentNewType for PlaceholderType {
3200 type Repr = rowan::SyntaxNode<RaTypes>;
3203 impl AstNode for PlaceholderType {
3204 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3205 match syntax.kind() {
3206 PLACEHOLDER_TYPE => Some(PlaceholderType::from_repr(syntax.into_repr())),
3210 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3213 impl ToOwned for PlaceholderType {
3214 type Owned = TreeArc<PlaceholderType>;
3215 fn to_owned(&self) -> TreeArc<PlaceholderType> { TreeArc::cast(self.syntax.to_owned()) }
3219 impl PlaceholderType {}
3222 #[derive(Debug, PartialEq, Eq, Hash)]
3223 #[repr(transparent)]
3224 pub struct PointerType {
3225 pub(crate) syntax: SyntaxNode,
3227 unsafe impl TransparentNewType for PointerType {
3228 type Repr = rowan::SyntaxNode<RaTypes>;
3231 impl AstNode for PointerType {
3232 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3233 match syntax.kind() {
3234 POINTER_TYPE => Some(PointerType::from_repr(syntax.into_repr())),
3238 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3241 impl ToOwned for PointerType {
3242 type Owned = TreeArc<PointerType>;
3243 fn to_owned(&self) -> TreeArc<PointerType> { TreeArc::cast(self.syntax.to_owned()) }
3248 pub fn type_ref(&self) -> Option<&TypeRef> {
3249 super::child_opt(self)
3254 #[derive(Debug, PartialEq, Eq, Hash)]
3255 #[repr(transparent)]
3256 pub struct PosFieldDef {
3257 pub(crate) syntax: SyntaxNode,
3259 unsafe impl TransparentNewType for PosFieldDef {
3260 type Repr = rowan::SyntaxNode<RaTypes>;
3263 impl AstNode for PosFieldDef {
3264 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3265 match syntax.kind() {
3266 POS_FIELD_DEF => Some(PosFieldDef::from_repr(syntax.into_repr())),
3270 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3273 impl ToOwned for PosFieldDef {
3274 type Owned = TreeArc<PosFieldDef>;
3275 fn to_owned(&self) -> TreeArc<PosFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
3279 impl ast::VisibilityOwner for PosFieldDef {}
3280 impl ast::AttrsOwner for PosFieldDef {}
3282 pub fn type_ref(&self) -> Option<&TypeRef> {
3283 super::child_opt(self)
3288 #[derive(Debug, PartialEq, Eq, Hash)]
3289 #[repr(transparent)]
3290 pub struct PosFieldDefList {
3291 pub(crate) syntax: SyntaxNode,
3293 unsafe impl TransparentNewType for PosFieldDefList {
3294 type Repr = rowan::SyntaxNode<RaTypes>;
3297 impl AstNode for PosFieldDefList {
3298 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3299 match syntax.kind() {
3300 POS_FIELD_DEF_LIST => Some(PosFieldDefList::from_repr(syntax.into_repr())),
3304 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3307 impl ToOwned for PosFieldDefList {
3308 type Owned = TreeArc<PosFieldDefList>;
3309 fn to_owned(&self) -> TreeArc<PosFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
3313 impl PosFieldDefList {
3314 pub fn fields(&self) -> impl Iterator<Item = &PosFieldDef> {
3315 super::children(self)
3320 #[derive(Debug, PartialEq, Eq, Hash)]
3321 #[repr(transparent)]
3322 pub struct PrefixExpr {
3323 pub(crate) syntax: SyntaxNode,
3325 unsafe impl TransparentNewType for PrefixExpr {
3326 type Repr = rowan::SyntaxNode<RaTypes>;
3329 impl AstNode for PrefixExpr {
3330 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3331 match syntax.kind() {
3332 PREFIX_EXPR => Some(PrefixExpr::from_repr(syntax.into_repr())),
3336 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3339 impl ToOwned for PrefixExpr {
3340 type Owned = TreeArc<PrefixExpr>;
3341 fn to_owned(&self) -> TreeArc<PrefixExpr> { TreeArc::cast(self.syntax.to_owned()) }
3346 pub fn expr(&self) -> Option<&Expr> {
3347 super::child_opt(self)
3352 #[derive(Debug, PartialEq, Eq, Hash)]
3353 #[repr(transparent)]
3354 pub struct RangeExpr {
3355 pub(crate) syntax: SyntaxNode,
3357 unsafe impl TransparentNewType for RangeExpr {
3358 type Repr = rowan::SyntaxNode<RaTypes>;
3361 impl AstNode for RangeExpr {
3362 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3363 match syntax.kind() {
3364 RANGE_EXPR => Some(RangeExpr::from_repr(syntax.into_repr())),
3368 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3371 impl ToOwned for RangeExpr {
3372 type Owned = TreeArc<RangeExpr>;
3373 fn to_owned(&self) -> TreeArc<RangeExpr> { TreeArc::cast(self.syntax.to_owned()) }
3380 #[derive(Debug, PartialEq, Eq, Hash)]
3381 #[repr(transparent)]
3382 pub struct RangePat {
3383 pub(crate) syntax: SyntaxNode,
3385 unsafe impl TransparentNewType for RangePat {
3386 type Repr = rowan::SyntaxNode<RaTypes>;
3389 impl AstNode for RangePat {
3390 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3391 match syntax.kind() {
3392 RANGE_PAT => Some(RangePat::from_repr(syntax.into_repr())),
3396 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3399 impl ToOwned for RangePat {
3400 type Owned = TreeArc<RangePat>;
3401 fn to_owned(&self) -> TreeArc<RangePat> { TreeArc::cast(self.syntax.to_owned()) }
3408 #[derive(Debug, PartialEq, Eq, Hash)]
3409 #[repr(transparent)]
3410 pub struct RawByteString {
3411 pub(crate) syntax: SyntaxNode,
3413 unsafe impl TransparentNewType for RawByteString {
3414 type Repr = rowan::SyntaxNode<RaTypes>;
3417 impl AstNode for RawByteString {
3418 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3419 match syntax.kind() {
3420 RAW_BYTE_STRING => Some(RawByteString::from_repr(syntax.into_repr())),
3424 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3427 impl ToOwned for RawByteString {
3428 type Owned = TreeArc<RawByteString>;
3429 fn to_owned(&self) -> TreeArc<RawByteString> { TreeArc::cast(self.syntax.to_owned()) }
3433 impl ast::AstToken for RawByteString {}
3434 impl RawByteString {}
3437 #[derive(Debug, PartialEq, Eq, Hash)]
3438 #[repr(transparent)]
3439 pub struct RawString {
3440 pub(crate) syntax: SyntaxNode,
3442 unsafe impl TransparentNewType for RawString {
3443 type Repr = rowan::SyntaxNode<RaTypes>;
3446 impl AstNode for RawString {
3447 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3448 match syntax.kind() {
3449 RAW_STRING => Some(RawString::from_repr(syntax.into_repr())),
3453 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3456 impl ToOwned for RawString {
3457 type Owned = TreeArc<RawString>;
3458 fn to_owned(&self) -> TreeArc<RawString> { TreeArc::cast(self.syntax.to_owned()) }
3462 impl ast::AstToken for RawString {}
3466 #[derive(Debug, PartialEq, Eq, Hash)]
3467 #[repr(transparent)]
3468 pub struct RefExpr {
3469 pub(crate) syntax: SyntaxNode,
3471 unsafe impl TransparentNewType for RefExpr {
3472 type Repr = rowan::SyntaxNode<RaTypes>;
3475 impl AstNode for RefExpr {
3476 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3477 match syntax.kind() {
3478 REF_EXPR => Some(RefExpr::from_repr(syntax.into_repr())),
3482 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3485 impl ToOwned for RefExpr {
3486 type Owned = TreeArc<RefExpr>;
3487 fn to_owned(&self) -> TreeArc<RefExpr> { TreeArc::cast(self.syntax.to_owned()) }
3492 pub fn expr(&self) -> Option<&Expr> {
3493 super::child_opt(self)
3498 #[derive(Debug, PartialEq, Eq, Hash)]
3499 #[repr(transparent)]
3501 pub(crate) syntax: SyntaxNode,
3503 unsafe impl TransparentNewType for RefPat {
3504 type Repr = rowan::SyntaxNode<RaTypes>;
3507 impl AstNode for RefPat {
3508 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3509 match syntax.kind() {
3510 REF_PAT => Some(RefPat::from_repr(syntax.into_repr())),
3514 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3517 impl ToOwned for RefPat {
3518 type Owned = TreeArc<RefPat>;
3519 fn to_owned(&self) -> TreeArc<RefPat> { TreeArc::cast(self.syntax.to_owned()) }
3524 pub fn pat(&self) -> Option<&Pat> {
3525 super::child_opt(self)
3530 #[derive(Debug, PartialEq, Eq, Hash)]
3531 #[repr(transparent)]
3532 pub struct ReferenceType {
3533 pub(crate) syntax: SyntaxNode,
3535 unsafe impl TransparentNewType for ReferenceType {
3536 type Repr = rowan::SyntaxNode<RaTypes>;
3539 impl AstNode for ReferenceType {
3540 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3541 match syntax.kind() {
3542 REFERENCE_TYPE => Some(ReferenceType::from_repr(syntax.into_repr())),
3546 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3549 impl ToOwned for ReferenceType {
3550 type Owned = TreeArc<ReferenceType>;
3551 fn to_owned(&self) -> TreeArc<ReferenceType> { TreeArc::cast(self.syntax.to_owned()) }
3555 impl ReferenceType {
3556 pub fn type_ref(&self) -> Option<&TypeRef> {
3557 super::child_opt(self)
3562 #[derive(Debug, PartialEq, Eq, Hash)]
3563 #[repr(transparent)]
3564 pub struct RetType {
3565 pub(crate) syntax: SyntaxNode,
3567 unsafe impl TransparentNewType for RetType {
3568 type Repr = rowan::SyntaxNode<RaTypes>;
3571 impl AstNode for RetType {
3572 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3573 match syntax.kind() {
3574 RET_TYPE => Some(RetType::from_repr(syntax.into_repr())),
3578 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3581 impl ToOwned for RetType {
3582 type Owned = TreeArc<RetType>;
3583 fn to_owned(&self) -> TreeArc<RetType> { TreeArc::cast(self.syntax.to_owned()) }
3588 pub fn type_ref(&self) -> Option<&TypeRef> {
3589 super::child_opt(self)
3594 #[derive(Debug, PartialEq, Eq, Hash)]
3595 #[repr(transparent)]
3596 pub struct ReturnExpr {
3597 pub(crate) syntax: SyntaxNode,
3599 unsafe impl TransparentNewType for ReturnExpr {
3600 type Repr = rowan::SyntaxNode<RaTypes>;
3603 impl AstNode for ReturnExpr {
3604 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3605 match syntax.kind() {
3606 RETURN_EXPR => Some(ReturnExpr::from_repr(syntax.into_repr())),
3610 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3613 impl ToOwned for ReturnExpr {
3614 type Owned = TreeArc<ReturnExpr>;
3615 fn to_owned(&self) -> TreeArc<ReturnExpr> { TreeArc::cast(self.syntax.to_owned()) }
3620 pub fn expr(&self) -> Option<&Expr> {
3621 super::child_opt(self)
3626 #[derive(Debug, PartialEq, Eq, Hash)]
3627 #[repr(transparent)]
3629 pub(crate) syntax: SyntaxNode,
3631 unsafe impl TransparentNewType for SelfKw {
3632 type Repr = rowan::SyntaxNode<RaTypes>;
3635 impl AstNode for SelfKw {
3636 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3637 match syntax.kind() {
3638 SELF_KW => Some(SelfKw::from_repr(syntax.into_repr())),
3642 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3645 impl ToOwned for SelfKw {
3646 type Owned = TreeArc<SelfKw>;
3647 fn to_owned(&self) -> TreeArc<SelfKw> { TreeArc::cast(self.syntax.to_owned()) }
3654 #[derive(Debug, PartialEq, Eq, Hash)]
3655 #[repr(transparent)]
3656 pub struct SelfParam {
3657 pub(crate) syntax: SyntaxNode,
3659 unsafe impl TransparentNewType for SelfParam {
3660 type Repr = rowan::SyntaxNode<RaTypes>;
3663 impl AstNode for SelfParam {
3664 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3665 match syntax.kind() {
3666 SELF_PARAM => Some(SelfParam::from_repr(syntax.into_repr())),
3670 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3673 impl ToOwned for SelfParam {
3674 type Owned = TreeArc<SelfParam>;
3675 fn to_owned(&self) -> TreeArc<SelfParam> { TreeArc::cast(self.syntax.to_owned()) }
3679 impl ast::TypeAscriptionOwner for SelfParam {}
3681 pub fn self_kw(&self) -> Option<&SelfKw> {
3682 super::child_opt(self)
3687 #[derive(Debug, PartialEq, Eq, Hash)]
3688 #[repr(transparent)]
3689 pub struct SlicePat {
3690 pub(crate) syntax: SyntaxNode,
3692 unsafe impl TransparentNewType for SlicePat {
3693 type Repr = rowan::SyntaxNode<RaTypes>;
3696 impl AstNode for SlicePat {
3697 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3698 match syntax.kind() {
3699 SLICE_PAT => Some(SlicePat::from_repr(syntax.into_repr())),
3703 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3706 impl ToOwned for SlicePat {
3707 type Owned = TreeArc<SlicePat>;
3708 fn to_owned(&self) -> TreeArc<SlicePat> { TreeArc::cast(self.syntax.to_owned()) }
3715 #[derive(Debug, PartialEq, Eq, Hash)]
3716 #[repr(transparent)]
3717 pub struct SliceType {
3718 pub(crate) syntax: SyntaxNode,
3720 unsafe impl TransparentNewType for SliceType {
3721 type Repr = rowan::SyntaxNode<RaTypes>;
3724 impl AstNode for SliceType {
3725 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3726 match syntax.kind() {
3727 SLICE_TYPE => Some(SliceType::from_repr(syntax.into_repr())),
3731 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3734 impl ToOwned for SliceType {
3735 type Owned = TreeArc<SliceType>;
3736 fn to_owned(&self) -> TreeArc<SliceType> { TreeArc::cast(self.syntax.to_owned()) }
3741 pub fn type_ref(&self) -> Option<&TypeRef> {
3742 super::child_opt(self)
3747 #[derive(Debug, PartialEq, Eq, Hash)]
3748 #[repr(transparent)]
3749 pub struct SourceFile {
3750 pub(crate) syntax: SyntaxNode,
3752 unsafe impl TransparentNewType for SourceFile {
3753 type Repr = rowan::SyntaxNode<RaTypes>;
3756 impl AstNode for SourceFile {
3757 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3758 match syntax.kind() {
3759 SOURCE_FILE => Some(SourceFile::from_repr(syntax.into_repr())),
3763 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3766 impl ToOwned for SourceFile {
3767 type Owned = TreeArc<SourceFile>;
3768 fn to_owned(&self) -> TreeArc<SourceFile> { TreeArc::cast(self.syntax.to_owned()) }
3772 impl ast::ModuleItemOwner for SourceFile {}
3773 impl ast::FnDefOwner for SourceFile {}
3775 pub fn modules(&self) -> impl Iterator<Item = &Module> {
3776 super::children(self)
3781 #[derive(Debug, PartialEq, Eq, Hash)]
3782 #[repr(transparent)]
3783 pub struct StaticDef {
3784 pub(crate) syntax: SyntaxNode,
3786 unsafe impl TransparentNewType for StaticDef {
3787 type Repr = rowan::SyntaxNode<RaTypes>;
3790 impl AstNode for StaticDef {
3791 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3792 match syntax.kind() {
3793 STATIC_DEF => Some(StaticDef::from_repr(syntax.into_repr())),
3797 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3800 impl ToOwned for StaticDef {
3801 type Owned = TreeArc<StaticDef>;
3802 fn to_owned(&self) -> TreeArc<StaticDef> { TreeArc::cast(self.syntax.to_owned()) }
3806 impl ast::VisibilityOwner for StaticDef {}
3807 impl ast::NameOwner for StaticDef {}
3808 impl ast::TypeParamsOwner for StaticDef {}
3809 impl ast::AttrsOwner for StaticDef {}
3810 impl ast::DocCommentsOwner for StaticDef {}
3811 impl ast::TypeAscriptionOwner for StaticDef {}
3815 #[derive(Debug, PartialEq, Eq, Hash)]
3816 #[repr(transparent)]
3818 pub(crate) syntax: SyntaxNode,
3820 unsafe impl TransparentNewType for Stmt {
3821 type Repr = rowan::SyntaxNode<RaTypes>;
3824 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3825 pub enum StmtKind<'a> {
3826 ExprStmt(&'a ExprStmt),
3827 LetStmt(&'a LetStmt),
3829 impl<'a> From<&'a ExprStmt> for &'a Stmt {
3830 fn from(n: &'a ExprStmt) -> &'a Stmt {
3831 Stmt::cast(&n.syntax).unwrap()
3834 impl<'a> From<&'a LetStmt> for &'a Stmt {
3835 fn from(n: &'a LetStmt) -> &'a Stmt {
3836 Stmt::cast(&n.syntax).unwrap()
3841 impl AstNode for Stmt {
3842 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3843 match syntax.kind() {
3845 | LET_STMT => Some(Stmt::from_repr(syntax.into_repr())),
3849 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3852 impl ToOwned for Stmt {
3853 type Owned = TreeArc<Stmt>;
3854 fn to_owned(&self) -> TreeArc<Stmt> { TreeArc::cast(self.syntax.to_owned()) }
3858 pub fn kind(&self) -> StmtKind {
3859 match self.syntax.kind() {
3860 EXPR_STMT => StmtKind::ExprStmt(ExprStmt::cast(&self.syntax).unwrap()),
3861 LET_STMT => StmtKind::LetStmt(LetStmt::cast(&self.syntax).unwrap()),
3862 _ => unreachable!(),
3870 #[derive(Debug, PartialEq, Eq, Hash)]
3871 #[repr(transparent)]
3873 pub(crate) syntax: SyntaxNode,
3875 unsafe impl TransparentNewType for String {
3876 type Repr = rowan::SyntaxNode<RaTypes>;
3879 impl AstNode for String {
3880 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3881 match syntax.kind() {
3882 STRING => Some(String::from_repr(syntax.into_repr())),
3886 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3889 impl ToOwned for String {
3890 type Owned = TreeArc<String>;
3891 fn to_owned(&self) -> TreeArc<String> { TreeArc::cast(self.syntax.to_owned()) }
3895 impl ast::AstToken for String {}
3899 #[derive(Debug, PartialEq, Eq, Hash)]
3900 #[repr(transparent)]
3901 pub struct StructDef {
3902 pub(crate) syntax: SyntaxNode,
3904 unsafe impl TransparentNewType for StructDef {
3905 type Repr = rowan::SyntaxNode<RaTypes>;
3908 impl AstNode for StructDef {
3909 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3910 match syntax.kind() {
3911 STRUCT_DEF => Some(StructDef::from_repr(syntax.into_repr())),
3915 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3918 impl ToOwned for StructDef {
3919 type Owned = TreeArc<StructDef>;
3920 fn to_owned(&self) -> TreeArc<StructDef> { TreeArc::cast(self.syntax.to_owned()) }
3924 impl ast::VisibilityOwner for StructDef {}
3925 impl ast::NameOwner for StructDef {}
3926 impl ast::TypeParamsOwner for StructDef {}
3927 impl ast::AttrsOwner for StructDef {}
3928 impl ast::DocCommentsOwner for StructDef {}
3932 #[derive(Debug, PartialEq, Eq, Hash)]
3933 #[repr(transparent)]
3934 pub struct StructLit {
3935 pub(crate) syntax: SyntaxNode,
3937 unsafe impl TransparentNewType for StructLit {
3938 type Repr = rowan::SyntaxNode<RaTypes>;
3941 impl AstNode for StructLit {
3942 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3943 match syntax.kind() {
3944 STRUCT_LIT => Some(StructLit::from_repr(syntax.into_repr())),
3948 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3951 impl ToOwned for StructLit {
3952 type Owned = TreeArc<StructLit>;
3953 fn to_owned(&self) -> TreeArc<StructLit> { TreeArc::cast(self.syntax.to_owned()) }
3958 pub fn path(&self) -> Option<&Path> {
3959 super::child_opt(self)
3962 pub fn named_field_list(&self) -> Option<&NamedFieldList> {
3963 super::child_opt(self)
3966 pub fn spread(&self) -> Option<&Expr> {
3967 super::child_opt(self)
3972 #[derive(Debug, PartialEq, Eq, Hash)]
3973 #[repr(transparent)]
3974 pub struct StructPat {
3975 pub(crate) syntax: SyntaxNode,
3977 unsafe impl TransparentNewType for StructPat {
3978 type Repr = rowan::SyntaxNode<RaTypes>;
3981 impl AstNode for StructPat {
3982 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3983 match syntax.kind() {
3984 STRUCT_PAT => Some(StructPat::from_repr(syntax.into_repr())),
3988 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3991 impl ToOwned for StructPat {
3992 type Owned = TreeArc<StructPat>;
3993 fn to_owned(&self) -> TreeArc<StructPat> { TreeArc::cast(self.syntax.to_owned()) }
3998 pub fn field_pat_list(&self) -> Option<&FieldPatList> {
3999 super::child_opt(self)
4002 pub fn path(&self) -> Option<&Path> {
4003 super::child_opt(self)
4008 #[derive(Debug, PartialEq, Eq, Hash)]
4009 #[repr(transparent)]
4010 pub struct TokenTree {
4011 pub(crate) syntax: SyntaxNode,
4013 unsafe impl TransparentNewType for TokenTree {
4014 type Repr = rowan::SyntaxNode<RaTypes>;
4017 impl AstNode for TokenTree {
4018 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4019 match syntax.kind() {
4020 TOKEN_TREE => Some(TokenTree::from_repr(syntax.into_repr())),
4024 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4027 impl ToOwned for TokenTree {
4028 type Owned = TreeArc<TokenTree>;
4029 fn to_owned(&self) -> TreeArc<TokenTree> { TreeArc::cast(self.syntax.to_owned()) }
4036 #[derive(Debug, PartialEq, Eq, Hash)]
4037 #[repr(transparent)]
4038 pub struct TraitDef {
4039 pub(crate) syntax: SyntaxNode,
4041 unsafe impl TransparentNewType for TraitDef {
4042 type Repr = rowan::SyntaxNode<RaTypes>;
4045 impl AstNode for TraitDef {
4046 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4047 match syntax.kind() {
4048 TRAIT_DEF => Some(TraitDef::from_repr(syntax.into_repr())),
4052 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4055 impl ToOwned for TraitDef {
4056 type Owned = TreeArc<TraitDef>;
4057 fn to_owned(&self) -> TreeArc<TraitDef> { TreeArc::cast(self.syntax.to_owned()) }
4061 impl ast::VisibilityOwner for TraitDef {}
4062 impl ast::NameOwner for TraitDef {}
4063 impl ast::AttrsOwner for TraitDef {}
4064 impl ast::DocCommentsOwner for TraitDef {}
4065 impl ast::TypeParamsOwner for TraitDef {}
4066 impl ast::TypeBoundsOwner for TraitDef {}
4068 pub fn item_list(&self) -> Option<&ItemList> {
4069 super::child_opt(self)
4074 #[derive(Debug, PartialEq, Eq, Hash)]
4075 #[repr(transparent)]
4077 pub(crate) syntax: SyntaxNode,
4079 unsafe impl TransparentNewType for TrueKw {
4080 type Repr = rowan::SyntaxNode<RaTypes>;
4083 impl AstNode for TrueKw {
4084 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4085 match syntax.kind() {
4086 TRUE_KW => Some(TrueKw::from_repr(syntax.into_repr())),
4090 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4093 impl ToOwned for TrueKw {
4094 type Owned = TreeArc<TrueKw>;
4095 fn to_owned(&self) -> TreeArc<TrueKw> { TreeArc::cast(self.syntax.to_owned()) }
4099 impl ast::AstToken for TrueKw {}
4103 #[derive(Debug, PartialEq, Eq, Hash)]
4104 #[repr(transparent)]
4105 pub struct TryExpr {
4106 pub(crate) syntax: SyntaxNode,
4108 unsafe impl TransparentNewType for TryExpr {
4109 type Repr = rowan::SyntaxNode<RaTypes>;
4112 impl AstNode for TryExpr {
4113 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4114 match syntax.kind() {
4115 TRY_EXPR => Some(TryExpr::from_repr(syntax.into_repr())),
4119 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4122 impl ToOwned for TryExpr {
4123 type Owned = TreeArc<TryExpr>;
4124 fn to_owned(&self) -> TreeArc<TryExpr> { TreeArc::cast(self.syntax.to_owned()) }
4129 pub fn expr(&self) -> Option<&Expr> {
4130 super::child_opt(self)
4135 #[derive(Debug, PartialEq, Eq, Hash)]
4136 #[repr(transparent)]
4137 pub struct TupleExpr {
4138 pub(crate) syntax: SyntaxNode,
4140 unsafe impl TransparentNewType for TupleExpr {
4141 type Repr = rowan::SyntaxNode<RaTypes>;
4144 impl AstNode for TupleExpr {
4145 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4146 match syntax.kind() {
4147 TUPLE_EXPR => Some(TupleExpr::from_repr(syntax.into_repr())),
4151 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4154 impl ToOwned for TupleExpr {
4155 type Owned = TreeArc<TupleExpr>;
4156 fn to_owned(&self) -> TreeArc<TupleExpr> { TreeArc::cast(self.syntax.to_owned()) }
4161 pub fn exprs(&self) -> impl Iterator<Item = &Expr> {
4162 super::children(self)
4167 #[derive(Debug, PartialEq, Eq, Hash)]
4168 #[repr(transparent)]
4169 pub struct TuplePat {
4170 pub(crate) syntax: SyntaxNode,
4172 unsafe impl TransparentNewType for TuplePat {
4173 type Repr = rowan::SyntaxNode<RaTypes>;
4176 impl AstNode for TuplePat {
4177 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4178 match syntax.kind() {
4179 TUPLE_PAT => Some(TuplePat::from_repr(syntax.into_repr())),
4183 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4186 impl ToOwned for TuplePat {
4187 type Owned = TreeArc<TuplePat>;
4188 fn to_owned(&self) -> TreeArc<TuplePat> { TreeArc::cast(self.syntax.to_owned()) }
4193 pub fn args(&self) -> impl Iterator<Item = &Pat> {
4194 super::children(self)
4199 #[derive(Debug, PartialEq, Eq, Hash)]
4200 #[repr(transparent)]
4201 pub struct TupleStructPat {
4202 pub(crate) syntax: SyntaxNode,
4204 unsafe impl TransparentNewType for TupleStructPat {
4205 type Repr = rowan::SyntaxNode<RaTypes>;
4208 impl AstNode for TupleStructPat {
4209 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4210 match syntax.kind() {
4211 TUPLE_STRUCT_PAT => Some(TupleStructPat::from_repr(syntax.into_repr())),
4215 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4218 impl ToOwned for TupleStructPat {
4219 type Owned = TreeArc<TupleStructPat>;
4220 fn to_owned(&self) -> TreeArc<TupleStructPat> { TreeArc::cast(self.syntax.to_owned()) }
4224 impl TupleStructPat {
4225 pub fn args(&self) -> impl Iterator<Item = &Pat> {
4226 super::children(self)
4229 pub fn path(&self) -> Option<&Path> {
4230 super::child_opt(self)
4235 #[derive(Debug, PartialEq, Eq, Hash)]
4236 #[repr(transparent)]
4237 pub struct TupleType {
4238 pub(crate) syntax: SyntaxNode,
4240 unsafe impl TransparentNewType for TupleType {
4241 type Repr = rowan::SyntaxNode<RaTypes>;
4244 impl AstNode for TupleType {
4245 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4246 match syntax.kind() {
4247 TUPLE_TYPE => Some(TupleType::from_repr(syntax.into_repr())),
4251 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4254 impl ToOwned for TupleType {
4255 type Owned = TreeArc<TupleType>;
4256 fn to_owned(&self) -> TreeArc<TupleType> { TreeArc::cast(self.syntax.to_owned()) }
4261 pub fn fields(&self) -> impl Iterator<Item = &TypeRef> {
4262 super::children(self)
4267 #[derive(Debug, PartialEq, Eq, Hash)]
4268 #[repr(transparent)]
4269 pub struct TypeAliasDef {
4270 pub(crate) syntax: SyntaxNode,
4272 unsafe impl TransparentNewType for TypeAliasDef {
4273 type Repr = rowan::SyntaxNode<RaTypes>;
4276 impl AstNode for TypeAliasDef {
4277 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4278 match syntax.kind() {
4279 TYPE_ALIAS_DEF => Some(TypeAliasDef::from_repr(syntax.into_repr())),
4283 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4286 impl ToOwned for TypeAliasDef {
4287 type Owned = TreeArc<TypeAliasDef>;
4288 fn to_owned(&self) -> TreeArc<TypeAliasDef> { TreeArc::cast(self.syntax.to_owned()) }
4292 impl ast::VisibilityOwner for TypeAliasDef {}
4293 impl ast::NameOwner for TypeAliasDef {}
4294 impl ast::TypeParamsOwner for TypeAliasDef {}
4295 impl ast::AttrsOwner for TypeAliasDef {}
4296 impl ast::DocCommentsOwner for TypeAliasDef {}
4297 impl ast::TypeBoundsOwner for TypeAliasDef {}
4299 pub fn type_ref(&self) -> Option<&TypeRef> {
4300 super::child_opt(self)
4305 #[derive(Debug, PartialEq, Eq, Hash)]
4306 #[repr(transparent)]
4307 pub struct TypeArg {
4308 pub(crate) syntax: SyntaxNode,
4310 unsafe impl TransparentNewType for TypeArg {
4311 type Repr = rowan::SyntaxNode<RaTypes>;
4314 impl AstNode for TypeArg {
4315 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4316 match syntax.kind() {
4317 TYPE_ARG => Some(TypeArg::from_repr(syntax.into_repr())),
4321 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4324 impl ToOwned for TypeArg {
4325 type Owned = TreeArc<TypeArg>;
4326 fn to_owned(&self) -> TreeArc<TypeArg> { TreeArc::cast(self.syntax.to_owned()) }
4331 pub fn type_ref(&self) -> Option<&TypeRef> {
4332 super::child_opt(self)
4337 #[derive(Debug, PartialEq, Eq, Hash)]
4338 #[repr(transparent)]
4339 pub struct TypeArgList {
4340 pub(crate) syntax: SyntaxNode,
4342 unsafe impl TransparentNewType for TypeArgList {
4343 type Repr = rowan::SyntaxNode<RaTypes>;
4346 impl AstNode for TypeArgList {
4347 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4348 match syntax.kind() {
4349 TYPE_ARG_LIST => Some(TypeArgList::from_repr(syntax.into_repr())),
4353 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4356 impl ToOwned for TypeArgList {
4357 type Owned = TreeArc<TypeArgList>;
4358 fn to_owned(&self) -> TreeArc<TypeArgList> { TreeArc::cast(self.syntax.to_owned()) }
4363 pub fn type_args(&self) -> impl Iterator<Item = &TypeArg> {
4364 super::children(self)
4367 pub fn lifetime_args(&self) -> impl Iterator<Item = &LifetimeArg> {
4368 super::children(self)
4371 pub fn assoc_type_args(&self) -> impl Iterator<Item = &AssocTypeArg> {
4372 super::children(self)
4377 #[derive(Debug, PartialEq, Eq, Hash)]
4378 #[repr(transparent)]
4379 pub struct TypeBound {
4380 pub(crate) syntax: SyntaxNode,
4382 unsafe impl TransparentNewType for TypeBound {
4383 type Repr = rowan::SyntaxNode<RaTypes>;
4386 impl AstNode for TypeBound {
4387 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4388 match syntax.kind() {
4389 TYPE_BOUND => Some(TypeBound::from_repr(syntax.into_repr())),
4393 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4396 impl ToOwned for TypeBound {
4397 type Owned = TreeArc<TypeBound>;
4398 fn to_owned(&self) -> TreeArc<TypeBound> { TreeArc::cast(self.syntax.to_owned()) }
4403 pub fn type_ref(&self) -> Option<&TypeRef> {
4404 super::child_opt(self)
4407 pub fn lifetime(&self) -> Option<&Lifetime> {
4408 super::child_opt(self)
4413 #[derive(Debug, PartialEq, Eq, Hash)]
4414 #[repr(transparent)]
4415 pub struct TypeBoundList {
4416 pub(crate) syntax: SyntaxNode,
4418 unsafe impl TransparentNewType for TypeBoundList {
4419 type Repr = rowan::SyntaxNode<RaTypes>;
4422 impl AstNode for TypeBoundList {
4423 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4424 match syntax.kind() {
4425 TYPE_BOUND_LIST => Some(TypeBoundList::from_repr(syntax.into_repr())),
4429 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4432 impl ToOwned for TypeBoundList {
4433 type Owned = TreeArc<TypeBoundList>;
4434 fn to_owned(&self) -> TreeArc<TypeBoundList> { TreeArc::cast(self.syntax.to_owned()) }
4438 impl TypeBoundList {
4439 pub fn bounds(&self) -> impl Iterator<Item = &TypeBound> {
4440 super::children(self)
4445 #[derive(Debug, PartialEq, Eq, Hash)]
4446 #[repr(transparent)]
4447 pub struct TypeParam {
4448 pub(crate) syntax: SyntaxNode,
4450 unsafe impl TransparentNewType for TypeParam {
4451 type Repr = rowan::SyntaxNode<RaTypes>;
4454 impl AstNode for TypeParam {
4455 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4456 match syntax.kind() {
4457 TYPE_PARAM => Some(TypeParam::from_repr(syntax.into_repr())),
4461 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4464 impl ToOwned for TypeParam {
4465 type Owned = TreeArc<TypeParam>;
4466 fn to_owned(&self) -> TreeArc<TypeParam> { TreeArc::cast(self.syntax.to_owned()) }
4470 impl ast::NameOwner for TypeParam {}
4471 impl ast::AttrsOwner for TypeParam {}
4472 impl ast::TypeBoundsOwner for TypeParam {}
4476 #[derive(Debug, PartialEq, Eq, Hash)]
4477 #[repr(transparent)]
4478 pub struct TypeParamList {
4479 pub(crate) syntax: SyntaxNode,
4481 unsafe impl TransparentNewType for TypeParamList {
4482 type Repr = rowan::SyntaxNode<RaTypes>;
4485 impl AstNode for TypeParamList {
4486 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4487 match syntax.kind() {
4488 TYPE_PARAM_LIST => Some(TypeParamList::from_repr(syntax.into_repr())),
4492 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4495 impl ToOwned for TypeParamList {
4496 type Owned = TreeArc<TypeParamList>;
4497 fn to_owned(&self) -> TreeArc<TypeParamList> { TreeArc::cast(self.syntax.to_owned()) }
4501 impl TypeParamList {
4502 pub fn type_params(&self) -> impl Iterator<Item = &TypeParam> {
4503 super::children(self)
4506 pub fn lifetime_params(&self) -> impl Iterator<Item = &LifetimeParam> {
4507 super::children(self)
4512 #[derive(Debug, PartialEq, Eq, Hash)]
4513 #[repr(transparent)]
4514 pub struct TypeRef {
4515 pub(crate) syntax: SyntaxNode,
4517 unsafe impl TransparentNewType for TypeRef {
4518 type Repr = rowan::SyntaxNode<RaTypes>;
4521 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4522 pub enum TypeRefKind<'a> {
4523 ParenType(&'a ParenType),
4524 TupleType(&'a TupleType),
4525 NeverType(&'a NeverType),
4526 PathType(&'a PathType),
4527 PointerType(&'a PointerType),
4528 ArrayType(&'a ArrayType),
4529 SliceType(&'a SliceType),
4530 ReferenceType(&'a ReferenceType),
4531 PlaceholderType(&'a PlaceholderType),
4532 FnPointerType(&'a FnPointerType),
4533 ForType(&'a ForType),
4534 ImplTraitType(&'a ImplTraitType),
4535 DynTraitType(&'a DynTraitType),
4537 impl<'a> From<&'a ParenType> for &'a TypeRef {
4538 fn from(n: &'a ParenType) -> &'a TypeRef {
4539 TypeRef::cast(&n.syntax).unwrap()
4542 impl<'a> From<&'a TupleType> for &'a TypeRef {
4543 fn from(n: &'a TupleType) -> &'a TypeRef {
4544 TypeRef::cast(&n.syntax).unwrap()
4547 impl<'a> From<&'a NeverType> for &'a TypeRef {
4548 fn from(n: &'a NeverType) -> &'a TypeRef {
4549 TypeRef::cast(&n.syntax).unwrap()
4552 impl<'a> From<&'a PathType> for &'a TypeRef {
4553 fn from(n: &'a PathType) -> &'a TypeRef {
4554 TypeRef::cast(&n.syntax).unwrap()
4557 impl<'a> From<&'a PointerType> for &'a TypeRef {
4558 fn from(n: &'a PointerType) -> &'a TypeRef {
4559 TypeRef::cast(&n.syntax).unwrap()
4562 impl<'a> From<&'a ArrayType> for &'a TypeRef {
4563 fn from(n: &'a ArrayType) -> &'a TypeRef {
4564 TypeRef::cast(&n.syntax).unwrap()
4567 impl<'a> From<&'a SliceType> for &'a TypeRef {
4568 fn from(n: &'a SliceType) -> &'a TypeRef {
4569 TypeRef::cast(&n.syntax).unwrap()
4572 impl<'a> From<&'a ReferenceType> for &'a TypeRef {
4573 fn from(n: &'a ReferenceType) -> &'a TypeRef {
4574 TypeRef::cast(&n.syntax).unwrap()
4577 impl<'a> From<&'a PlaceholderType> for &'a TypeRef {
4578 fn from(n: &'a PlaceholderType) -> &'a TypeRef {
4579 TypeRef::cast(&n.syntax).unwrap()
4582 impl<'a> From<&'a FnPointerType> for &'a TypeRef {
4583 fn from(n: &'a FnPointerType) -> &'a TypeRef {
4584 TypeRef::cast(&n.syntax).unwrap()
4587 impl<'a> From<&'a ForType> for &'a TypeRef {
4588 fn from(n: &'a ForType) -> &'a TypeRef {
4589 TypeRef::cast(&n.syntax).unwrap()
4592 impl<'a> From<&'a ImplTraitType> for &'a TypeRef {
4593 fn from(n: &'a ImplTraitType) -> &'a TypeRef {
4594 TypeRef::cast(&n.syntax).unwrap()
4597 impl<'a> From<&'a DynTraitType> for &'a TypeRef {
4598 fn from(n: &'a DynTraitType) -> &'a TypeRef {
4599 TypeRef::cast(&n.syntax).unwrap()
4604 impl AstNode for TypeRef {
4605 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4606 match syntax.kind() {
4619 | DYN_TRAIT_TYPE => Some(TypeRef::from_repr(syntax.into_repr())),
4623 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4626 impl ToOwned for TypeRef {
4627 type Owned = TreeArc<TypeRef>;
4628 fn to_owned(&self) -> TreeArc<TypeRef> { TreeArc::cast(self.syntax.to_owned()) }
4632 pub fn kind(&self) -> TypeRefKind {
4633 match self.syntax.kind() {
4634 PAREN_TYPE => TypeRefKind::ParenType(ParenType::cast(&self.syntax).unwrap()),
4635 TUPLE_TYPE => TypeRefKind::TupleType(TupleType::cast(&self.syntax).unwrap()),
4636 NEVER_TYPE => TypeRefKind::NeverType(NeverType::cast(&self.syntax).unwrap()),
4637 PATH_TYPE => TypeRefKind::PathType(PathType::cast(&self.syntax).unwrap()),
4638 POINTER_TYPE => TypeRefKind::PointerType(PointerType::cast(&self.syntax).unwrap()),
4639 ARRAY_TYPE => TypeRefKind::ArrayType(ArrayType::cast(&self.syntax).unwrap()),
4640 SLICE_TYPE => TypeRefKind::SliceType(SliceType::cast(&self.syntax).unwrap()),
4641 REFERENCE_TYPE => TypeRefKind::ReferenceType(ReferenceType::cast(&self.syntax).unwrap()),
4642 PLACEHOLDER_TYPE => TypeRefKind::PlaceholderType(PlaceholderType::cast(&self.syntax).unwrap()),
4643 FN_POINTER_TYPE => TypeRefKind::FnPointerType(FnPointerType::cast(&self.syntax).unwrap()),
4644 FOR_TYPE => TypeRefKind::ForType(ForType::cast(&self.syntax).unwrap()),
4645 IMPL_TRAIT_TYPE => TypeRefKind::ImplTraitType(ImplTraitType::cast(&self.syntax).unwrap()),
4646 DYN_TRAIT_TYPE => TypeRefKind::DynTraitType(DynTraitType::cast(&self.syntax).unwrap()),
4647 _ => unreachable!(),
4655 #[derive(Debug, PartialEq, Eq, Hash)]
4656 #[repr(transparent)]
4657 pub struct UseItem {
4658 pub(crate) syntax: SyntaxNode,
4660 unsafe impl TransparentNewType for UseItem {
4661 type Repr = rowan::SyntaxNode<RaTypes>;
4664 impl AstNode for UseItem {
4665 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4666 match syntax.kind() {
4667 USE_ITEM => Some(UseItem::from_repr(syntax.into_repr())),
4671 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4674 impl ToOwned for UseItem {
4675 type Owned = TreeArc<UseItem>;
4676 fn to_owned(&self) -> TreeArc<UseItem> { TreeArc::cast(self.syntax.to_owned()) }
4680 impl ast::AttrsOwner for UseItem {}
4682 pub fn use_tree(&self) -> Option<&UseTree> {
4683 super::child_opt(self)
4688 #[derive(Debug, PartialEq, Eq, Hash)]
4689 #[repr(transparent)]
4690 pub struct UseTree {
4691 pub(crate) syntax: SyntaxNode,
4693 unsafe impl TransparentNewType for UseTree {
4694 type Repr = rowan::SyntaxNode<RaTypes>;
4697 impl AstNode for UseTree {
4698 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4699 match syntax.kind() {
4700 USE_TREE => Some(UseTree::from_repr(syntax.into_repr())),
4704 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4707 impl ToOwned for UseTree {
4708 type Owned = TreeArc<UseTree>;
4709 fn to_owned(&self) -> TreeArc<UseTree> { TreeArc::cast(self.syntax.to_owned()) }
4714 pub fn path(&self) -> Option<&Path> {
4715 super::child_opt(self)
4718 pub fn use_tree_list(&self) -> Option<&UseTreeList> {
4719 super::child_opt(self)
4722 pub fn alias(&self) -> Option<&Alias> {
4723 super::child_opt(self)
4728 #[derive(Debug, PartialEq, Eq, Hash)]
4729 #[repr(transparent)]
4730 pub struct UseTreeList {
4731 pub(crate) syntax: SyntaxNode,
4733 unsafe impl TransparentNewType for UseTreeList {
4734 type Repr = rowan::SyntaxNode<RaTypes>;
4737 impl AstNode for UseTreeList {
4738 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4739 match syntax.kind() {
4740 USE_TREE_LIST => Some(UseTreeList::from_repr(syntax.into_repr())),
4744 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4747 impl ToOwned for UseTreeList {
4748 type Owned = TreeArc<UseTreeList>;
4749 fn to_owned(&self) -> TreeArc<UseTreeList> { TreeArc::cast(self.syntax.to_owned()) }
4754 pub fn use_trees(&self) -> impl Iterator<Item = &UseTree> {
4755 super::children(self)
4760 #[derive(Debug, PartialEq, Eq, Hash)]
4761 #[repr(transparent)]
4762 pub struct Visibility {
4763 pub(crate) syntax: SyntaxNode,
4765 unsafe impl TransparentNewType for Visibility {
4766 type Repr = rowan::SyntaxNode<RaTypes>;
4769 impl AstNode for Visibility {
4770 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4771 match syntax.kind() {
4772 VISIBILITY => Some(Visibility::from_repr(syntax.into_repr())),
4776 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4779 impl ToOwned for Visibility {
4780 type Owned = TreeArc<Visibility>;
4781 fn to_owned(&self) -> TreeArc<Visibility> { TreeArc::cast(self.syntax.to_owned()) }
4788 #[derive(Debug, PartialEq, Eq, Hash)]
4789 #[repr(transparent)]
4790 pub struct WhereClause {
4791 pub(crate) syntax: SyntaxNode,
4793 unsafe impl TransparentNewType for WhereClause {
4794 type Repr = rowan::SyntaxNode<RaTypes>;
4797 impl AstNode for WhereClause {
4798 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4799 match syntax.kind() {
4800 WHERE_CLAUSE => Some(WhereClause::from_repr(syntax.into_repr())),
4804 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4807 impl ToOwned for WhereClause {
4808 type Owned = TreeArc<WhereClause>;
4809 fn to_owned(&self) -> TreeArc<WhereClause> { TreeArc::cast(self.syntax.to_owned()) }
4814 pub fn predicates(&self) -> impl Iterator<Item = &WherePred> {
4815 super::children(self)
4820 #[derive(Debug, PartialEq, Eq, Hash)]
4821 #[repr(transparent)]
4822 pub struct WherePred {
4823 pub(crate) syntax: SyntaxNode,
4825 unsafe impl TransparentNewType for WherePred {
4826 type Repr = rowan::SyntaxNode<RaTypes>;
4829 impl AstNode for WherePred {
4830 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4831 match syntax.kind() {
4832 WHERE_PRED => Some(WherePred::from_repr(syntax.into_repr())),
4836 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4839 impl ToOwned for WherePred {
4840 type Owned = TreeArc<WherePred>;
4841 fn to_owned(&self) -> TreeArc<WherePred> { TreeArc::cast(self.syntax.to_owned()) }
4845 impl ast::TypeBoundsOwner for WherePred {}
4847 pub fn type_ref(&self) -> Option<&TypeRef> {
4848 super::child_opt(self)
4851 pub fn lifetime(&self) -> Option<&Lifetime> {
4852 super::child_opt(self)
4857 #[derive(Debug, PartialEq, Eq, Hash)]
4858 #[repr(transparent)]
4859 pub struct WhileExpr {
4860 pub(crate) syntax: SyntaxNode,
4862 unsafe impl TransparentNewType for WhileExpr {
4863 type Repr = rowan::SyntaxNode<RaTypes>;
4866 impl AstNode for WhileExpr {
4867 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4868 match syntax.kind() {
4869 WHILE_EXPR => Some(WhileExpr::from_repr(syntax.into_repr())),
4873 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4876 impl ToOwned for WhileExpr {
4877 type Owned = TreeArc<WhileExpr>;
4878 fn to_owned(&self) -> TreeArc<WhileExpr> { TreeArc::cast(self.syntax.to_owned()) }
4882 impl ast::LoopBodyOwner for WhileExpr {}
4884 pub fn condition(&self) -> Option<&Condition> {
4885 super::child_opt(self)
4890 #[derive(Debug, PartialEq, Eq, Hash)]
4891 #[repr(transparent)]
4892 pub struct Whitespace {
4893 pub(crate) syntax: SyntaxNode,
4895 unsafe impl TransparentNewType for Whitespace {
4896 type Repr = rowan::SyntaxNode<RaTypes>;
4899 impl AstNode for Whitespace {
4900 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4901 match syntax.kind() {
4902 WHITESPACE => Some(Whitespace::from_repr(syntax.into_repr())),
4906 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4909 impl ToOwned for Whitespace {
4910 type Owned = TreeArc<Whitespace>;
4911 fn to_owned(&self) -> TreeArc<Whitespace> { TreeArc::cast(self.syntax.to_owned()) }
4915 impl ast::AstToken for Whitespace {}