// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run // Do not edit manually //! This module contains auto-generated Rust AST. Like `SyntaxNode`s, AST nodes //! are generic over ownership: `X<'a>` things are `Copy` references, `XNode` //! are Arc-based. You can switch between the two variants using `.owned` and //! `.borrowed` functions. Most of the code works with borowed mode, and only //! this mode has all AST accessors. #![cfg_attr(rustfmt, rustfmt_skip)] use std::hash::{Hash, Hasher}; use crate::{ ast, SyntaxNode, SyntaxNodeRef, AstNode, yellow::{TreeRoot, RaTypes, OwnedRoot, RefRoot}, SyntaxKind::*, }; // ArgList #[derive(Debug, Clone, Copy,)] pub struct ArgListNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ArgList<'a> = ArgListNode>; impl, R2: TreeRoot> PartialEq> for ArgListNode { fn eq(&self, other: &ArgListNode) -> bool { self.syntax == other.syntax } } impl> Eq for ArgListNode {} impl> Hash for ArgListNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ArgList<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { ARG_LIST => Some(ArgList { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ArgListNode { pub fn borrowed(&self) -> ArgList { ArgListNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ArgListNode { ArgListNode { syntax: self.syntax.owned() } } } impl<'a> ArgList<'a> { pub fn args(self) -> impl Iterator> + 'a { super::children(self) } } // ArrayExpr #[derive(Debug, Clone, Copy,)] pub struct ArrayExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ArrayExpr<'a> = ArrayExprNode>; impl, R2: TreeRoot> PartialEq> for ArrayExprNode { fn eq(&self, other: &ArrayExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for ArrayExprNode {} impl> Hash for ArrayExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ArrayExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { ARRAY_EXPR => Some(ArrayExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ArrayExprNode { pub fn borrowed(&self) -> ArrayExpr { ArrayExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ArrayExprNode { ArrayExprNode { syntax: self.syntax.owned() } } } impl<'a> ArrayExpr<'a> {} // ArrayType #[derive(Debug, Clone, Copy,)] pub struct ArrayTypeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ArrayType<'a> = ArrayTypeNode>; impl, R2: TreeRoot> PartialEq> for ArrayTypeNode { fn eq(&self, other: &ArrayTypeNode) -> bool { self.syntax == other.syntax } } impl> Eq for ArrayTypeNode {} impl> Hash for ArrayTypeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ArrayType<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { ARRAY_TYPE => Some(ArrayType { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ArrayTypeNode { pub fn borrowed(&self) -> ArrayType { ArrayTypeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ArrayTypeNode { ArrayTypeNode { syntax: self.syntax.owned() } } } impl<'a> ArrayType<'a> {} // Attr #[derive(Debug, Clone, Copy,)] pub struct AttrNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type Attr<'a> = AttrNode>; impl, R2: TreeRoot> PartialEq> for AttrNode { fn eq(&self, other: &AttrNode) -> bool { self.syntax == other.syntax } } impl> Eq for AttrNode {} impl> Hash for AttrNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for Attr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { ATTR => Some(Attr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> AttrNode { pub fn borrowed(&self) -> Attr { AttrNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> AttrNode { AttrNode { syntax: self.syntax.owned() } } } impl<'a> Attr<'a> { pub fn value(self) -> Option> { super::child_opt(self) } } // BinExpr #[derive(Debug, Clone, Copy,)] pub struct BinExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type BinExpr<'a> = BinExprNode>; impl, R2: TreeRoot> PartialEq> for BinExprNode { fn eq(&self, other: &BinExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for BinExprNode {} impl> Hash for BinExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for BinExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { BIN_EXPR => Some(BinExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> BinExprNode { pub fn borrowed(&self) -> BinExpr { BinExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> BinExprNode { BinExprNode { syntax: self.syntax.owned() } } } impl<'a> BinExpr<'a> {} // BindPat #[derive(Debug, Clone, Copy,)] pub struct BindPatNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type BindPat<'a> = BindPatNode>; impl, R2: TreeRoot> PartialEq> for BindPatNode { fn eq(&self, other: &BindPatNode) -> bool { self.syntax == other.syntax } } impl> Eq for BindPatNode {} impl> Hash for BindPatNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for BindPat<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { BIND_PAT => Some(BindPat { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> BindPatNode { pub fn borrowed(&self) -> BindPat { BindPatNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> BindPatNode { BindPatNode { syntax: self.syntax.owned() } } } impl<'a> ast::NameOwner<'a> for BindPat<'a> {} impl<'a> BindPat<'a> {} // Block #[derive(Debug, Clone, Copy,)] pub struct BlockNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type Block<'a> = BlockNode>; impl, R2: TreeRoot> PartialEq> for BlockNode { fn eq(&self, other: &BlockNode) -> bool { self.syntax == other.syntax } } impl> Eq for BlockNode {} impl> Hash for BlockNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for Block<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { BLOCK => Some(Block { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> BlockNode { pub fn borrowed(&self) -> Block { BlockNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> BlockNode { BlockNode { syntax: self.syntax.owned() } } } impl<'a> Block<'a> { pub fn statements(self) -> impl Iterator> + 'a { super::children(self) } pub fn expr(self) -> Option> { super::child_opt(self) } } // BlockExpr #[derive(Debug, Clone, Copy,)] pub struct BlockExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type BlockExpr<'a> = BlockExprNode>; impl, R2: TreeRoot> PartialEq> for BlockExprNode { fn eq(&self, other: &BlockExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for BlockExprNode {} impl> Hash for BlockExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for BlockExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { BLOCK_EXPR => Some(BlockExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> BlockExprNode { pub fn borrowed(&self) -> BlockExpr { BlockExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> BlockExprNode { BlockExprNode { syntax: self.syntax.owned() } } } impl<'a> BlockExpr<'a> { pub fn block(self) -> Option> { super::child_opt(self) } } // BreakExpr #[derive(Debug, Clone, Copy,)] pub struct BreakExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type BreakExpr<'a> = BreakExprNode>; impl, R2: TreeRoot> PartialEq> for BreakExprNode { fn eq(&self, other: &BreakExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for BreakExprNode {} impl> Hash for BreakExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for BreakExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { BREAK_EXPR => Some(BreakExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> BreakExprNode { pub fn borrowed(&self) -> BreakExpr { BreakExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> BreakExprNode { BreakExprNode { syntax: self.syntax.owned() } } } impl<'a> BreakExpr<'a> {} // CallExpr #[derive(Debug, Clone, Copy,)] pub struct CallExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type CallExpr<'a> = CallExprNode>; impl, R2: TreeRoot> PartialEq> for CallExprNode { fn eq(&self, other: &CallExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for CallExprNode {} impl> Hash for CallExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for CallExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { CALL_EXPR => Some(CallExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> CallExprNode { pub fn borrowed(&self) -> CallExpr { CallExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> CallExprNode { CallExprNode { syntax: self.syntax.owned() } } } impl<'a> ast::ArgListOwner<'a> for CallExpr<'a> {} impl<'a> CallExpr<'a> { pub fn expr(self) -> Option> { super::child_opt(self) } } // CastExpr #[derive(Debug, Clone, Copy,)] pub struct CastExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type CastExpr<'a> = CastExprNode>; impl, R2: TreeRoot> PartialEq> for CastExprNode { fn eq(&self, other: &CastExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for CastExprNode {} impl> Hash for CastExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for CastExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { CAST_EXPR => Some(CastExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> CastExprNode { pub fn borrowed(&self) -> CastExpr { CastExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> CastExprNode { CastExprNode { syntax: self.syntax.owned() } } } impl<'a> CastExpr<'a> {} // Char #[derive(Debug, Clone, Copy,)] pub struct CharNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type Char<'a> = CharNode>; impl, R2: TreeRoot> PartialEq> for CharNode { fn eq(&self, other: &CharNode) -> bool { self.syntax == other.syntax } } impl> Eq for CharNode {} impl> Hash for CharNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for Char<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { CHAR => Some(Char { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> CharNode { pub fn borrowed(&self) -> Char { CharNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> CharNode { CharNode { syntax: self.syntax.owned() } } } impl<'a> Char<'a> {} // Comment #[derive(Debug, Clone, Copy,)] pub struct CommentNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type Comment<'a> = CommentNode>; impl, R2: TreeRoot> PartialEq> for CommentNode { fn eq(&self, other: &CommentNode) -> bool { self.syntax == other.syntax } } impl> Eq for CommentNode {} impl> Hash for CommentNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for Comment<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { COMMENT => Some(Comment { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> CommentNode { pub fn borrowed(&self) -> Comment { CommentNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> CommentNode { CommentNode { syntax: self.syntax.owned() } } } impl<'a> Comment<'a> {} // Condition #[derive(Debug, Clone, Copy,)] pub struct ConditionNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type Condition<'a> = ConditionNode>; impl, R2: TreeRoot> PartialEq> for ConditionNode { fn eq(&self, other: &ConditionNode) -> bool { self.syntax == other.syntax } } impl> Eq for ConditionNode {} impl> Hash for ConditionNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for Condition<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { CONDITION => Some(Condition { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ConditionNode { pub fn borrowed(&self) -> Condition { ConditionNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ConditionNode { ConditionNode { syntax: self.syntax.owned() } } } impl<'a> Condition<'a> { pub fn pat(self) -> Option> { super::child_opt(self) } pub fn expr(self) -> Option> { super::child_opt(self) } } // ConstDef #[derive(Debug, Clone, Copy,)] pub struct ConstDefNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ConstDef<'a> = ConstDefNode>; impl, R2: TreeRoot> PartialEq> for ConstDefNode { fn eq(&self, other: &ConstDefNode) -> bool { self.syntax == other.syntax } } impl> Eq for ConstDefNode {} impl> Hash for ConstDefNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ConstDef<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { CONST_DEF => Some(ConstDef { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ConstDefNode { pub fn borrowed(&self) -> ConstDef { ConstDefNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ConstDefNode { ConstDefNode { syntax: self.syntax.owned() } } } impl<'a> ast::NameOwner<'a> for ConstDef<'a> {} impl<'a> ast::TypeParamsOwner<'a> for ConstDef<'a> {} impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {} impl<'a> ConstDef<'a> {} // ContinueExpr #[derive(Debug, Clone, Copy,)] pub struct ContinueExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ContinueExpr<'a> = ContinueExprNode>; impl, R2: TreeRoot> PartialEq> for ContinueExprNode { fn eq(&self, other: &ContinueExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for ContinueExprNode {} impl> Hash for ContinueExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ContinueExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { CONTINUE_EXPR => Some(ContinueExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ContinueExprNode { pub fn borrowed(&self) -> ContinueExpr { ContinueExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ContinueExprNode { ContinueExprNode { syntax: self.syntax.owned() } } } impl<'a> ContinueExpr<'a> {} // DynTraitType #[derive(Debug, Clone, Copy,)] pub struct DynTraitTypeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type DynTraitType<'a> = DynTraitTypeNode>; impl, R2: TreeRoot> PartialEq> for DynTraitTypeNode { fn eq(&self, other: &DynTraitTypeNode) -> bool { self.syntax == other.syntax } } impl> Eq for DynTraitTypeNode {} impl> Hash for DynTraitTypeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for DynTraitType<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { DYN_TRAIT_TYPE => Some(DynTraitType { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> DynTraitTypeNode { pub fn borrowed(&self) -> DynTraitType { DynTraitTypeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> DynTraitTypeNode { DynTraitTypeNode { syntax: self.syntax.owned() } } } impl<'a> DynTraitType<'a> {} // EnumDef #[derive(Debug, Clone, Copy,)] pub struct EnumDefNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type EnumDef<'a> = EnumDefNode>; impl, R2: TreeRoot> PartialEq> for EnumDefNode { fn eq(&self, other: &EnumDefNode) -> bool { self.syntax == other.syntax } } impl> Eq for EnumDefNode {} impl> Hash for EnumDefNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for EnumDef<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { ENUM_DEF => Some(EnumDef { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> EnumDefNode { pub fn borrowed(&self) -> EnumDef { EnumDefNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> EnumDefNode { EnumDefNode { syntax: self.syntax.owned() } } } impl<'a> ast::NameOwner<'a> for EnumDef<'a> {} impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {} impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {} impl<'a> EnumDef<'a> {} // Expr #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Expr<'a> { TupleExpr(TupleExpr<'a>), ArrayExpr(ArrayExpr<'a>), ParenExpr(ParenExpr<'a>), PathExpr(PathExpr<'a>), LambdaExpr(LambdaExpr<'a>), IfExpr(IfExpr<'a>), LoopExpr(LoopExpr<'a>), ForExpr(ForExpr<'a>), WhileExpr(WhileExpr<'a>), ContinueExpr(ContinueExpr<'a>), BreakExpr(BreakExpr<'a>), Label(Label<'a>), BlockExpr(BlockExpr<'a>), ReturnExpr(ReturnExpr<'a>), MatchExpr(MatchExpr<'a>), MatchArmList(MatchArmList<'a>), MatchArm(MatchArm<'a>), MatchGuard(MatchGuard<'a>), StructLit(StructLit<'a>), NamedFieldList(NamedFieldList<'a>), NamedField(NamedField<'a>), CallExpr(CallExpr<'a>), IndexExpr(IndexExpr<'a>), MethodCallExpr(MethodCallExpr<'a>), FieldExpr(FieldExpr<'a>), TryExpr(TryExpr<'a>), CastExpr(CastExpr<'a>), RefExpr(RefExpr<'a>), PrefixExpr(PrefixExpr<'a>), RangeExpr(RangeExpr<'a>), BinExpr(BinExpr<'a>), Literal(Literal<'a>), } impl<'a> AstNode<'a> for Expr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { TUPLE_EXPR => Some(Expr::TupleExpr(TupleExpr { syntax })), ARRAY_EXPR => Some(Expr::ArrayExpr(ArrayExpr { syntax })), PAREN_EXPR => Some(Expr::ParenExpr(ParenExpr { syntax })), PATH_EXPR => Some(Expr::PathExpr(PathExpr { syntax })), LAMBDA_EXPR => Some(Expr::LambdaExpr(LambdaExpr { syntax })), IF_EXPR => Some(Expr::IfExpr(IfExpr { syntax })), LOOP_EXPR => Some(Expr::LoopExpr(LoopExpr { syntax })), FOR_EXPR => Some(Expr::ForExpr(ForExpr { syntax })), WHILE_EXPR => Some(Expr::WhileExpr(WhileExpr { syntax })), CONTINUE_EXPR => Some(Expr::ContinueExpr(ContinueExpr { syntax })), BREAK_EXPR => Some(Expr::BreakExpr(BreakExpr { syntax })), LABEL => Some(Expr::Label(Label { syntax })), BLOCK_EXPR => Some(Expr::BlockExpr(BlockExpr { syntax })), RETURN_EXPR => Some(Expr::ReturnExpr(ReturnExpr { syntax })), MATCH_EXPR => Some(Expr::MatchExpr(MatchExpr { syntax })), MATCH_ARM_LIST => Some(Expr::MatchArmList(MatchArmList { syntax })), MATCH_ARM => Some(Expr::MatchArm(MatchArm { syntax })), MATCH_GUARD => Some(Expr::MatchGuard(MatchGuard { syntax })), STRUCT_LIT => Some(Expr::StructLit(StructLit { syntax })), NAMED_FIELD_LIST => Some(Expr::NamedFieldList(NamedFieldList { syntax })), NAMED_FIELD => Some(Expr::NamedField(NamedField { syntax })), CALL_EXPR => Some(Expr::CallExpr(CallExpr { syntax })), INDEX_EXPR => Some(Expr::IndexExpr(IndexExpr { syntax })), METHOD_CALL_EXPR => Some(Expr::MethodCallExpr(MethodCallExpr { syntax })), FIELD_EXPR => Some(Expr::FieldExpr(FieldExpr { syntax })), TRY_EXPR => Some(Expr::TryExpr(TryExpr { syntax })), CAST_EXPR => Some(Expr::CastExpr(CastExpr { syntax })), REF_EXPR => Some(Expr::RefExpr(RefExpr { syntax })), PREFIX_EXPR => Some(Expr::PrefixExpr(PrefixExpr { syntax })), RANGE_EXPR => Some(Expr::RangeExpr(RangeExpr { syntax })), BIN_EXPR => Some(Expr::BinExpr(BinExpr { syntax })), LITERAL => Some(Expr::Literal(Literal { syntax })), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { match self { Expr::TupleExpr(inner) => inner.syntax(), Expr::ArrayExpr(inner) => inner.syntax(), Expr::ParenExpr(inner) => inner.syntax(), Expr::PathExpr(inner) => inner.syntax(), Expr::LambdaExpr(inner) => inner.syntax(), Expr::IfExpr(inner) => inner.syntax(), Expr::LoopExpr(inner) => inner.syntax(), Expr::ForExpr(inner) => inner.syntax(), Expr::WhileExpr(inner) => inner.syntax(), Expr::ContinueExpr(inner) => inner.syntax(), Expr::BreakExpr(inner) => inner.syntax(), Expr::Label(inner) => inner.syntax(), Expr::BlockExpr(inner) => inner.syntax(), Expr::ReturnExpr(inner) => inner.syntax(), Expr::MatchExpr(inner) => inner.syntax(), Expr::MatchArmList(inner) => inner.syntax(), Expr::MatchArm(inner) => inner.syntax(), Expr::MatchGuard(inner) => inner.syntax(), Expr::StructLit(inner) => inner.syntax(), Expr::NamedFieldList(inner) => inner.syntax(), Expr::NamedField(inner) => inner.syntax(), Expr::CallExpr(inner) => inner.syntax(), Expr::IndexExpr(inner) => inner.syntax(), Expr::MethodCallExpr(inner) => inner.syntax(), Expr::FieldExpr(inner) => inner.syntax(), Expr::TryExpr(inner) => inner.syntax(), Expr::CastExpr(inner) => inner.syntax(), Expr::RefExpr(inner) => inner.syntax(), Expr::PrefixExpr(inner) => inner.syntax(), Expr::RangeExpr(inner) => inner.syntax(), Expr::BinExpr(inner) => inner.syntax(), Expr::Literal(inner) => inner.syntax(), } } } impl<'a> Expr<'a> {} // ExprStmt #[derive(Debug, Clone, Copy,)] pub struct ExprStmtNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ExprStmt<'a> = ExprStmtNode>; impl, R2: TreeRoot> PartialEq> for ExprStmtNode { fn eq(&self, other: &ExprStmtNode) -> bool { self.syntax == other.syntax } } impl> Eq for ExprStmtNode {} impl> Hash for ExprStmtNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ExprStmt<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { EXPR_STMT => Some(ExprStmt { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ExprStmtNode { pub fn borrowed(&self) -> ExprStmt { ExprStmtNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ExprStmtNode { ExprStmtNode { syntax: self.syntax.owned() } } } impl<'a> ExprStmt<'a> { pub fn expr(self) -> Option> { super::child_opt(self) } } // ExternCrateItem #[derive(Debug, Clone, Copy,)] pub struct ExternCrateItemNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ExternCrateItem<'a> = ExternCrateItemNode>; impl, R2: TreeRoot> PartialEq> for ExternCrateItemNode { fn eq(&self, other: &ExternCrateItemNode) -> bool { self.syntax == other.syntax } } impl> Eq for ExternCrateItemNode {} impl> Hash for ExternCrateItemNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ExternCrateItem<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { EXTERN_CRATE_ITEM => Some(ExternCrateItem { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ExternCrateItemNode { pub fn borrowed(&self) -> ExternCrateItem { ExternCrateItemNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ExternCrateItemNode { ExternCrateItemNode { syntax: self.syntax.owned() } } } impl<'a> ExternCrateItem<'a> {} // FieldExpr #[derive(Debug, Clone, Copy,)] pub struct FieldExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type FieldExpr<'a> = FieldExprNode>; impl, R2: TreeRoot> PartialEq> for FieldExprNode { fn eq(&self, other: &FieldExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for FieldExprNode {} impl> Hash for FieldExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for FieldExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { FIELD_EXPR => Some(FieldExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> FieldExprNode { pub fn borrowed(&self) -> FieldExpr { FieldExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> FieldExprNode { FieldExprNode { syntax: self.syntax.owned() } } } impl<'a> FieldExpr<'a> {} // FieldPatList #[derive(Debug, Clone, Copy,)] pub struct FieldPatListNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type FieldPatList<'a> = FieldPatListNode>; impl, R2: TreeRoot> PartialEq> for FieldPatListNode { fn eq(&self, other: &FieldPatListNode) -> bool { self.syntax == other.syntax } } impl> Eq for FieldPatListNode {} impl> Hash for FieldPatListNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for FieldPatList<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { FIELD_PAT_LIST => Some(FieldPatList { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> FieldPatListNode { pub fn borrowed(&self) -> FieldPatList { FieldPatListNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> FieldPatListNode { FieldPatListNode { syntax: self.syntax.owned() } } } impl<'a> FieldPatList<'a> {} // FnDef #[derive(Debug, Clone, Copy,)] pub struct FnDefNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type FnDef<'a> = FnDefNode>; impl, R2: TreeRoot> PartialEq> for FnDefNode { fn eq(&self, other: &FnDefNode) -> bool { self.syntax == other.syntax } } impl> Eq for FnDefNode {} impl> Hash for FnDefNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for FnDef<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { FN_DEF => Some(FnDef { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> FnDefNode { pub fn borrowed(&self) -> FnDef { FnDefNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> FnDefNode { FnDefNode { syntax: self.syntax.owned() } } } impl<'a> ast::NameOwner<'a> for FnDef<'a> {} impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {} impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {} impl<'a> ast::DocCommentsOwner<'a> for FnDef<'a> {} impl<'a> FnDef<'a> { pub fn param_list(self) -> Option> { super::child_opt(self) } pub fn body(self) -> Option> { super::child_opt(self) } pub fn ret_type(self) -> Option> { super::child_opt(self) } } // FnPointerType #[derive(Debug, Clone, Copy,)] pub struct FnPointerTypeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type FnPointerType<'a> = FnPointerTypeNode>; impl, R2: TreeRoot> PartialEq> for FnPointerTypeNode { fn eq(&self, other: &FnPointerTypeNode) -> bool { self.syntax == other.syntax } } impl> Eq for FnPointerTypeNode {} impl> Hash for FnPointerTypeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for FnPointerType<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { FN_POINTER_TYPE => Some(FnPointerType { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> FnPointerTypeNode { pub fn borrowed(&self) -> FnPointerType { FnPointerTypeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> FnPointerTypeNode { FnPointerTypeNode { syntax: self.syntax.owned() } } } impl<'a> FnPointerType<'a> {} // ForExpr #[derive(Debug, Clone, Copy,)] pub struct ForExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ForExpr<'a> = ForExprNode>; impl, R2: TreeRoot> PartialEq> for ForExprNode { fn eq(&self, other: &ForExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for ForExprNode {} impl> Hash for ForExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ForExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { FOR_EXPR => Some(ForExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ForExprNode { pub fn borrowed(&self) -> ForExpr { ForExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ForExprNode { ForExprNode { syntax: self.syntax.owned() } } } impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {} impl<'a> ForExpr<'a> { pub fn pat(self) -> Option> { super::child_opt(self) } pub fn iterable(self) -> Option> { super::child_opt(self) } } // ForType #[derive(Debug, Clone, Copy,)] pub struct ForTypeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ForType<'a> = ForTypeNode>; impl, R2: TreeRoot> PartialEq> for ForTypeNode { fn eq(&self, other: &ForTypeNode) -> bool { self.syntax == other.syntax } } impl> Eq for ForTypeNode {} impl> Hash for ForTypeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ForType<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { FOR_TYPE => Some(ForType { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ForTypeNode { pub fn borrowed(&self) -> ForType { ForTypeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ForTypeNode { ForTypeNode { syntax: self.syntax.owned() } } } impl<'a> ForType<'a> {} // IfExpr #[derive(Debug, Clone, Copy,)] pub struct IfExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type IfExpr<'a> = IfExprNode>; impl, R2: TreeRoot> PartialEq> for IfExprNode { fn eq(&self, other: &IfExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for IfExprNode {} impl> Hash for IfExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for IfExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { IF_EXPR => Some(IfExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> IfExprNode { pub fn borrowed(&self) -> IfExpr { IfExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> IfExprNode { IfExprNode { syntax: self.syntax.owned() } } } impl<'a> IfExpr<'a> { pub fn condition(self) -> Option> { super::child_opt(self) } } // ImplItem #[derive(Debug, Clone, Copy,)] pub struct ImplItemNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ImplItem<'a> = ImplItemNode>; impl, R2: TreeRoot> PartialEq> for ImplItemNode { fn eq(&self, other: &ImplItemNode) -> bool { self.syntax == other.syntax } } impl> Eq for ImplItemNode {} impl> Hash for ImplItemNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ImplItem<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { IMPL_ITEM => Some(ImplItem { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ImplItemNode { pub fn borrowed(&self) -> ImplItem { ImplItemNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ImplItemNode { ImplItemNode { syntax: self.syntax.owned() } } } impl<'a> ImplItem<'a> {} // ImplTraitType #[derive(Debug, Clone, Copy,)] pub struct ImplTraitTypeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ImplTraitType<'a> = ImplTraitTypeNode>; impl, R2: TreeRoot> PartialEq> for ImplTraitTypeNode { fn eq(&self, other: &ImplTraitTypeNode) -> bool { self.syntax == other.syntax } } impl> Eq for ImplTraitTypeNode {} impl> Hash for ImplTraitTypeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ImplTraitType<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { IMPL_TRAIT_TYPE => Some(ImplTraitType { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ImplTraitTypeNode { pub fn borrowed(&self) -> ImplTraitType { ImplTraitTypeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ImplTraitTypeNode { ImplTraitTypeNode { syntax: self.syntax.owned() } } } impl<'a> ImplTraitType<'a> {} // IndexExpr #[derive(Debug, Clone, Copy,)] pub struct IndexExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type IndexExpr<'a> = IndexExprNode>; impl, R2: TreeRoot> PartialEq> for IndexExprNode { fn eq(&self, other: &IndexExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for IndexExprNode {} impl> Hash for IndexExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for IndexExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { INDEX_EXPR => Some(IndexExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> IndexExprNode { pub fn borrowed(&self) -> IndexExpr { IndexExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> IndexExprNode { IndexExprNode { syntax: self.syntax.owned() } } } impl<'a> IndexExpr<'a> {} // ItemList #[derive(Debug, Clone, Copy,)] pub struct ItemListNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ItemList<'a> = ItemListNode>; impl, R2: TreeRoot> PartialEq> for ItemListNode { fn eq(&self, other: &ItemListNode) -> bool { self.syntax == other.syntax } } impl> Eq for ItemListNode {} impl> Hash for ItemListNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ItemList<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { ITEM_LIST => Some(ItemList { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ItemListNode { pub fn borrowed(&self) -> ItemList { ItemListNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ItemListNode { ItemListNode { syntax: self.syntax.owned() } } } impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {} impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {} impl<'a> ItemList<'a> {} // Label #[derive(Debug, Clone, Copy,)] pub struct LabelNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type Label<'a> = LabelNode>; impl, R2: TreeRoot> PartialEq> for LabelNode { fn eq(&self, other: &LabelNode) -> bool { self.syntax == other.syntax } } impl> Eq for LabelNode {} impl> Hash for LabelNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for Label<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { LABEL => Some(Label { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> LabelNode { pub fn borrowed(&self) -> Label { LabelNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> LabelNode { LabelNode { syntax: self.syntax.owned() } } } impl<'a> Label<'a> {} // LambdaExpr #[derive(Debug, Clone, Copy,)] pub struct LambdaExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type LambdaExpr<'a> = LambdaExprNode>; impl, R2: TreeRoot> PartialEq> for LambdaExprNode { fn eq(&self, other: &LambdaExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for LambdaExprNode {} impl> Hash for LambdaExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for LambdaExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { LAMBDA_EXPR => Some(LambdaExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> LambdaExprNode { pub fn borrowed(&self) -> LambdaExpr { LambdaExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> LambdaExprNode { LambdaExprNode { syntax: self.syntax.owned() } } } impl<'a> LambdaExpr<'a> { pub fn param_list(self) -> Option> { super::child_opt(self) } pub fn body(self) -> Option> { super::child_opt(self) } } // LetStmt #[derive(Debug, Clone, Copy,)] pub struct LetStmtNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type LetStmt<'a> = LetStmtNode>; impl, R2: TreeRoot> PartialEq> for LetStmtNode { fn eq(&self, other: &LetStmtNode) -> bool { self.syntax == other.syntax } } impl> Eq for LetStmtNode {} impl> Hash for LetStmtNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for LetStmt<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { LET_STMT => Some(LetStmt { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> LetStmtNode { pub fn borrowed(&self) -> LetStmt { LetStmtNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> LetStmtNode { LetStmtNode { syntax: self.syntax.owned() } } } impl<'a> LetStmt<'a> { pub fn pat(self) -> Option> { super::child_opt(self) } pub fn initializer(self) -> Option> { super::child_opt(self) } } // Lifetime #[derive(Debug, Clone, Copy,)] pub struct LifetimeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type Lifetime<'a> = LifetimeNode>; impl, R2: TreeRoot> PartialEq> for LifetimeNode { fn eq(&self, other: &LifetimeNode) -> bool { self.syntax == other.syntax } } impl> Eq for LifetimeNode {} impl> Hash for LifetimeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for Lifetime<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { LIFETIME => Some(Lifetime { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> LifetimeNode { pub fn borrowed(&self) -> Lifetime { LifetimeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> LifetimeNode { LifetimeNode { syntax: self.syntax.owned() } } } impl<'a> Lifetime<'a> {} // LifetimeParam #[derive(Debug, Clone, Copy,)] pub struct LifetimeParamNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type LifetimeParam<'a> = LifetimeParamNode>; impl, R2: TreeRoot> PartialEq> for LifetimeParamNode { fn eq(&self, other: &LifetimeParamNode) -> bool { self.syntax == other.syntax } } impl> Eq for LifetimeParamNode {} impl> Hash for LifetimeParamNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for LifetimeParam<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { LIFETIME_PARAM => Some(LifetimeParam { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> LifetimeParamNode { pub fn borrowed(&self) -> LifetimeParam { LifetimeParamNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> LifetimeParamNode { LifetimeParamNode { syntax: self.syntax.owned() } } } impl<'a> LifetimeParam<'a> { pub fn lifetime(self) -> Option> { super::child_opt(self) } } // Literal #[derive(Debug, Clone, Copy,)] pub struct LiteralNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type Literal<'a> = LiteralNode>; impl, R2: TreeRoot> PartialEq> for LiteralNode { fn eq(&self, other: &LiteralNode) -> bool { self.syntax == other.syntax } } impl> Eq for LiteralNode {} impl> Hash for LiteralNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for Literal<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { LITERAL => Some(Literal { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> LiteralNode { pub fn borrowed(&self) -> Literal { LiteralNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> LiteralNode { LiteralNode { syntax: self.syntax.owned() } } } impl<'a> Literal<'a> {} // LoopExpr #[derive(Debug, Clone, Copy,)] pub struct LoopExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type LoopExpr<'a> = LoopExprNode>; impl, R2: TreeRoot> PartialEq> for LoopExprNode { fn eq(&self, other: &LoopExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for LoopExprNode {} impl> Hash for LoopExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for LoopExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { LOOP_EXPR => Some(LoopExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> LoopExprNode { pub fn borrowed(&self) -> LoopExpr { LoopExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> LoopExprNode { LoopExprNode { syntax: self.syntax.owned() } } } impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {} impl<'a> LoopExpr<'a> {} // MatchArm #[derive(Debug, Clone, Copy,)] pub struct MatchArmNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type MatchArm<'a> = MatchArmNode>; impl, R2: TreeRoot> PartialEq> for MatchArmNode { fn eq(&self, other: &MatchArmNode) -> bool { self.syntax == other.syntax } } impl> Eq for MatchArmNode {} impl> Hash for MatchArmNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for MatchArm<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { MATCH_ARM => Some(MatchArm { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> MatchArmNode { pub fn borrowed(&self) -> MatchArm { MatchArmNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> MatchArmNode { MatchArmNode { syntax: self.syntax.owned() } } } impl<'a> MatchArm<'a> { pub fn pats(self) -> impl Iterator> + 'a { super::children(self) } pub fn guard(self) -> Option> { super::child_opt(self) } pub fn expr(self) -> Option> { super::child_opt(self) } } // MatchArmList #[derive(Debug, Clone, Copy,)] pub struct MatchArmListNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type MatchArmList<'a> = MatchArmListNode>; impl, R2: TreeRoot> PartialEq> for MatchArmListNode { fn eq(&self, other: &MatchArmListNode) -> bool { self.syntax == other.syntax } } impl> Eq for MatchArmListNode {} impl> Hash for MatchArmListNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for MatchArmList<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { MATCH_ARM_LIST => Some(MatchArmList { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> MatchArmListNode { pub fn borrowed(&self) -> MatchArmList { MatchArmListNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> MatchArmListNode { MatchArmListNode { syntax: self.syntax.owned() } } } impl<'a> MatchArmList<'a> { pub fn arms(self) -> impl Iterator> + 'a { super::children(self) } } // MatchExpr #[derive(Debug, Clone, Copy,)] pub struct MatchExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type MatchExpr<'a> = MatchExprNode>; impl, R2: TreeRoot> PartialEq> for MatchExprNode { fn eq(&self, other: &MatchExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for MatchExprNode {} impl> Hash for MatchExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for MatchExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { MATCH_EXPR => Some(MatchExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> MatchExprNode { pub fn borrowed(&self) -> MatchExpr { MatchExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> MatchExprNode { MatchExprNode { syntax: self.syntax.owned() } } } impl<'a> MatchExpr<'a> { pub fn expr(self) -> Option> { super::child_opt(self) } pub fn match_arm_list(self) -> Option> { super::child_opt(self) } } // MatchGuard #[derive(Debug, Clone, Copy,)] pub struct MatchGuardNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type MatchGuard<'a> = MatchGuardNode>; impl, R2: TreeRoot> PartialEq> for MatchGuardNode { fn eq(&self, other: &MatchGuardNode) -> bool { self.syntax == other.syntax } } impl> Eq for MatchGuardNode {} impl> Hash for MatchGuardNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for MatchGuard<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { MATCH_GUARD => Some(MatchGuard { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> MatchGuardNode { pub fn borrowed(&self) -> MatchGuard { MatchGuardNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> MatchGuardNode { MatchGuardNode { syntax: self.syntax.owned() } } } impl<'a> MatchGuard<'a> {} // MethodCallExpr #[derive(Debug, Clone, Copy,)] pub struct MethodCallExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type MethodCallExpr<'a> = MethodCallExprNode>; impl, R2: TreeRoot> PartialEq> for MethodCallExprNode { fn eq(&self, other: &MethodCallExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for MethodCallExprNode {} impl> Hash for MethodCallExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for MethodCallExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { METHOD_CALL_EXPR => Some(MethodCallExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> MethodCallExprNode { pub fn borrowed(&self) -> MethodCallExpr { MethodCallExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> MethodCallExprNode { MethodCallExprNode { syntax: self.syntax.owned() } } } impl<'a> ast::ArgListOwner<'a> for MethodCallExpr<'a> {} impl<'a> MethodCallExpr<'a> { pub fn expr(self) -> Option> { super::child_opt(self) } } // Module #[derive(Debug, Clone, Copy,)] pub struct ModuleNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type Module<'a> = ModuleNode>; impl, R2: TreeRoot> PartialEq> for ModuleNode { fn eq(&self, other: &ModuleNode) -> bool { self.syntax == other.syntax } } impl> Eq for ModuleNode {} impl> Hash for ModuleNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for Module<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { MODULE => Some(Module { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ModuleNode { pub fn borrowed(&self) -> Module { ModuleNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ModuleNode { ModuleNode { syntax: self.syntax.owned() } } } impl<'a> ast::NameOwner<'a> for Module<'a> {} impl<'a> ast::AttrsOwner<'a> for Module<'a> {} impl<'a> Module<'a> { pub fn item_list(self) -> Option> { super::child_opt(self) } } // ModuleItem #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ModuleItem<'a> { StructDef(StructDef<'a>), EnumDef(EnumDef<'a>), FnDef(FnDef<'a>), TraitDef(TraitDef<'a>), TypeDef(TypeDef<'a>), ImplItem(ImplItem<'a>), UseItem(UseItem<'a>), ExternCrateItem(ExternCrateItem<'a>), ConstDef(ConstDef<'a>), StaticDef(StaticDef<'a>), Module(Module<'a>), } impl<'a> AstNode<'a> for ModuleItem<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { STRUCT_DEF => Some(ModuleItem::StructDef(StructDef { syntax })), ENUM_DEF => Some(ModuleItem::EnumDef(EnumDef { syntax })), FN_DEF => Some(ModuleItem::FnDef(FnDef { syntax })), TRAIT_DEF => Some(ModuleItem::TraitDef(TraitDef { syntax })), TYPE_DEF => Some(ModuleItem::TypeDef(TypeDef { syntax })), IMPL_ITEM => Some(ModuleItem::ImplItem(ImplItem { syntax })), USE_ITEM => Some(ModuleItem::UseItem(UseItem { syntax })), EXTERN_CRATE_ITEM => Some(ModuleItem::ExternCrateItem(ExternCrateItem { syntax })), CONST_DEF => Some(ModuleItem::ConstDef(ConstDef { syntax })), STATIC_DEF => Some(ModuleItem::StaticDef(StaticDef { syntax })), MODULE => Some(ModuleItem::Module(Module { syntax })), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { match self { ModuleItem::StructDef(inner) => inner.syntax(), ModuleItem::EnumDef(inner) => inner.syntax(), ModuleItem::FnDef(inner) => inner.syntax(), ModuleItem::TraitDef(inner) => inner.syntax(), ModuleItem::TypeDef(inner) => inner.syntax(), ModuleItem::ImplItem(inner) => inner.syntax(), ModuleItem::UseItem(inner) => inner.syntax(), ModuleItem::ExternCrateItem(inner) => inner.syntax(), ModuleItem::ConstDef(inner) => inner.syntax(), ModuleItem::StaticDef(inner) => inner.syntax(), ModuleItem::Module(inner) => inner.syntax(), } } } impl<'a> ModuleItem<'a> {} // Name #[derive(Debug, Clone, Copy,)] pub struct NameNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type Name<'a> = NameNode>; impl, R2: TreeRoot> PartialEq> for NameNode { fn eq(&self, other: &NameNode) -> bool { self.syntax == other.syntax } } impl> Eq for NameNode {} impl> Hash for NameNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for Name<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { NAME => Some(Name { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> NameNode { pub fn borrowed(&self) -> Name { NameNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> NameNode { NameNode { syntax: self.syntax.owned() } } } impl<'a> Name<'a> {} // NameRef #[derive(Debug, Clone, Copy,)] pub struct NameRefNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type NameRef<'a> = NameRefNode>; impl, R2: TreeRoot> PartialEq> for NameRefNode { fn eq(&self, other: &NameRefNode) -> bool { self.syntax == other.syntax } } impl> Eq for NameRefNode {} impl> Hash for NameRefNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for NameRef<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { NAME_REF => Some(NameRef { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> NameRefNode { pub fn borrowed(&self) -> NameRef { NameRefNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> NameRefNode { NameRefNode { syntax: self.syntax.owned() } } } impl<'a> NameRef<'a> {} // NamedField #[derive(Debug, Clone, Copy,)] pub struct NamedFieldNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type NamedField<'a> = NamedFieldNode>; impl, R2: TreeRoot> PartialEq> for NamedFieldNode { fn eq(&self, other: &NamedFieldNode) -> bool { self.syntax == other.syntax } } impl> Eq for NamedFieldNode {} impl> Hash for NamedFieldNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for NamedField<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { NAMED_FIELD => Some(NamedField { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> NamedFieldNode { pub fn borrowed(&self) -> NamedField { NamedFieldNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> NamedFieldNode { NamedFieldNode { syntax: self.syntax.owned() } } } impl<'a> NamedField<'a> {} // NamedFieldDef #[derive(Debug, Clone, Copy,)] pub struct NamedFieldDefNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type NamedFieldDef<'a> = NamedFieldDefNode>; impl, R2: TreeRoot> PartialEq> for NamedFieldDefNode { fn eq(&self, other: &NamedFieldDefNode) -> bool { self.syntax == other.syntax } } impl> Eq for NamedFieldDefNode {} impl> Hash for NamedFieldDefNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for NamedFieldDef<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { NAMED_FIELD_DEF => Some(NamedFieldDef { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> NamedFieldDefNode { pub fn borrowed(&self) -> NamedFieldDef { NamedFieldDefNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> NamedFieldDefNode { NamedFieldDefNode { syntax: self.syntax.owned() } } } impl<'a> ast::NameOwner<'a> for NamedFieldDef<'a> {} impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {} impl<'a> NamedFieldDef<'a> {} // NamedFieldList #[derive(Debug, Clone, Copy,)] pub struct NamedFieldListNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type NamedFieldList<'a> = NamedFieldListNode>; impl, R2: TreeRoot> PartialEq> for NamedFieldListNode { fn eq(&self, other: &NamedFieldListNode) -> bool { self.syntax == other.syntax } } impl> Eq for NamedFieldListNode {} impl> Hash for NamedFieldListNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for NamedFieldList<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { NAMED_FIELD_LIST => Some(NamedFieldList { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> NamedFieldListNode { pub fn borrowed(&self) -> NamedFieldList { NamedFieldListNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> NamedFieldListNode { NamedFieldListNode { syntax: self.syntax.owned() } } } impl<'a> NamedFieldList<'a> {} // NeverType #[derive(Debug, Clone, Copy,)] pub struct NeverTypeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type NeverType<'a> = NeverTypeNode>; impl, R2: TreeRoot> PartialEq> for NeverTypeNode { fn eq(&self, other: &NeverTypeNode) -> bool { self.syntax == other.syntax } } impl> Eq for NeverTypeNode {} impl> Hash for NeverTypeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for NeverType<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { NEVER_TYPE => Some(NeverType { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> NeverTypeNode { pub fn borrowed(&self) -> NeverType { NeverTypeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> NeverTypeNode { NeverTypeNode { syntax: self.syntax.owned() } } } impl<'a> NeverType<'a> {} // NominalDef #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum NominalDef<'a> { StructDef(StructDef<'a>), EnumDef(EnumDef<'a>), } impl<'a> AstNode<'a> for NominalDef<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { STRUCT_DEF => Some(NominalDef::StructDef(StructDef { syntax })), ENUM_DEF => Some(NominalDef::EnumDef(EnumDef { syntax })), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { match self { NominalDef::StructDef(inner) => inner.syntax(), NominalDef::EnumDef(inner) => inner.syntax(), } } } impl<'a> ast::NameOwner<'a> for NominalDef<'a> {} impl<'a> ast::TypeParamsOwner<'a> for NominalDef<'a> {} impl<'a> ast::AttrsOwner<'a> for NominalDef<'a> {} impl<'a> NominalDef<'a> {} // Param #[derive(Debug, Clone, Copy,)] pub struct ParamNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type Param<'a> = ParamNode>; impl, R2: TreeRoot> PartialEq> for ParamNode { fn eq(&self, other: &ParamNode) -> bool { self.syntax == other.syntax } } impl> Eq for ParamNode {} impl> Hash for ParamNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for Param<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { PARAM => Some(Param { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ParamNode { pub fn borrowed(&self) -> Param { ParamNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ParamNode { ParamNode { syntax: self.syntax.owned() } } } impl<'a> Param<'a> { pub fn pat(self) -> Option> { super::child_opt(self) } } // ParamList #[derive(Debug, Clone, Copy,)] pub struct ParamListNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ParamList<'a> = ParamListNode>; impl, R2: TreeRoot> PartialEq> for ParamListNode { fn eq(&self, other: &ParamListNode) -> bool { self.syntax == other.syntax } } impl> Eq for ParamListNode {} impl> Hash for ParamListNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ParamList<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { PARAM_LIST => Some(ParamList { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ParamListNode { pub fn borrowed(&self) -> ParamList { ParamListNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ParamListNode { ParamListNode { syntax: self.syntax.owned() } } } impl<'a> ParamList<'a> { pub fn params(self) -> impl Iterator> + 'a { super::children(self) } pub fn self_param(self) -> Option> { super::child_opt(self) } } // ParenExpr #[derive(Debug, Clone, Copy,)] pub struct ParenExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ParenExpr<'a> = ParenExprNode>; impl, R2: TreeRoot> PartialEq> for ParenExprNode { fn eq(&self, other: &ParenExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for ParenExprNode {} impl> Hash for ParenExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ParenExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { PAREN_EXPR => Some(ParenExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ParenExprNode { pub fn borrowed(&self) -> ParenExpr { ParenExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ParenExprNode { ParenExprNode { syntax: self.syntax.owned() } } } impl<'a> ParenExpr<'a> {} // ParenType #[derive(Debug, Clone, Copy,)] pub struct ParenTypeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ParenType<'a> = ParenTypeNode>; impl, R2: TreeRoot> PartialEq> for ParenTypeNode { fn eq(&self, other: &ParenTypeNode) -> bool { self.syntax == other.syntax } } impl> Eq for ParenTypeNode {} impl> Hash for ParenTypeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ParenType<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { PAREN_TYPE => Some(ParenType { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ParenTypeNode { pub fn borrowed(&self) -> ParenType { ParenTypeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ParenTypeNode { ParenTypeNode { syntax: self.syntax.owned() } } } impl<'a> ParenType<'a> {} // Pat #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Pat<'a> { RefPat(RefPat<'a>), BindPat(BindPat<'a>), PlaceholderPat(PlaceholderPat<'a>), PathPat(PathPat<'a>), StructPat(StructPat<'a>), FieldPatList(FieldPatList<'a>), TupleStructPat(TupleStructPat<'a>), TuplePat(TuplePat<'a>), SlicePat(SlicePat<'a>), RangePat(RangePat<'a>), } impl<'a> AstNode<'a> for Pat<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { REF_PAT => Some(Pat::RefPat(RefPat { syntax })), BIND_PAT => Some(Pat::BindPat(BindPat { syntax })), PLACEHOLDER_PAT => Some(Pat::PlaceholderPat(PlaceholderPat { syntax })), PATH_PAT => Some(Pat::PathPat(PathPat { syntax })), STRUCT_PAT => Some(Pat::StructPat(StructPat { syntax })), FIELD_PAT_LIST => Some(Pat::FieldPatList(FieldPatList { syntax })), TUPLE_STRUCT_PAT => Some(Pat::TupleStructPat(TupleStructPat { syntax })), TUPLE_PAT => Some(Pat::TuplePat(TuplePat { syntax })), SLICE_PAT => Some(Pat::SlicePat(SlicePat { syntax })), RANGE_PAT => Some(Pat::RangePat(RangePat { syntax })), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { match self { Pat::RefPat(inner) => inner.syntax(), Pat::BindPat(inner) => inner.syntax(), Pat::PlaceholderPat(inner) => inner.syntax(), Pat::PathPat(inner) => inner.syntax(), Pat::StructPat(inner) => inner.syntax(), Pat::FieldPatList(inner) => inner.syntax(), Pat::TupleStructPat(inner) => inner.syntax(), Pat::TuplePat(inner) => inner.syntax(), Pat::SlicePat(inner) => inner.syntax(), Pat::RangePat(inner) => inner.syntax(), } } } impl<'a> Pat<'a> {} // Path #[derive(Debug, Clone, Copy,)] pub struct PathNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type Path<'a> = PathNode>; impl, R2: TreeRoot> PartialEq> for PathNode { fn eq(&self, other: &PathNode) -> bool { self.syntax == other.syntax } } impl> Eq for PathNode {} impl> Hash for PathNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for Path<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { PATH => Some(Path { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> PathNode { pub fn borrowed(&self) -> Path { PathNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> PathNode { PathNode { syntax: self.syntax.owned() } } } impl<'a> Path<'a> { pub fn segment(self) -> Option> { super::child_opt(self) } pub fn qualifier(self) -> Option> { super::child_opt(self) } } // PathExpr #[derive(Debug, Clone, Copy,)] pub struct PathExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type PathExpr<'a> = PathExprNode>; impl, R2: TreeRoot> PartialEq> for PathExprNode { fn eq(&self, other: &PathExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for PathExprNode {} impl> Hash for PathExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for PathExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { PATH_EXPR => Some(PathExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> PathExprNode { pub fn borrowed(&self) -> PathExpr { PathExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> PathExprNode { PathExprNode { syntax: self.syntax.owned() } } } impl<'a> PathExpr<'a> { pub fn path(self) -> Option> { super::child_opt(self) } } // PathPat #[derive(Debug, Clone, Copy,)] pub struct PathPatNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type PathPat<'a> = PathPatNode>; impl, R2: TreeRoot> PartialEq> for PathPatNode { fn eq(&self, other: &PathPatNode) -> bool { self.syntax == other.syntax } } impl> Eq for PathPatNode {} impl> Hash for PathPatNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for PathPat<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { PATH_PAT => Some(PathPat { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> PathPatNode { pub fn borrowed(&self) -> PathPat { PathPatNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> PathPatNode { PathPatNode { syntax: self.syntax.owned() } } } impl<'a> PathPat<'a> {} // PathSegment #[derive(Debug, Clone, Copy,)] pub struct PathSegmentNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type PathSegment<'a> = PathSegmentNode>; impl, R2: TreeRoot> PartialEq> for PathSegmentNode { fn eq(&self, other: &PathSegmentNode) -> bool { self.syntax == other.syntax } } impl> Eq for PathSegmentNode {} impl> Hash for PathSegmentNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for PathSegment<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { PATH_SEGMENT => Some(PathSegment { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> PathSegmentNode { pub fn borrowed(&self) -> PathSegment { PathSegmentNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> PathSegmentNode { PathSegmentNode { syntax: self.syntax.owned() } } } impl<'a> PathSegment<'a> { pub fn name_ref(self) -> Option> { super::child_opt(self) } } // PathType #[derive(Debug, Clone, Copy,)] pub struct PathTypeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type PathType<'a> = PathTypeNode>; impl, R2: TreeRoot> PartialEq> for PathTypeNode { fn eq(&self, other: &PathTypeNode) -> bool { self.syntax == other.syntax } } impl> Eq for PathTypeNode {} impl> Hash for PathTypeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for PathType<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { PATH_TYPE => Some(PathType { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> PathTypeNode { pub fn borrowed(&self) -> PathType { PathTypeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> PathTypeNode { PathTypeNode { syntax: self.syntax.owned() } } } impl<'a> PathType<'a> {} // PlaceholderPat #[derive(Debug, Clone, Copy,)] pub struct PlaceholderPatNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type PlaceholderPat<'a> = PlaceholderPatNode>; impl, R2: TreeRoot> PartialEq> for PlaceholderPatNode { fn eq(&self, other: &PlaceholderPatNode) -> bool { self.syntax == other.syntax } } impl> Eq for PlaceholderPatNode {} impl> Hash for PlaceholderPatNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for PlaceholderPat<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { PLACEHOLDER_PAT => Some(PlaceholderPat { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> PlaceholderPatNode { pub fn borrowed(&self) -> PlaceholderPat { PlaceholderPatNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> PlaceholderPatNode { PlaceholderPatNode { syntax: self.syntax.owned() } } } impl<'a> PlaceholderPat<'a> {} // PlaceholderType #[derive(Debug, Clone, Copy,)] pub struct PlaceholderTypeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type PlaceholderType<'a> = PlaceholderTypeNode>; impl, R2: TreeRoot> PartialEq> for PlaceholderTypeNode { fn eq(&self, other: &PlaceholderTypeNode) -> bool { self.syntax == other.syntax } } impl> Eq for PlaceholderTypeNode {} impl> Hash for PlaceholderTypeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for PlaceholderType<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { PLACEHOLDER_TYPE => Some(PlaceholderType { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> PlaceholderTypeNode { pub fn borrowed(&self) -> PlaceholderType { PlaceholderTypeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> PlaceholderTypeNode { PlaceholderTypeNode { syntax: self.syntax.owned() } } } impl<'a> PlaceholderType<'a> {} // PointerType #[derive(Debug, Clone, Copy,)] pub struct PointerTypeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type PointerType<'a> = PointerTypeNode>; impl, R2: TreeRoot> PartialEq> for PointerTypeNode { fn eq(&self, other: &PointerTypeNode) -> bool { self.syntax == other.syntax } } impl> Eq for PointerTypeNode {} impl> Hash for PointerTypeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for PointerType<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { POINTER_TYPE => Some(PointerType { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> PointerTypeNode { pub fn borrowed(&self) -> PointerType { PointerTypeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> PointerTypeNode { PointerTypeNode { syntax: self.syntax.owned() } } } impl<'a> PointerType<'a> {} // PrefixExpr #[derive(Debug, Clone, Copy,)] pub struct PrefixExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type PrefixExpr<'a> = PrefixExprNode>; impl, R2: TreeRoot> PartialEq> for PrefixExprNode { fn eq(&self, other: &PrefixExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for PrefixExprNode {} impl> Hash for PrefixExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for PrefixExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { PREFIX_EXPR => Some(PrefixExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> PrefixExprNode { pub fn borrowed(&self) -> PrefixExpr { PrefixExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> PrefixExprNode { PrefixExprNode { syntax: self.syntax.owned() } } } impl<'a> PrefixExpr<'a> {} // RangeExpr #[derive(Debug, Clone, Copy,)] pub struct RangeExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type RangeExpr<'a> = RangeExprNode>; impl, R2: TreeRoot> PartialEq> for RangeExprNode { fn eq(&self, other: &RangeExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for RangeExprNode {} impl> Hash for RangeExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for RangeExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { RANGE_EXPR => Some(RangeExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> RangeExprNode { pub fn borrowed(&self) -> RangeExpr { RangeExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> RangeExprNode { RangeExprNode { syntax: self.syntax.owned() } } } impl<'a> RangeExpr<'a> {} // RangePat #[derive(Debug, Clone, Copy,)] pub struct RangePatNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type RangePat<'a> = RangePatNode>; impl, R2: TreeRoot> PartialEq> for RangePatNode { fn eq(&self, other: &RangePatNode) -> bool { self.syntax == other.syntax } } impl> Eq for RangePatNode {} impl> Hash for RangePatNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for RangePat<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { RANGE_PAT => Some(RangePat { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> RangePatNode { pub fn borrowed(&self) -> RangePat { RangePatNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> RangePatNode { RangePatNode { syntax: self.syntax.owned() } } } impl<'a> RangePat<'a> {} // RefExpr #[derive(Debug, Clone, Copy,)] pub struct RefExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type RefExpr<'a> = RefExprNode>; impl, R2: TreeRoot> PartialEq> for RefExprNode { fn eq(&self, other: &RefExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for RefExprNode {} impl> Hash for RefExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for RefExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { REF_EXPR => Some(RefExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> RefExprNode { pub fn borrowed(&self) -> RefExpr { RefExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> RefExprNode { RefExprNode { syntax: self.syntax.owned() } } } impl<'a> RefExpr<'a> {} // RefPat #[derive(Debug, Clone, Copy,)] pub struct RefPatNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type RefPat<'a> = RefPatNode>; impl, R2: TreeRoot> PartialEq> for RefPatNode { fn eq(&self, other: &RefPatNode) -> bool { self.syntax == other.syntax } } impl> Eq for RefPatNode {} impl> Hash for RefPatNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for RefPat<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { REF_PAT => Some(RefPat { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> RefPatNode { pub fn borrowed(&self) -> RefPat { RefPatNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> RefPatNode { RefPatNode { syntax: self.syntax.owned() } } } impl<'a> RefPat<'a> {} // ReferenceType #[derive(Debug, Clone, Copy,)] pub struct ReferenceTypeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ReferenceType<'a> = ReferenceTypeNode>; impl, R2: TreeRoot> PartialEq> for ReferenceTypeNode { fn eq(&self, other: &ReferenceTypeNode) -> bool { self.syntax == other.syntax } } impl> Eq for ReferenceTypeNode {} impl> Hash for ReferenceTypeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ReferenceType<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { REFERENCE_TYPE => Some(ReferenceType { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ReferenceTypeNode { pub fn borrowed(&self) -> ReferenceType { ReferenceTypeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ReferenceTypeNode { ReferenceTypeNode { syntax: self.syntax.owned() } } } impl<'a> ReferenceType<'a> {} // RetType #[derive(Debug, Clone, Copy,)] pub struct RetTypeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type RetType<'a> = RetTypeNode>; impl, R2: TreeRoot> PartialEq> for RetTypeNode { fn eq(&self, other: &RetTypeNode) -> bool { self.syntax == other.syntax } } impl> Eq for RetTypeNode {} impl> Hash for RetTypeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for RetType<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { RET_TYPE => Some(RetType { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> RetTypeNode { pub fn borrowed(&self) -> RetType { RetTypeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> RetTypeNode { RetTypeNode { syntax: self.syntax.owned() } } } impl<'a> RetType<'a> {} // ReturnExpr #[derive(Debug, Clone, Copy,)] pub struct ReturnExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type ReturnExpr<'a> = ReturnExprNode>; impl, R2: TreeRoot> PartialEq> for ReturnExprNode { fn eq(&self, other: &ReturnExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for ReturnExprNode {} impl> Hash for ReturnExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for ReturnExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { RETURN_EXPR => Some(ReturnExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> ReturnExprNode { pub fn borrowed(&self) -> ReturnExpr { ReturnExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> ReturnExprNode { ReturnExprNode { syntax: self.syntax.owned() } } } impl<'a> ReturnExpr<'a> {} // Root #[derive(Debug, Clone, Copy,)] pub struct RootNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type Root<'a> = RootNode>; impl, R2: TreeRoot> PartialEq> for RootNode { fn eq(&self, other: &RootNode) -> bool { self.syntax == other.syntax } } impl> Eq for RootNode {} impl> Hash for RootNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for Root<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { ROOT => Some(Root { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> RootNode { pub fn borrowed(&self) -> Root { RootNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> RootNode { RootNode { syntax: self.syntax.owned() } } } impl<'a> ast::ModuleItemOwner<'a> for Root<'a> {} impl<'a> ast::FnDefOwner<'a> for Root<'a> {} impl<'a> Root<'a> { pub fn modules(self) -> impl Iterator> + 'a { super::children(self) } } // SelfParam #[derive(Debug, Clone, Copy,)] pub struct SelfParamNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type SelfParam<'a> = SelfParamNode>; impl, R2: TreeRoot> PartialEq> for SelfParamNode { fn eq(&self, other: &SelfParamNode) -> bool { self.syntax == other.syntax } } impl> Eq for SelfParamNode {} impl> Hash for SelfParamNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for SelfParam<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { SELF_PARAM => Some(SelfParam { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> SelfParamNode { pub fn borrowed(&self) -> SelfParam { SelfParamNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> SelfParamNode { SelfParamNode { syntax: self.syntax.owned() } } } impl<'a> SelfParam<'a> {} // SlicePat #[derive(Debug, Clone, Copy,)] pub struct SlicePatNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type SlicePat<'a> = SlicePatNode>; impl, R2: TreeRoot> PartialEq> for SlicePatNode { fn eq(&self, other: &SlicePatNode) -> bool { self.syntax == other.syntax } } impl> Eq for SlicePatNode {} impl> Hash for SlicePatNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for SlicePat<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { SLICE_PAT => Some(SlicePat { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> SlicePatNode { pub fn borrowed(&self) -> SlicePat { SlicePatNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> SlicePatNode { SlicePatNode { syntax: self.syntax.owned() } } } impl<'a> SlicePat<'a> {} // SliceType #[derive(Debug, Clone, Copy,)] pub struct SliceTypeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type SliceType<'a> = SliceTypeNode>; impl, R2: TreeRoot> PartialEq> for SliceTypeNode { fn eq(&self, other: &SliceTypeNode) -> bool { self.syntax == other.syntax } } impl> Eq for SliceTypeNode {} impl> Hash for SliceTypeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for SliceType<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { SLICE_TYPE => Some(SliceType { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> SliceTypeNode { pub fn borrowed(&self) -> SliceType { SliceTypeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> SliceTypeNode { SliceTypeNode { syntax: self.syntax.owned() } } } impl<'a> SliceType<'a> {} // StaticDef #[derive(Debug, Clone, Copy,)] pub struct StaticDefNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type StaticDef<'a> = StaticDefNode>; impl, R2: TreeRoot> PartialEq> for StaticDefNode { fn eq(&self, other: &StaticDefNode) -> bool { self.syntax == other.syntax } } impl> Eq for StaticDefNode {} impl> Hash for StaticDefNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for StaticDef<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { STATIC_DEF => Some(StaticDef { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> StaticDefNode { pub fn borrowed(&self) -> StaticDef { StaticDefNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> StaticDefNode { StaticDefNode { syntax: self.syntax.owned() } } } impl<'a> ast::NameOwner<'a> for StaticDef<'a> {} impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {} impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {} impl<'a> StaticDef<'a> {} // Stmt #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Stmt<'a> { ExprStmt(ExprStmt<'a>), LetStmt(LetStmt<'a>), } impl<'a> AstNode<'a> for Stmt<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { EXPR_STMT => Some(Stmt::ExprStmt(ExprStmt { syntax })), LET_STMT => Some(Stmt::LetStmt(LetStmt { syntax })), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { match self { Stmt::ExprStmt(inner) => inner.syntax(), Stmt::LetStmt(inner) => inner.syntax(), } } } impl<'a> Stmt<'a> {} // StructDef #[derive(Debug, Clone, Copy,)] pub struct StructDefNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type StructDef<'a> = StructDefNode>; impl, R2: TreeRoot> PartialEq> for StructDefNode { fn eq(&self, other: &StructDefNode) -> bool { self.syntax == other.syntax } } impl> Eq for StructDefNode {} impl> Hash for StructDefNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for StructDef<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { STRUCT_DEF => Some(StructDef { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> StructDefNode { pub fn borrowed(&self) -> StructDef { StructDefNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> StructDefNode { StructDefNode { syntax: self.syntax.owned() } } } impl<'a> ast::NameOwner<'a> for StructDef<'a> {} impl<'a> ast::TypeParamsOwner<'a> for StructDef<'a> {} impl<'a> ast::AttrsOwner<'a> for StructDef<'a> {} impl<'a> StructDef<'a> { pub fn fields(self) -> impl Iterator> + 'a { super::children(self) } } // StructLit #[derive(Debug, Clone, Copy,)] pub struct StructLitNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type StructLit<'a> = StructLitNode>; impl, R2: TreeRoot> PartialEq> for StructLitNode { fn eq(&self, other: &StructLitNode) -> bool { self.syntax == other.syntax } } impl> Eq for StructLitNode {} impl> Hash for StructLitNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for StructLit<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { STRUCT_LIT => Some(StructLit { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> StructLitNode { pub fn borrowed(&self) -> StructLit { StructLitNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> StructLitNode { StructLitNode { syntax: self.syntax.owned() } } } impl<'a> StructLit<'a> {} // StructPat #[derive(Debug, Clone, Copy,)] pub struct StructPatNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type StructPat<'a> = StructPatNode>; impl, R2: TreeRoot> PartialEq> for StructPatNode { fn eq(&self, other: &StructPatNode) -> bool { self.syntax == other.syntax } } impl> Eq for StructPatNode {} impl> Hash for StructPatNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for StructPat<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { STRUCT_PAT => Some(StructPat { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> StructPatNode { pub fn borrowed(&self) -> StructPat { StructPatNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> StructPatNode { StructPatNode { syntax: self.syntax.owned() } } } impl<'a> StructPat<'a> {} // TokenTree #[derive(Debug, Clone, Copy,)] pub struct TokenTreeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type TokenTree<'a> = TokenTreeNode>; impl, R2: TreeRoot> PartialEq> for TokenTreeNode { fn eq(&self, other: &TokenTreeNode) -> bool { self.syntax == other.syntax } } impl> Eq for TokenTreeNode {} impl> Hash for TokenTreeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for TokenTree<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { TOKEN_TREE => Some(TokenTree { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> TokenTreeNode { pub fn borrowed(&self) -> TokenTree { TokenTreeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> TokenTreeNode { TokenTreeNode { syntax: self.syntax.owned() } } } impl<'a> TokenTree<'a> {} // TraitDef #[derive(Debug, Clone, Copy,)] pub struct TraitDefNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type TraitDef<'a> = TraitDefNode>; impl, R2: TreeRoot> PartialEq> for TraitDefNode { fn eq(&self, other: &TraitDefNode) -> bool { self.syntax == other.syntax } } impl> Eq for TraitDefNode {} impl> Hash for TraitDefNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for TraitDef<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { TRAIT_DEF => Some(TraitDef { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> TraitDefNode { pub fn borrowed(&self) -> TraitDef { TraitDefNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> TraitDefNode { TraitDefNode { syntax: self.syntax.owned() } } } impl<'a> ast::NameOwner<'a> for TraitDef<'a> {} impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {} impl<'a> TraitDef<'a> {} // TryExpr #[derive(Debug, Clone, Copy,)] pub struct TryExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type TryExpr<'a> = TryExprNode>; impl, R2: TreeRoot> PartialEq> for TryExprNode { fn eq(&self, other: &TryExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for TryExprNode {} impl> Hash for TryExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for TryExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { TRY_EXPR => Some(TryExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> TryExprNode { pub fn borrowed(&self) -> TryExpr { TryExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> TryExprNode { TryExprNode { syntax: self.syntax.owned() } } } impl<'a> TryExpr<'a> {} // TupleExpr #[derive(Debug, Clone, Copy,)] pub struct TupleExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type TupleExpr<'a> = TupleExprNode>; impl, R2: TreeRoot> PartialEq> for TupleExprNode { fn eq(&self, other: &TupleExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for TupleExprNode {} impl> Hash for TupleExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for TupleExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { TUPLE_EXPR => Some(TupleExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> TupleExprNode { pub fn borrowed(&self) -> TupleExpr { TupleExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> TupleExprNode { TupleExprNode { syntax: self.syntax.owned() } } } impl<'a> TupleExpr<'a> {} // TuplePat #[derive(Debug, Clone, Copy,)] pub struct TuplePatNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type TuplePat<'a> = TuplePatNode>; impl, R2: TreeRoot> PartialEq> for TuplePatNode { fn eq(&self, other: &TuplePatNode) -> bool { self.syntax == other.syntax } } impl> Eq for TuplePatNode {} impl> Hash for TuplePatNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for TuplePat<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { TUPLE_PAT => Some(TuplePat { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> TuplePatNode { pub fn borrowed(&self) -> TuplePat { TuplePatNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> TuplePatNode { TuplePatNode { syntax: self.syntax.owned() } } } impl<'a> TuplePat<'a> {} // TupleStructPat #[derive(Debug, Clone, Copy,)] pub struct TupleStructPatNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type TupleStructPat<'a> = TupleStructPatNode>; impl, R2: TreeRoot> PartialEq> for TupleStructPatNode { fn eq(&self, other: &TupleStructPatNode) -> bool { self.syntax == other.syntax } } impl> Eq for TupleStructPatNode {} impl> Hash for TupleStructPatNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for TupleStructPat<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { TUPLE_STRUCT_PAT => Some(TupleStructPat { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> TupleStructPatNode { pub fn borrowed(&self) -> TupleStructPat { TupleStructPatNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> TupleStructPatNode { TupleStructPatNode { syntax: self.syntax.owned() } } } impl<'a> TupleStructPat<'a> {} // TupleType #[derive(Debug, Clone, Copy,)] pub struct TupleTypeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type TupleType<'a> = TupleTypeNode>; impl, R2: TreeRoot> PartialEq> for TupleTypeNode { fn eq(&self, other: &TupleTypeNode) -> bool { self.syntax == other.syntax } } impl> Eq for TupleTypeNode {} impl> Hash for TupleTypeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for TupleType<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { TUPLE_TYPE => Some(TupleType { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> TupleTypeNode { pub fn borrowed(&self) -> TupleType { TupleTypeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> TupleTypeNode { TupleTypeNode { syntax: self.syntax.owned() } } } impl<'a> TupleType<'a> {} // TypeDef #[derive(Debug, Clone, Copy,)] pub struct TypeDefNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type TypeDef<'a> = TypeDefNode>; impl, R2: TreeRoot> PartialEq> for TypeDefNode { fn eq(&self, other: &TypeDefNode) -> bool { self.syntax == other.syntax } } impl> Eq for TypeDefNode {} impl> Hash for TypeDefNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for TypeDef<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { TYPE_DEF => Some(TypeDef { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> TypeDefNode { pub fn borrowed(&self) -> TypeDef { TypeDefNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> TypeDefNode { TypeDefNode { syntax: self.syntax.owned() } } } impl<'a> ast::NameOwner<'a> for TypeDef<'a> {} impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {} impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {} impl<'a> TypeDef<'a> {} // TypeParam #[derive(Debug, Clone, Copy,)] pub struct TypeParamNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type TypeParam<'a> = TypeParamNode>; impl, R2: TreeRoot> PartialEq> for TypeParamNode { fn eq(&self, other: &TypeParamNode) -> bool { self.syntax == other.syntax } } impl> Eq for TypeParamNode {} impl> Hash for TypeParamNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for TypeParam<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { TYPE_PARAM => Some(TypeParam { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> TypeParamNode { pub fn borrowed(&self) -> TypeParam { TypeParamNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> TypeParamNode { TypeParamNode { syntax: self.syntax.owned() } } } impl<'a> ast::NameOwner<'a> for TypeParam<'a> {} impl<'a> TypeParam<'a> {} // TypeParamList #[derive(Debug, Clone, Copy,)] pub struct TypeParamListNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type TypeParamList<'a> = TypeParamListNode>; impl, R2: TreeRoot> PartialEq> for TypeParamListNode { fn eq(&self, other: &TypeParamListNode) -> bool { self.syntax == other.syntax } } impl> Eq for TypeParamListNode {} impl> Hash for TypeParamListNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for TypeParamList<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { TYPE_PARAM_LIST => Some(TypeParamList { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> TypeParamListNode { pub fn borrowed(&self) -> TypeParamList { TypeParamListNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> TypeParamListNode { TypeParamListNode { syntax: self.syntax.owned() } } } impl<'a> TypeParamList<'a> { pub fn type_params(self) -> impl Iterator> + 'a { super::children(self) } pub fn lifetime_params(self) -> impl Iterator> + 'a { super::children(self) } } // TypeRef #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum TypeRef<'a> { ParenType(ParenType<'a>), TupleType(TupleType<'a>), NeverType(NeverType<'a>), PathType(PathType<'a>), PointerType(PointerType<'a>), ArrayType(ArrayType<'a>), SliceType(SliceType<'a>), ReferenceType(ReferenceType<'a>), PlaceholderType(PlaceholderType<'a>), FnPointerType(FnPointerType<'a>), ForType(ForType<'a>), ImplTraitType(ImplTraitType<'a>), DynTraitType(DynTraitType<'a>), } impl<'a> AstNode<'a> for TypeRef<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { PAREN_TYPE => Some(TypeRef::ParenType(ParenType { syntax })), TUPLE_TYPE => Some(TypeRef::TupleType(TupleType { syntax })), NEVER_TYPE => Some(TypeRef::NeverType(NeverType { syntax })), PATH_TYPE => Some(TypeRef::PathType(PathType { syntax })), POINTER_TYPE => Some(TypeRef::PointerType(PointerType { syntax })), ARRAY_TYPE => Some(TypeRef::ArrayType(ArrayType { syntax })), SLICE_TYPE => Some(TypeRef::SliceType(SliceType { syntax })), REFERENCE_TYPE => Some(TypeRef::ReferenceType(ReferenceType { syntax })), PLACEHOLDER_TYPE => Some(TypeRef::PlaceholderType(PlaceholderType { syntax })), FN_POINTER_TYPE => Some(TypeRef::FnPointerType(FnPointerType { syntax })), FOR_TYPE => Some(TypeRef::ForType(ForType { syntax })), IMPL_TRAIT_TYPE => Some(TypeRef::ImplTraitType(ImplTraitType { syntax })), DYN_TRAIT_TYPE => Some(TypeRef::DynTraitType(DynTraitType { syntax })), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { match self { TypeRef::ParenType(inner) => inner.syntax(), TypeRef::TupleType(inner) => inner.syntax(), TypeRef::NeverType(inner) => inner.syntax(), TypeRef::PathType(inner) => inner.syntax(), TypeRef::PointerType(inner) => inner.syntax(), TypeRef::ArrayType(inner) => inner.syntax(), TypeRef::SliceType(inner) => inner.syntax(), TypeRef::ReferenceType(inner) => inner.syntax(), TypeRef::PlaceholderType(inner) => inner.syntax(), TypeRef::FnPointerType(inner) => inner.syntax(), TypeRef::ForType(inner) => inner.syntax(), TypeRef::ImplTraitType(inner) => inner.syntax(), TypeRef::DynTraitType(inner) => inner.syntax(), } } } impl<'a> TypeRef<'a> {} // UseItem #[derive(Debug, Clone, Copy,)] pub struct UseItemNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type UseItem<'a> = UseItemNode>; impl, R2: TreeRoot> PartialEq> for UseItemNode { fn eq(&self, other: &UseItemNode) -> bool { self.syntax == other.syntax } } impl> Eq for UseItemNode {} impl> Hash for UseItemNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for UseItem<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { USE_ITEM => Some(UseItem { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> UseItemNode { pub fn borrowed(&self) -> UseItem { UseItemNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> UseItemNode { UseItemNode { syntax: self.syntax.owned() } } } impl<'a> UseItem<'a> { pub fn use_tree(self) -> Option> { super::child_opt(self) } } // UseTree #[derive(Debug, Clone, Copy,)] pub struct UseTreeNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type UseTree<'a> = UseTreeNode>; impl, R2: TreeRoot> PartialEq> for UseTreeNode { fn eq(&self, other: &UseTreeNode) -> bool { self.syntax == other.syntax } } impl> Eq for UseTreeNode {} impl> Hash for UseTreeNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for UseTree<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { USE_TREE => Some(UseTree { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> UseTreeNode { pub fn borrowed(&self) -> UseTree { UseTreeNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> UseTreeNode { UseTreeNode { syntax: self.syntax.owned() } } } impl<'a> UseTree<'a> { pub fn path(self) -> Option> { super::child_opt(self) } pub fn use_tree_list(self) -> Option> { super::child_opt(self) } } // UseTreeList #[derive(Debug, Clone, Copy,)] pub struct UseTreeListNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type UseTreeList<'a> = UseTreeListNode>; impl, R2: TreeRoot> PartialEq> for UseTreeListNode { fn eq(&self, other: &UseTreeListNode) -> bool { self.syntax == other.syntax } } impl> Eq for UseTreeListNode {} impl> Hash for UseTreeListNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for UseTreeList<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { USE_TREE_LIST => Some(UseTreeList { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> UseTreeListNode { pub fn borrowed(&self) -> UseTreeList { UseTreeListNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> UseTreeListNode { UseTreeListNode { syntax: self.syntax.owned() } } } impl<'a> UseTreeList<'a> { pub fn use_trees(self) -> impl Iterator> + 'a { super::children(self) } } // WhereClause #[derive(Debug, Clone, Copy,)] pub struct WhereClauseNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type WhereClause<'a> = WhereClauseNode>; impl, R2: TreeRoot> PartialEq> for WhereClauseNode { fn eq(&self, other: &WhereClauseNode) -> bool { self.syntax == other.syntax } } impl> Eq for WhereClauseNode {} impl> Hash for WhereClauseNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for WhereClause<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { WHERE_CLAUSE => Some(WhereClause { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> WhereClauseNode { pub fn borrowed(&self) -> WhereClause { WhereClauseNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> WhereClauseNode { WhereClauseNode { syntax: self.syntax.owned() } } } impl<'a> WhereClause<'a> {} // WhileExpr #[derive(Debug, Clone, Copy,)] pub struct WhileExprNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type WhileExpr<'a> = WhileExprNode>; impl, R2: TreeRoot> PartialEq> for WhileExprNode { fn eq(&self, other: &WhileExprNode) -> bool { self.syntax == other.syntax } } impl> Eq for WhileExprNode {} impl> Hash for WhileExprNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for WhileExpr<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { WHILE_EXPR => Some(WhileExpr { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> WhileExprNode { pub fn borrowed(&self) -> WhileExpr { WhileExprNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> WhileExprNode { WhileExprNode { syntax: self.syntax.owned() } } } impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {} impl<'a> WhileExpr<'a> { pub fn condition(self) -> Option> { super::child_opt(self) } } // Whitespace #[derive(Debug, Clone, Copy,)] pub struct WhitespaceNode = OwnedRoot> { pub(crate) syntax: SyntaxNode, } pub type Whitespace<'a> = WhitespaceNode>; impl, R2: TreeRoot> PartialEq> for WhitespaceNode { fn eq(&self, other: &WhitespaceNode) -> bool { self.syntax == other.syntax } } impl> Eq for WhitespaceNode {} impl> Hash for WhitespaceNode { fn hash(&self, state: &mut H) { self.syntax.hash(state) } } impl<'a> AstNode<'a> for Whitespace<'a> { fn cast(syntax: SyntaxNodeRef<'a>) -> Option { match syntax.kind() { WHITESPACE => Some(Whitespace { syntax }), _ => None, } } fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } impl> WhitespaceNode { pub fn borrowed(&self) -> Whitespace { WhitespaceNode { syntax: self.syntax.borrowed() } } pub fn owned(&self) -> WhitespaceNode { WhitespaceNode { syntax: self.syntax.owned() } } } impl<'a> Whitespace<'a> {}