rust/crates/ra_syntax/src/ast/generated.rs

3809 lines
91 KiB
Rust
Raw Normal View History

2018-10-16 20:09:22 +02:00
// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run
2018-10-04 22:43:58 +02:00
// Do not edit manually
#![cfg_attr(rustfmt, rustfmt_skip)]
2018-10-15 18:55:32 +02:00
use crate::{
2018-08-11 11:28:59 +02:00
ast,
SyntaxNode, SyntaxNodeRef, AstNode,
2018-08-09 16:43:39 +02:00
SyntaxKind::*,
};
2018-08-28 22:59:57 +02:00
// ArgList
#[derive(Debug, Clone)]
pub struct ArgListNode(SyntaxNode);
impl ArgListNode {
pub fn ast(&self) -> ArgList {
ArgList::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ArgList<'a>> for ArgListNode {
fn from(ast: ArgList<'a>) -> ArgListNode {
let syntax = ast.syntax().owned();
ArgListNode(syntax)
}
}
2018-08-28 22:59:57 +02:00
#[derive(Debug, Clone, Copy)]
pub struct ArgList<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for ArgList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
ARG_LIST => Some(ArgList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> ArgList<'a> {
pub fn args(self) -> impl Iterator<Item = Expr<'a>> + 'a {
super::children(self)
}
}
2018-08-25 12:42:40 +02:00
// ArrayExpr
#[derive(Debug, Clone)]
pub struct ArrayExprNode(SyntaxNode);
impl ArrayExprNode {
pub fn ast(&self) -> ArrayExpr {
ArrayExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ArrayExpr<'a>> for ArrayExprNode {
fn from(ast: ArrayExpr<'a>) -> ArrayExprNode {
let syntax = ast.syntax().owned();
ArrayExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct ArrayExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for ArrayExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
ARRAY_EXPR => Some(ArrayExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> ArrayExpr<'a> {}
2018-08-14 11:38:20 +02:00
// ArrayType
#[derive(Debug, Clone)]
pub struct ArrayTypeNode(SyntaxNode);
impl ArrayTypeNode {
pub fn ast(&self) -> ArrayType {
ArrayType::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ArrayType<'a>> for ArrayTypeNode {
fn from(ast: ArrayType<'a>) -> ArrayTypeNode {
let syntax = ast.syntax().owned();
ArrayTypeNode(syntax)
}
}
2018-08-14 11:38:20 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct ArrayType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for ArrayType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
ARRAY_TYPE => Some(ArrayType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> ArrayType<'a> {}
2018-08-14 11:38:20 +02:00
2018-08-16 11:51:40 +02:00
// Attr
#[derive(Debug, Clone)]
pub struct AttrNode(SyntaxNode);
impl AttrNode {
pub fn ast(&self) -> Attr {
Attr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Attr<'a>> for AttrNode {
fn from(ast: Attr<'a>) -> AttrNode {
let syntax = ast.syntax().owned();
AttrNode(syntax)
}
}
2018-08-16 11:51:40 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct Attr<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-16 11:51:40 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for Attr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-16 11:51:40 +02:00
match syntax.kind() {
ATTR => Some(Attr { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-16 11:51:40 +02:00
}
impl<'a> Attr<'a> {
pub fn value(self) -> Option<TokenTree<'a>> {
2018-08-22 16:01:51 +02:00
super::child_opt(self)
2018-08-16 11:51:40 +02:00
}
}
2018-08-25 12:42:40 +02:00
// BinExpr
#[derive(Debug, Clone)]
pub struct BinExprNode(SyntaxNode);
impl BinExprNode {
pub fn ast(&self) -> BinExpr {
BinExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<BinExpr<'a>> for BinExprNode {
fn from(ast: BinExpr<'a>) -> BinExprNode {
let syntax = ast.syntax().owned();
BinExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct BinExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for BinExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
BIN_EXPR => Some(BinExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> BinExpr<'a> {}
2018-08-26 11:09:28 +02:00
// BindPat
#[derive(Debug, Clone)]
pub struct BindPatNode(SyntaxNode);
impl BindPatNode {
pub fn ast(&self) -> BindPat {
BindPat::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<BindPat<'a>> for BindPatNode {
fn from(ast: BindPat<'a>) -> BindPatNode {
let syntax = ast.syntax().owned();
BindPatNode(syntax)
}
}
2018-08-26 11:09:28 +02:00
#[derive(Debug, Clone, Copy)]
pub struct BindPat<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for BindPat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
BIND_PAT => Some(BindPat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> ast::NameOwner<'a> for BindPat<'a> {}
impl<'a> BindPat<'a> {}
2018-08-25 12:42:40 +02:00
// Block
#[derive(Debug, Clone)]
pub struct BlockNode(SyntaxNode);
impl BlockNode {
pub fn ast(&self) -> Block {
Block::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Block<'a>> for BlockNode {
fn from(ast: Block<'a>) -> BlockNode {
let syntax = ast.syntax().owned();
BlockNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct Block<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for Block<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
BLOCK => Some(Block { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-08-26 11:09:28 +02:00
impl<'a> Block<'a> {
2018-08-27 09:12:28 +02:00
pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a {
2018-08-26 11:09:28 +02:00
super::children(self)
}
pub fn expr(self) -> Option<Expr<'a>> {
2018-08-27 09:12:28 +02:00
super::child_opt(self)
}
2018-08-26 11:09:28 +02:00
}
2018-08-25 12:42:40 +02:00
// BlockExpr
#[derive(Debug, Clone)]
pub struct BlockExprNode(SyntaxNode);
impl BlockExprNode {
pub fn ast(&self) -> BlockExpr {
BlockExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<BlockExpr<'a>> for BlockExprNode {
fn from(ast: BlockExpr<'a>) -> BlockExprNode {
let syntax = ast.syntax().owned();
BlockExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct BlockExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for BlockExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
BLOCK_EXPR => Some(BlockExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> BlockExpr<'a> {
pub fn block(self) -> Option<Block<'a>> {
2018-08-27 11:22:09 +02:00
super::child_opt(self)
}
}
2018-08-25 12:42:40 +02:00
// BreakExpr
#[derive(Debug, Clone)]
pub struct BreakExprNode(SyntaxNode);
impl BreakExprNode {
pub fn ast(&self) -> BreakExpr {
BreakExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<BreakExpr<'a>> for BreakExprNode {
fn from(ast: BreakExpr<'a>) -> BreakExprNode {
let syntax = ast.syntax().owned();
BreakExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct BreakExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for BreakExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
BREAK_EXPR => Some(BreakExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> BreakExpr<'a> {}
// CallExpr
#[derive(Debug, Clone)]
pub struct CallExprNode(SyntaxNode);
impl CallExprNode {
pub fn ast(&self) -> CallExpr {
CallExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<CallExpr<'a>> for CallExprNode {
fn from(ast: CallExpr<'a>) -> CallExprNode {
let syntax = ast.syntax().owned();
CallExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct CallExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for CallExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
CALL_EXPR => Some(CallExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-09-03 01:01:43 +02:00
impl<'a> ast::ArgListOwner<'a> for CallExpr<'a> {}
impl<'a> CallExpr<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
2018-08-28 22:59:57 +02:00
super::child_opt(self)
}
}
2018-08-25 12:42:40 +02:00
// CastExpr
#[derive(Debug, Clone)]
pub struct CastExprNode(SyntaxNode);
impl CastExprNode {
pub fn ast(&self) -> CastExpr {
CastExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<CastExpr<'a>> for CastExprNode {
fn from(ast: CastExpr<'a>) -> CastExprNode {
let syntax = ast.syntax().owned();
CastExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct CastExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for CastExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
CAST_EXPR => Some(CastExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> CastExpr<'a> {}
2018-10-11 16:25:35 +02:00
// Comment
#[derive(Debug, Clone)]
pub struct CommentNode(SyntaxNode);
impl CommentNode {
pub fn ast(&self) -> Comment {
Comment::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Comment<'a>> for CommentNode {
fn from(ast: Comment<'a>) -> CommentNode {
let syntax = ast.syntax().owned();
CommentNode(syntax)
}
}
2018-10-11 16:25:35 +02:00
#[derive(Debug, Clone, Copy)]
pub struct Comment<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for Comment<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
COMMENT => Some(Comment { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> Comment<'a> {}
2018-08-27 11:22:09 +02:00
// Condition
#[derive(Debug, Clone)]
pub struct ConditionNode(SyntaxNode);
impl ConditionNode {
pub fn ast(&self) -> Condition {
Condition::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Condition<'a>> for ConditionNode {
fn from(ast: Condition<'a>) -> ConditionNode {
let syntax = ast.syntax().owned();
ConditionNode(syntax)
}
}
2018-08-27 11:22:09 +02:00
#[derive(Debug, Clone, Copy)]
pub struct Condition<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for Condition<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
CONDITION => Some(Condition { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> Condition<'a> {
pub fn pat(self) -> Option<Pat<'a>> {
2018-08-27 11:22:09 +02:00
super::child_opt(self)
}
pub fn expr(self) -> Option<Expr<'a>> {
2018-08-27 11:22:09 +02:00
super::child_opt(self)
}
}
2018-08-13 17:36:16 +02:00
// ConstDef
#[derive(Debug, Clone)]
pub struct ConstDefNode(SyntaxNode);
impl ConstDefNode {
pub fn ast(&self) -> ConstDef {
ConstDef::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ConstDef<'a>> for ConstDefNode {
fn from(ast: ConstDef<'a>) -> ConstDefNode {
let syntax = ast.syntax().owned();
ConstDefNode(syntax)
}
}
2018-08-11 10:03:22 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct ConstDef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-11 10:03:22 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for ConstDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 10:03:22 +02:00
match syntax.kind() {
2018-08-13 17:36:16 +02:00
CONST_DEF => Some(ConstDef { syntax }),
2018-08-11 10:03:22 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 10:03:22 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> ast::NameOwner<'a> for ConstDef<'a> {}
2018-08-22 15:46:42 +02:00
impl<'a> ast::TypeParamsOwner<'a> for ConstDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {}
impl<'a> ConstDef<'a> {}
2018-08-11 10:03:22 +02:00
2018-08-25 12:42:40 +02:00
// ContinueExpr
#[derive(Debug, Clone)]
pub struct ContinueExprNode(SyntaxNode);
impl ContinueExprNode {
pub fn ast(&self) -> ContinueExpr {
ContinueExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ContinueExpr<'a>> for ContinueExprNode {
fn from(ast: ContinueExpr<'a>) -> ContinueExprNode {
let syntax = ast.syntax().owned();
ContinueExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct ContinueExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for ContinueExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
CONTINUE_EXPR => Some(ContinueExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> ContinueExpr<'a> {}
2018-08-14 11:38:20 +02:00
// DynTraitType
#[derive(Debug, Clone)]
pub struct DynTraitTypeNode(SyntaxNode);
impl DynTraitTypeNode {
pub fn ast(&self) -> DynTraitType {
DynTraitType::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<DynTraitType<'a>> for DynTraitTypeNode {
fn from(ast: DynTraitType<'a>) -> DynTraitTypeNode {
let syntax = ast.syntax().owned();
DynTraitTypeNode(syntax)
}
}
2018-08-14 11:38:20 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct DynTraitType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for DynTraitType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
DYN_TRAIT_TYPE => Some(DynTraitType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> DynTraitType<'a> {}
2018-08-14 11:38:20 +02:00
2018-08-13 17:36:16 +02:00
// EnumDef
#[derive(Debug, Clone)]
pub struct EnumDefNode(SyntaxNode);
impl EnumDefNode {
pub fn ast(&self) -> EnumDef {
EnumDef::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<EnumDef<'a>> for EnumDefNode {
fn from(ast: EnumDef<'a>) -> EnumDefNode {
let syntax = ast.syntax().owned();
EnumDefNode(syntax)
}
}
2018-08-11 09:56:40 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct EnumDef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-11 09:56:40 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for EnumDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 09:56:40 +02:00
match syntax.kind() {
2018-08-13 17:36:16 +02:00
ENUM_DEF => Some(EnumDef { syntax }),
2018-08-11 09:56:40 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 09:56:40 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> ast::NameOwner<'a> for EnumDef<'a> {}
2018-08-22 15:46:42 +02:00
impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {}
impl<'a> EnumDef<'a> {}
2018-08-11 09:56:40 +02:00
2018-08-25 12:42:40 +02:00
// Expr
#[derive(Debug, Clone)]
pub struct ExprNode(SyntaxNode);
impl ExprNode {
pub fn ast(&self) -> Expr {
Expr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Expr<'a>> for ExprNode {
fn from(ast: Expr<'a>) -> ExprNode {
let syntax = ast.syntax().owned();
ExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
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>),
2018-08-28 13:21:37 +02:00
Literal(Literal<'a>),
2018-08-25 12:42:40 +02:00
}
impl<'a> AstNode<'a> for Expr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
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 })),
2018-08-28 13:21:37 +02:00
LITERAL => Some(Expr::Literal(Literal { syntax })),
2018-08-25 12:42:40 +02:00
_ => 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(),
2018-08-28 13:21:37 +02:00
Expr::Literal(inner) => inner.syntax(),
2018-08-25 12:42:40 +02:00
}
}
}
impl<'a> Expr<'a> {}
2018-08-27 09:01:31 +02:00
// ExprStmt
#[derive(Debug, Clone)]
pub struct ExprStmtNode(SyntaxNode);
impl ExprStmtNode {
pub fn ast(&self) -> ExprStmt {
ExprStmt::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ExprStmt<'a>> for ExprStmtNode {
fn from(ast: ExprStmt<'a>) -> ExprStmtNode {
let syntax = ast.syntax().owned();
ExprStmtNode(syntax)
}
}
2018-08-27 09:01:31 +02:00
#[derive(Debug, Clone, Copy)]
pub struct ExprStmt<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for ExprStmt<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
EXPR_STMT => Some(ExprStmt { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> ExprStmt<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
2018-08-27 11:22:09 +02:00
super::child_opt(self)
}
}
2018-08-27 09:01:31 +02:00
2018-08-28 10:12:42 +02:00
// ExternCrateItem
#[derive(Debug, Clone)]
pub struct ExternCrateItemNode(SyntaxNode);
impl ExternCrateItemNode {
pub fn ast(&self) -> ExternCrateItem {
ExternCrateItem::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ExternCrateItem<'a>> for ExternCrateItemNode {
fn from(ast: ExternCrateItem<'a>) -> ExternCrateItemNode {
let syntax = ast.syntax().owned();
ExternCrateItemNode(syntax)
}
}
2018-08-28 10:12:42 +02:00
#[derive(Debug, Clone, Copy)]
pub struct ExternCrateItem<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for ExternCrateItem<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
EXTERN_CRATE_ITEM => Some(ExternCrateItem { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> ExternCrateItem<'a> {}
2018-08-25 12:42:40 +02:00
// FieldExpr
#[derive(Debug, Clone)]
pub struct FieldExprNode(SyntaxNode);
impl FieldExprNode {
pub fn ast(&self) -> FieldExpr {
FieldExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<FieldExpr<'a>> for FieldExprNode {
fn from(ast: FieldExpr<'a>) -> FieldExprNode {
let syntax = ast.syntax().owned();
FieldExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct FieldExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for FieldExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
FIELD_EXPR => Some(FieldExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> FieldExpr<'a> {}
2018-08-26 11:09:28 +02:00
// FieldPatList
#[derive(Debug, Clone)]
pub struct FieldPatListNode(SyntaxNode);
impl FieldPatListNode {
pub fn ast(&self) -> FieldPatList {
FieldPatList::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<FieldPatList<'a>> for FieldPatListNode {
fn from(ast: FieldPatList<'a>) -> FieldPatListNode {
let syntax = ast.syntax().owned();
FieldPatListNode(syntax)
}
}
2018-08-26 11:09:28 +02:00
#[derive(Debug, Clone, Copy)]
pub struct FieldPatList<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for FieldPatList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
FIELD_PAT_LIST => Some(FieldPatList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> FieldPatList<'a> {}
2018-08-13 17:36:16 +02:00
// FnDef
#[derive(Debug, Clone)]
pub struct FnDefNode(SyntaxNode);
impl FnDefNode {
pub fn ast(&self) -> FnDef {
FnDef::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<FnDef<'a>> for FnDefNode {
fn from(ast: FnDef<'a>) -> FnDefNode {
let syntax = ast.syntax().owned();
FnDefNode(syntax)
}
}
2018-08-10 14:07:43 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct FnDef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-09 16:43:39 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for FnDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-09 16:43:39 +02:00
match syntax.kind() {
2018-08-13 17:36:16 +02:00
FN_DEF => Some(FnDef { syntax }),
2018-08-09 16:43:39 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-09 16:43:39 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> ast::NameOwner<'a> for FnDef<'a> {}
2018-08-22 15:46:42 +02:00
impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {}
2018-08-17 21:00:13 +02:00
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<ParamList<'a>> {
2018-08-26 11:09:28 +02:00
super::child_opt(self)
}
pub fn body(self) -> Option<Block<'a>> {
2018-08-27 09:01:31 +02:00
super::child_opt(self)
}
pub fn ret_type(self) -> Option<RetType<'a>> {
2018-08-28 20:11:17 +02:00
super::child_opt(self)
}
2018-08-26 11:09:28 +02:00
}
2018-08-11 08:55:32 +02:00
2018-08-14 11:38:20 +02:00
// FnPointerType
#[derive(Debug, Clone)]
pub struct FnPointerTypeNode(SyntaxNode);
impl FnPointerTypeNode {
pub fn ast(&self) -> FnPointerType {
FnPointerType::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<FnPointerType<'a>> for FnPointerTypeNode {
fn from(ast: FnPointerType<'a>) -> FnPointerTypeNode {
let syntax = ast.syntax().owned();
FnPointerTypeNode(syntax)
}
}
2018-08-14 11:38:20 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct FnPointerType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for FnPointerType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
FN_POINTER_TYPE => Some(FnPointerType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> FnPointerType<'a> {}
2018-08-14 11:38:20 +02:00
2018-08-25 12:42:40 +02:00
// ForExpr
#[derive(Debug, Clone)]
pub struct ForExprNode(SyntaxNode);
impl ForExprNode {
pub fn ast(&self) -> ForExpr {
ForExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ForExpr<'a>> for ForExprNode {
fn from(ast: ForExpr<'a>) -> ForExprNode {
let syntax = ast.syntax().owned();
ForExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct ForExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for ForExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
FOR_EXPR => Some(ForExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-08-30 20:32:12 +02:00
impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {}
impl<'a> ForExpr<'a> {
pub fn pat(self) -> Option<Pat<'a>> {
2018-08-27 21:03:19 +02:00
super::child_opt(self)
}
pub fn iterable(self) -> Option<Expr<'a>> {
2018-08-27 21:03:19 +02:00
super::child_opt(self)
}
2018-08-27 11:22:09 +02:00
}
2018-08-25 12:42:40 +02:00
2018-08-14 11:38:20 +02:00
// ForType
#[derive(Debug, Clone)]
pub struct ForTypeNode(SyntaxNode);
impl ForTypeNode {
pub fn ast(&self) -> ForType {
ForType::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ForType<'a>> for ForTypeNode {
fn from(ast: ForType<'a>) -> ForTypeNode {
let syntax = ast.syntax().owned();
ForTypeNode(syntax)
}
}
2018-08-14 11:38:20 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct ForType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for ForType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
FOR_TYPE => Some(ForType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> ForType<'a> {}
2018-08-14 11:38:20 +02:00
2018-08-25 12:42:40 +02:00
// IfExpr
#[derive(Debug, Clone)]
pub struct IfExprNode(SyntaxNode);
impl IfExprNode {
pub fn ast(&self) -> IfExpr {
IfExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<IfExpr<'a>> for IfExprNode {
fn from(ast: IfExpr<'a>) -> IfExprNode {
let syntax = ast.syntax().owned();
IfExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct IfExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for IfExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
IF_EXPR => Some(IfExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> IfExpr<'a> {
pub fn condition(self) -> Option<Condition<'a>> {
2018-08-27 11:22:09 +02:00
super::child_opt(self)
}
}
2018-08-25 12:42:40 +02:00
2018-08-14 10:20:09 +02:00
// ImplItem
#[derive(Debug, Clone)]
pub struct ImplItemNode(SyntaxNode);
impl ImplItemNode {
pub fn ast(&self) -> ImplItem {
ImplItem::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ImplItem<'a>> for ImplItemNode {
fn from(ast: ImplItem<'a>) -> ImplItemNode {
let syntax = ast.syntax().owned();
ImplItemNode(syntax)
}
}
2018-08-14 10:20:09 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct ImplItem<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 10:20:09 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for ImplItem<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 10:20:09 +02:00
match syntax.kind() {
IMPL_ITEM => Some(ImplItem { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 10:20:09 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> ImplItem<'a> {}
2018-08-14 10:20:09 +02:00
2018-08-14 11:38:20 +02:00
// ImplTraitType
#[derive(Debug, Clone)]
pub struct ImplTraitTypeNode(SyntaxNode);
impl ImplTraitTypeNode {
pub fn ast(&self) -> ImplTraitType {
ImplTraitType::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ImplTraitType<'a>> for ImplTraitTypeNode {
fn from(ast: ImplTraitType<'a>) -> ImplTraitTypeNode {
let syntax = ast.syntax().owned();
ImplTraitTypeNode(syntax)
}
}
2018-08-14 11:38:20 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct ImplTraitType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for ImplTraitType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
IMPL_TRAIT_TYPE => Some(ImplTraitType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> ImplTraitType<'a> {}
2018-08-14 11:38:20 +02:00
2018-08-25 12:42:40 +02:00
// IndexExpr
#[derive(Debug, Clone)]
pub struct IndexExprNode(SyntaxNode);
impl IndexExprNode {
pub fn ast(&self) -> IndexExpr {
IndexExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<IndexExpr<'a>> for IndexExprNode {
fn from(ast: IndexExpr<'a>) -> IndexExprNode {
let syntax = ast.syntax().owned();
IndexExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct IndexExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for IndexExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
INDEX_EXPR => Some(IndexExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> IndexExpr<'a> {}
2018-09-03 14:10:06 +02:00
// ItemList
#[derive(Debug, Clone)]
pub struct ItemListNode(SyntaxNode);
impl ItemListNode {
pub fn ast(&self) -> ItemList {
ItemList::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ItemList<'a>> for ItemListNode {
fn from(ast: ItemList<'a>) -> ItemListNode {
let syntax = ast.syntax().owned();
ItemListNode(syntax)
}
}
2018-09-03 14:10:06 +02:00
#[derive(Debug, Clone, Copy)]
pub struct ItemList<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for ItemList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
ITEM_LIST => Some(ItemList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-09-03 14:46:14 +02:00
impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {}
2018-09-08 00:35:20 +02:00
impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {}
impl<'a> ItemList<'a> {}
2018-09-03 14:10:06 +02:00
2018-08-25 12:42:40 +02:00
// Label
#[derive(Debug, Clone)]
pub struct LabelNode(SyntaxNode);
impl LabelNode {
pub fn ast(&self) -> Label {
Label::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Label<'a>> for LabelNode {
fn from(ast: Label<'a>) -> LabelNode {
let syntax = ast.syntax().owned();
LabelNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct Label<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for Label<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
LABEL => Some(Label { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> Label<'a> {}
// LambdaExpr
#[derive(Debug, Clone)]
pub struct LambdaExprNode(SyntaxNode);
impl LambdaExprNode {
pub fn ast(&self) -> LambdaExpr {
LambdaExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<LambdaExpr<'a>> for LambdaExprNode {
fn from(ast: LambdaExpr<'a>) -> LambdaExprNode {
let syntax = ast.syntax().owned();
LambdaExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct LambdaExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for LambdaExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
LAMBDA_EXPR => Some(LambdaExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> LambdaExpr<'a> {
pub fn param_list(self) -> Option<ParamList<'a>> {
2018-08-28 22:59:57 +02:00
super::child_opt(self)
}
pub fn body(self) -> Option<Expr<'a>> {
2018-08-28 22:59:57 +02:00
super::child_opt(self)
}
}
2018-08-25 12:42:40 +02:00
2018-08-26 11:09:28 +02:00
// LetStmt
#[derive(Debug, Clone)]
pub struct LetStmtNode(SyntaxNode);
impl LetStmtNode {
pub fn ast(&self) -> LetStmt {
LetStmt::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<LetStmt<'a>> for LetStmtNode {
fn from(ast: LetStmt<'a>) -> LetStmtNode {
let syntax = ast.syntax().owned();
LetStmtNode(syntax)
}
}
2018-08-26 11:09:28 +02:00
#[derive(Debug, Clone, Copy)]
pub struct LetStmt<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for LetStmt<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
LET_STMT => Some(LetStmt { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> LetStmt<'a> {
pub fn pat(self) -> Option<Pat<'a>> {
2018-08-26 11:09:28 +02:00
super::child_opt(self)
}
pub fn initializer(self) -> Option<Expr<'a>> {
2018-08-27 09:01:31 +02:00
super::child_opt(self)
}
2018-08-26 11:09:28 +02:00
}
2018-08-28 22:59:57 +02:00
// Lifetime
#[derive(Debug, Clone)]
pub struct LifetimeNode(SyntaxNode);
impl LifetimeNode {
pub fn ast(&self) -> Lifetime {
Lifetime::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Lifetime<'a>> for LifetimeNode {
fn from(ast: Lifetime<'a>) -> LifetimeNode {
let syntax = ast.syntax().owned();
LifetimeNode(syntax)
}
}
2018-08-28 22:59:57 +02:00
#[derive(Debug, Clone, Copy)]
pub struct Lifetime<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for Lifetime<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
LIFETIME => Some(Lifetime { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> Lifetime<'a> {}
// LifetimeParam
#[derive(Debug, Clone)]
pub struct LifetimeParamNode(SyntaxNode);
impl LifetimeParamNode {
pub fn ast(&self) -> LifetimeParam {
LifetimeParam::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<LifetimeParam<'a>> for LifetimeParamNode {
fn from(ast: LifetimeParam<'a>) -> LifetimeParamNode {
let syntax = ast.syntax().owned();
LifetimeParamNode(syntax)
}
}
2018-08-28 22:59:57 +02:00
#[derive(Debug, Clone, Copy)]
pub struct LifetimeParam<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for LifetimeParam<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
LIFETIME_PARAM => Some(LifetimeParam { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> LifetimeParam<'a> {
pub fn lifetime(self) -> Option<Lifetime<'a>> {
2018-08-28 22:59:57 +02:00
super::child_opt(self)
}
}
2018-08-28 13:21:37 +02:00
// Literal
#[derive(Debug, Clone)]
pub struct LiteralNode(SyntaxNode);
impl LiteralNode {
pub fn ast(&self) -> Literal {
Literal::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Literal<'a>> for LiteralNode {
fn from(ast: Literal<'a>) -> LiteralNode {
let syntax = ast.syntax().owned();
LiteralNode(syntax)
}
}
2018-08-28 13:21:37 +02:00
#[derive(Debug, Clone, Copy)]
pub struct Literal<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for Literal<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
LITERAL => Some(Literal { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> Literal<'a> {}
2018-08-25 12:42:40 +02:00
// LoopExpr
#[derive(Debug, Clone)]
pub struct LoopExprNode(SyntaxNode);
impl LoopExprNode {
pub fn ast(&self) -> LoopExpr {
LoopExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<LoopExpr<'a>> for LoopExprNode {
fn from(ast: LoopExpr<'a>) -> LoopExprNode {
let syntax = ast.syntax().owned();
LoopExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct LoopExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for LoopExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
LOOP_EXPR => Some(LoopExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-08-30 20:32:12 +02:00
impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {}
impl<'a> LoopExpr<'a> {}
2018-08-25 12:42:40 +02:00
// MatchArm
#[derive(Debug, Clone)]
pub struct MatchArmNode(SyntaxNode);
impl MatchArmNode {
pub fn ast(&self) -> MatchArm {
MatchArm::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<MatchArm<'a>> for MatchArmNode {
fn from(ast: MatchArm<'a>) -> MatchArmNode {
let syntax = ast.syntax().owned();
MatchArmNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct MatchArm<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for MatchArm<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
MATCH_ARM => Some(MatchArm { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-09-03 00:51:46 +02:00
impl<'a> MatchArm<'a> {
pub fn pats(self) -> impl Iterator<Item = Pat<'a>> + 'a {
super::children(self)
}
pub fn guard(self) -> Option<MatchGuard<'a>> {
2018-09-03 00:51:46 +02:00
super::child_opt(self)
}
pub fn expr(self) -> Option<Expr<'a>> {
2018-09-03 00:51:46 +02:00
super::child_opt(self)
}
}
2018-08-25 12:42:40 +02:00
// MatchArmList
#[derive(Debug, Clone)]
pub struct MatchArmListNode(SyntaxNode);
impl MatchArmListNode {
pub fn ast(&self) -> MatchArmList {
MatchArmList::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<MatchArmList<'a>> for MatchArmListNode {
fn from(ast: MatchArmList<'a>) -> MatchArmListNode {
let syntax = ast.syntax().owned();
MatchArmListNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct MatchArmList<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for MatchArmList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
MATCH_ARM_LIST => Some(MatchArmList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-09-03 00:51:46 +02:00
impl<'a> MatchArmList<'a> {
pub fn arms(self) -> impl Iterator<Item = MatchArm<'a>> + 'a {
super::children(self)
}
}
2018-08-25 12:42:40 +02:00
// MatchExpr
#[derive(Debug, Clone)]
pub struct MatchExprNode(SyntaxNode);
impl MatchExprNode {
pub fn ast(&self) -> MatchExpr {
MatchExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<MatchExpr<'a>> for MatchExprNode {
fn from(ast: MatchExpr<'a>) -> MatchExprNode {
let syntax = ast.syntax().owned();
MatchExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct MatchExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for MatchExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
MATCH_EXPR => Some(MatchExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> MatchExpr<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
2018-09-03 00:51:46 +02:00
super::child_opt(self)
}
pub fn match_arm_list(self) -> Option<MatchArmList<'a>> {
2018-09-03 00:51:46 +02:00
super::child_opt(self)
}
}
2018-08-25 12:42:40 +02:00
// MatchGuard
#[derive(Debug, Clone)]
pub struct MatchGuardNode(SyntaxNode);
impl MatchGuardNode {
pub fn ast(&self) -> MatchGuard {
MatchGuard::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<MatchGuard<'a>> for MatchGuardNode {
fn from(ast: MatchGuard<'a>) -> MatchGuardNode {
let syntax = ast.syntax().owned();
MatchGuardNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct MatchGuard<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for MatchGuard<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
MATCH_GUARD => Some(MatchGuard { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> MatchGuard<'a> {}
// MethodCallExpr
#[derive(Debug, Clone)]
pub struct MethodCallExprNode(SyntaxNode);
impl MethodCallExprNode {
pub fn ast(&self) -> MethodCallExpr {
MethodCallExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<MethodCallExpr<'a>> for MethodCallExprNode {
fn from(ast: MethodCallExpr<'a>) -> MethodCallExprNode {
let syntax = ast.syntax().owned();
MethodCallExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct MethodCallExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for MethodCallExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
METHOD_CALL_EXPR => Some(MethodCallExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-09-03 01:01:43 +02:00
impl<'a> ast::ArgListOwner<'a> for MethodCallExpr<'a> {}
impl<'a> MethodCallExpr<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
2018-09-03 01:01:43 +02:00
super::child_opt(self)
}
}
2018-08-25 12:42:40 +02:00
2018-08-11 11:28:59 +02:00
// Module
#[derive(Debug, Clone)]
pub struct ModuleNode(SyntaxNode);
impl ModuleNode {
pub fn ast(&self) -> Module {
Module::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Module<'a>> for ModuleNode {
fn from(ast: Module<'a>) -> ModuleNode {
let syntax = ast.syntax().owned();
ModuleNode(syntax)
}
}
2018-08-11 10:03:22 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct Module<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-11 10:03:22 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for Module<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 10:03:22 +02:00
match syntax.kind() {
MODULE => Some(Module { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 10:03:22 +02:00
}
2018-08-17 21:00:13 +02:00
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<ItemList<'a>> {
2018-09-03 14:10:06 +02:00
super::child_opt(self)
2018-08-21 17:30:10 +02:00
}
}
2018-08-11 10:03:22 +02:00
2018-08-28 10:12:42 +02:00
// ModuleItem
#[derive(Debug, Clone)]
pub struct ModuleItemNode(SyntaxNode);
impl ModuleItemNode {
pub fn ast(&self) -> ModuleItem {
ModuleItem::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ModuleItem<'a>> for ModuleItemNode {
fn from(ast: ModuleItem<'a>) -> ModuleItemNode {
let syntax = ast.syntax().owned();
ModuleItemNode(syntax)
}
}
2018-08-28 10:12:42 +02:00
#[derive(Debug, Clone, Copy)]
pub enum ModuleItem<'a> {
StructDef(StructDef<'a>),
EnumDef(EnumDef<'a>),
FnDef(FnDef<'a>),
TraitDef(TraitDef<'a>),
2018-09-01 11:30:53 +02:00
TypeDef(TypeDef<'a>),
2018-08-28 10:12:42 +02:00
ImplItem(ImplItem<'a>),
UseItem(UseItem<'a>),
ExternCrateItem(ExternCrateItem<'a>),
2018-08-28 18:35:09 +02:00
ConstDef(ConstDef<'a>),
StaticDef(StaticDef<'a>),
2018-08-30 19:37:33 +02:00
Module(Module<'a>),
2018-08-28 10:12:42 +02:00
}
impl<'a> AstNode<'a> for ModuleItem<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
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 })),
2018-09-01 11:30:53 +02:00
TYPE_DEF => Some(ModuleItem::TypeDef(TypeDef { syntax })),
2018-08-28 10:12:42 +02:00
IMPL_ITEM => Some(ModuleItem::ImplItem(ImplItem { syntax })),
USE_ITEM => Some(ModuleItem::UseItem(UseItem { syntax })),
EXTERN_CRATE_ITEM => Some(ModuleItem::ExternCrateItem(ExternCrateItem { syntax })),
2018-08-28 18:35:09 +02:00
CONST_DEF => Some(ModuleItem::ConstDef(ConstDef { syntax })),
STATIC_DEF => Some(ModuleItem::StaticDef(StaticDef { syntax })),
2018-08-30 19:37:33 +02:00
MODULE => Some(ModuleItem::Module(Module { syntax })),
2018-08-28 10:12:42 +02:00
_ => 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(),
2018-09-01 11:30:53 +02:00
ModuleItem::TypeDef(inner) => inner.syntax(),
2018-08-28 10:12:42 +02:00
ModuleItem::ImplItem(inner) => inner.syntax(),
ModuleItem::UseItem(inner) => inner.syntax(),
ModuleItem::ExternCrateItem(inner) => inner.syntax(),
2018-08-28 18:35:09 +02:00
ModuleItem::ConstDef(inner) => inner.syntax(),
ModuleItem::StaticDef(inner) => inner.syntax(),
2018-08-30 19:37:33 +02:00
ModuleItem::Module(inner) => inner.syntax(),
2018-08-28 10:12:42 +02:00
}
}
}
impl<'a> ModuleItem<'a> {}
2018-08-11 11:28:59 +02:00
// Name
#[derive(Debug, Clone)]
pub struct NameNode(SyntaxNode);
impl NameNode {
pub fn ast(&self) -> Name {
Name::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Name<'a>> for NameNode {
fn from(ast: Name<'a>) -> NameNode {
let syntax = ast.syntax().owned();
NameNode(syntax)
}
}
2018-08-10 14:07:43 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct Name<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-09 16:43:39 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for Name<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-09 16:43:39 +02:00
match syntax.kind() {
NAME => Some(Name { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-09 16:43:39 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> Name<'a> {}
2018-08-11 08:55:32 +02:00
2018-08-13 15:35:17 +02:00
// NameRef
#[derive(Debug, Clone)]
pub struct NameRefNode(SyntaxNode);
impl NameRefNode {
pub fn ast(&self) -> NameRef {
NameRef::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<NameRef<'a>> for NameRefNode {
fn from(ast: NameRef<'a>) -> NameRefNode {
let syntax = ast.syntax().owned();
NameRefNode(syntax)
}
}
2018-08-13 15:35:17 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct NameRef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-13 15:35:17 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for NameRef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-13 15:35:17 +02:00
match syntax.kind() {
NAME_REF => Some(NameRef { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-13 15:35:17 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> NameRef<'a> {}
2018-08-13 15:35:17 +02:00
2018-08-25 12:42:40 +02:00
// NamedField
#[derive(Debug, Clone)]
pub struct NamedFieldNode(SyntaxNode);
impl NamedFieldNode {
pub fn ast(&self) -> NamedField {
NamedField::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<NamedField<'a>> for NamedFieldNode {
fn from(ast: NamedField<'a>) -> NamedFieldNode {
let syntax = ast.syntax().owned();
NamedFieldNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct NamedField<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for NamedField<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
NAMED_FIELD => Some(NamedField { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> NamedField<'a> {}
2018-08-24 18:27:30 +02:00
// NamedFieldDef
#[derive(Debug, Clone)]
pub struct NamedFieldDefNode(SyntaxNode);
impl NamedFieldDefNode {
pub fn ast(&self) -> NamedFieldDef {
NamedFieldDef::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<NamedFieldDef<'a>> for NamedFieldDefNode {
fn from(ast: NamedFieldDef<'a>) -> NamedFieldDefNode {
let syntax = ast.syntax().owned();
NamedFieldDefNode(syntax)
}
}
2018-08-14 13:45:56 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-24 18:27:30 +02:00
pub struct NamedFieldDef<'a> {
2018-08-17 21:00:13 +02:00
syntax: SyntaxNodeRef<'a>,
2018-08-14 13:45:56 +02:00
}
2018-08-24 18:27:30 +02:00
impl<'a> AstNode<'a> for NamedFieldDef<'a> {
2018-08-17 21:00:13 +02:00
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 13:45:56 +02:00
match syntax.kind() {
2018-08-24 18:27:30 +02:00
NAMED_FIELD_DEF => Some(NamedFieldDef { syntax }),
2018-08-14 13:45:56 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 13:45:56 +02:00
}
2018-08-24 18:27:30 +02:00
impl<'a> ast::NameOwner<'a> for NamedFieldDef<'a> {}
impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {}
impl<'a> NamedFieldDef<'a> {}
2018-08-14 13:45:56 +02:00
2018-08-25 12:42:40 +02:00
// NamedFieldList
#[derive(Debug, Clone)]
pub struct NamedFieldListNode(SyntaxNode);
impl NamedFieldListNode {
pub fn ast(&self) -> NamedFieldList {
NamedFieldList::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<NamedFieldList<'a>> for NamedFieldListNode {
fn from(ast: NamedFieldList<'a>) -> NamedFieldListNode {
let syntax = ast.syntax().owned();
NamedFieldListNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct NamedFieldList<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for NamedFieldList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
NAMED_FIELD_LIST => Some(NamedFieldList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> NamedFieldList<'a> {}
2018-08-14 11:38:20 +02:00
// NeverType
#[derive(Debug, Clone)]
pub struct NeverTypeNode(SyntaxNode);
impl NeverTypeNode {
pub fn ast(&self) -> NeverType {
NeverType::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<NeverType<'a>> for NeverTypeNode {
fn from(ast: NeverType<'a>) -> NeverTypeNode {
let syntax = ast.syntax().owned();
NeverTypeNode(syntax)
}
}
2018-08-14 11:38:20 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct NeverType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for NeverType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
NEVER_TYPE => Some(NeverType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> NeverType<'a> {}
2018-08-14 11:38:20 +02:00
2018-08-14 12:33:44 +02:00
// NominalDef
#[derive(Debug, Clone)]
pub struct NominalDefNode(SyntaxNode);
impl NominalDefNode {
pub fn ast(&self) -> NominalDef {
NominalDef::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<NominalDef<'a>> for NominalDefNode {
fn from(ast: NominalDef<'a>) -> NominalDefNode {
let syntax = ast.syntax().owned();
NominalDefNode(syntax)
}
}
2018-08-14 12:33:44 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub enum NominalDef<'a> {
StructDef(StructDef<'a>),
EnumDef(EnumDef<'a>),
2018-08-14 12:33:44 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for NominalDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 12:33:44 +02:00
match syntax.kind() {
STRUCT_DEF => Some(NominalDef::StructDef(StructDef { syntax })),
ENUM_DEF => Some(NominalDef::EnumDef(EnumDef { syntax })),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> {
2018-08-14 12:33:44 +02:00
match self {
NominalDef::StructDef(inner) => inner.syntax(),
NominalDef::EnumDef(inner) => inner.syntax(),
}
}
}
2018-08-22 17:05:43 +02:00
impl<'a> ast::NameOwner<'a> for NominalDef<'a> {}
2018-08-22 15:46:42 +02:00
impl<'a> ast::TypeParamsOwner<'a> for NominalDef<'a> {}
2018-08-22 17:05:43 +02:00
impl<'a> ast::AttrsOwner<'a> for NominalDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> NominalDef<'a> {}
2018-08-14 12:33:44 +02:00
2018-08-26 11:09:28 +02:00
// Param
#[derive(Debug, Clone)]
pub struct ParamNode(SyntaxNode);
impl ParamNode {
pub fn ast(&self) -> Param {
Param::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Param<'a>> for ParamNode {
fn from(ast: Param<'a>) -> ParamNode {
let syntax = ast.syntax().owned();
ParamNode(syntax)
}
}
2018-08-26 11:09:28 +02:00
#[derive(Debug, Clone, Copy)]
pub struct Param<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for Param<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PARAM => Some(Param { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> Param<'a> {
pub fn pat(self) -> Option<Pat<'a>> {
2018-08-26 11:09:28 +02:00
super::child_opt(self)
}
}
// ParamList
#[derive(Debug, Clone)]
pub struct ParamListNode(SyntaxNode);
impl ParamListNode {
pub fn ast(&self) -> ParamList {
ParamList::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ParamList<'a>> for ParamListNode {
fn from(ast: ParamList<'a>) -> ParamListNode {
let syntax = ast.syntax().owned();
ParamListNode(syntax)
}
}
2018-08-26 11:09:28 +02:00
#[derive(Debug, Clone, Copy)]
pub struct ParamList<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for ParamList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PARAM_LIST => Some(ParamList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> ParamList<'a> {
pub fn params(self) -> impl Iterator<Item = Param<'a>> + 'a {
super::children(self)
}
pub fn self_param(self) -> Option<SelfParam<'a>> {
2018-08-31 15:30:42 +02:00
super::child_opt(self)
}
2018-08-26 11:09:28 +02:00
}
2018-08-25 12:42:40 +02:00
// ParenExpr
#[derive(Debug, Clone)]
pub struct ParenExprNode(SyntaxNode);
impl ParenExprNode {
pub fn ast(&self) -> ParenExpr {
ParenExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ParenExpr<'a>> for ParenExprNode {
fn from(ast: ParenExpr<'a>) -> ParenExprNode {
let syntax = ast.syntax().owned();
ParenExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct ParenExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for ParenExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PAREN_EXPR => Some(ParenExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> ParenExpr<'a> {}
2018-08-14 11:38:20 +02:00
// ParenType
#[derive(Debug, Clone)]
pub struct ParenTypeNode(SyntaxNode);
impl ParenTypeNode {
pub fn ast(&self) -> ParenType {
ParenType::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ParenType<'a>> for ParenTypeNode {
fn from(ast: ParenType<'a>) -> ParenTypeNode {
let syntax = ast.syntax().owned();
ParenTypeNode(syntax)
}
}
2018-08-14 11:38:20 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct ParenType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for ParenType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
PAREN_TYPE => Some(ParenType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> ParenType<'a> {}
2018-08-14 11:38:20 +02:00
2018-08-26 11:09:28 +02:00
// Pat
#[derive(Debug, Clone)]
pub struct PatNode(SyntaxNode);
impl PatNode {
pub fn ast(&self) -> Pat {
Pat::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Pat<'a>> for PatNode {
fn from(ast: Pat<'a>) -> PatNode {
let syntax = ast.syntax().owned();
PatNode(syntax)
}
}
2018-08-26 11:09:28 +02:00
#[derive(Debug, Clone, Copy)]
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<Self> {
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> {}
2018-08-30 19:03:18 +02:00
// Path
#[derive(Debug, Clone)]
pub struct PathNode(SyntaxNode);
impl PathNode {
pub fn ast(&self) -> Path {
Path::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Path<'a>> for PathNode {
fn from(ast: Path<'a>) -> PathNode {
let syntax = ast.syntax().owned();
PathNode(syntax)
}
}
2018-08-30 19:03:18 +02:00
#[derive(Debug, Clone, Copy)]
pub struct Path<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for Path<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PATH => Some(Path { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> Path<'a> {
pub fn segment(self) -> Option<PathSegment<'a>> {
2018-08-30 19:37:33 +02:00
super::child_opt(self)
}
2018-10-24 17:37:25 +02:00
pub fn qualifier(self) -> Option<Path<'a>> {
super::child_opt(self)
}
2018-08-30 19:37:33 +02:00
}
2018-08-30 19:03:18 +02:00
2018-08-25 12:42:40 +02:00
// PathExpr
#[derive(Debug, Clone)]
pub struct PathExprNode(SyntaxNode);
impl PathExprNode {
pub fn ast(&self) -> PathExpr {
PathExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<PathExpr<'a>> for PathExprNode {
fn from(ast: PathExpr<'a>) -> PathExprNode {
let syntax = ast.syntax().owned();
PathExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct PathExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for PathExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PATH_EXPR => Some(PathExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-10-12 13:43:37 +02:00
impl<'a> PathExpr<'a> {
pub fn path(self) -> Option<Path<'a>> {
super::child_opt(self)
}
}
2018-08-25 12:42:40 +02:00
2018-08-26 11:09:28 +02:00
// PathPat
#[derive(Debug, Clone)]
pub struct PathPatNode(SyntaxNode);
impl PathPatNode {
pub fn ast(&self) -> PathPat {
PathPat::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<PathPat<'a>> for PathPatNode {
fn from(ast: PathPat<'a>) -> PathPatNode {
let syntax = ast.syntax().owned();
PathPatNode(syntax)
}
}
2018-08-26 11:09:28 +02:00
#[derive(Debug, Clone, Copy)]
pub struct PathPat<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for PathPat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PATH_PAT => Some(PathPat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> PathPat<'a> {}
2018-08-30 19:37:33 +02:00
// PathSegment
#[derive(Debug, Clone)]
pub struct PathSegmentNode(SyntaxNode);
impl PathSegmentNode {
pub fn ast(&self) -> PathSegment {
PathSegment::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<PathSegment<'a>> for PathSegmentNode {
fn from(ast: PathSegment<'a>) -> PathSegmentNode {
let syntax = ast.syntax().owned();
PathSegmentNode(syntax)
}
}
2018-08-30 19:37:33 +02:00
#[derive(Debug, Clone, Copy)]
pub struct PathSegment<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for PathSegment<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PATH_SEGMENT => Some(PathSegment { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> PathSegment<'a> {
pub fn name_ref(self) -> Option<NameRef<'a>> {
2018-08-30 19:37:33 +02:00
super::child_opt(self)
}
}
2018-08-14 11:38:20 +02:00
// PathType
#[derive(Debug, Clone)]
pub struct PathTypeNode(SyntaxNode);
impl PathTypeNode {
pub fn ast(&self) -> PathType {
PathType::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<PathType<'a>> for PathTypeNode {
fn from(ast: PathType<'a>) -> PathTypeNode {
let syntax = ast.syntax().owned();
PathTypeNode(syntax)
}
}
2018-08-14 11:38:20 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct PathType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for PathType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
PATH_TYPE => Some(PathType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> PathType<'a> {}
2018-08-14 11:38:20 +02:00
2018-08-26 11:09:28 +02:00
// PlaceholderPat
#[derive(Debug, Clone)]
pub struct PlaceholderPatNode(SyntaxNode);
impl PlaceholderPatNode {
pub fn ast(&self) -> PlaceholderPat {
PlaceholderPat::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<PlaceholderPat<'a>> for PlaceholderPatNode {
fn from(ast: PlaceholderPat<'a>) -> PlaceholderPatNode {
let syntax = ast.syntax().owned();
PlaceholderPatNode(syntax)
}
}
2018-08-26 11:09:28 +02:00
#[derive(Debug, Clone, Copy)]
pub struct PlaceholderPat<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for PlaceholderPat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PLACEHOLDER_PAT => Some(PlaceholderPat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> PlaceholderPat<'a> {}
2018-08-14 11:38:20 +02:00
// PlaceholderType
#[derive(Debug, Clone)]
pub struct PlaceholderTypeNode(SyntaxNode);
impl PlaceholderTypeNode {
pub fn ast(&self) -> PlaceholderType {
PlaceholderType::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<PlaceholderType<'a>> for PlaceholderTypeNode {
fn from(ast: PlaceholderType<'a>) -> PlaceholderTypeNode {
let syntax = ast.syntax().owned();
PlaceholderTypeNode(syntax)
}
}
2018-08-14 11:38:20 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct PlaceholderType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for PlaceholderType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
PLACEHOLDER_TYPE => Some(PlaceholderType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> PlaceholderType<'a> {}
2018-08-14 11:38:20 +02:00
// PointerType
#[derive(Debug, Clone)]
pub struct PointerTypeNode(SyntaxNode);
impl PointerTypeNode {
pub fn ast(&self) -> PointerType {
PointerType::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<PointerType<'a>> for PointerTypeNode {
fn from(ast: PointerType<'a>) -> PointerTypeNode {
let syntax = ast.syntax().owned();
PointerTypeNode(syntax)
}
}
2018-08-14 11:38:20 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct PointerType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for PointerType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
POINTER_TYPE => Some(PointerType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> PointerType<'a> {}
2018-08-14 11:38:20 +02:00
2018-08-25 12:42:40 +02:00
// PrefixExpr
#[derive(Debug, Clone)]
pub struct PrefixExprNode(SyntaxNode);
impl PrefixExprNode {
pub fn ast(&self) -> PrefixExpr {
PrefixExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<PrefixExpr<'a>> for PrefixExprNode {
fn from(ast: PrefixExpr<'a>) -> PrefixExprNode {
let syntax = ast.syntax().owned();
PrefixExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct PrefixExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for PrefixExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PREFIX_EXPR => Some(PrefixExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> PrefixExpr<'a> {}
// RangeExpr
#[derive(Debug, Clone)]
pub struct RangeExprNode(SyntaxNode);
impl RangeExprNode {
pub fn ast(&self) -> RangeExpr {
RangeExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<RangeExpr<'a>> for RangeExprNode {
fn from(ast: RangeExpr<'a>) -> RangeExprNode {
let syntax = ast.syntax().owned();
RangeExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct RangeExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for RangeExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
RANGE_EXPR => Some(RangeExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> RangeExpr<'a> {}
2018-08-26 11:09:28 +02:00
// RangePat
#[derive(Debug, Clone)]
pub struct RangePatNode(SyntaxNode);
impl RangePatNode {
pub fn ast(&self) -> RangePat {
RangePat::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<RangePat<'a>> for RangePatNode {
fn from(ast: RangePat<'a>) -> RangePatNode {
let syntax = ast.syntax().owned();
RangePatNode(syntax)
}
}
2018-08-26 11:09:28 +02:00
#[derive(Debug, Clone, Copy)]
pub struct RangePat<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for RangePat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
RANGE_PAT => Some(RangePat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> RangePat<'a> {}
2018-08-25 12:42:40 +02:00
// RefExpr
#[derive(Debug, Clone)]
pub struct RefExprNode(SyntaxNode);
impl RefExprNode {
pub fn ast(&self) -> RefExpr {
RefExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<RefExpr<'a>> for RefExprNode {
fn from(ast: RefExpr<'a>) -> RefExprNode {
let syntax = ast.syntax().owned();
RefExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct RefExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for RefExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
REF_EXPR => Some(RefExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> RefExpr<'a> {}
2018-08-26 11:09:28 +02:00
// RefPat
#[derive(Debug, Clone)]
pub struct RefPatNode(SyntaxNode);
impl RefPatNode {
pub fn ast(&self) -> RefPat {
RefPat::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<RefPat<'a>> for RefPatNode {
fn from(ast: RefPat<'a>) -> RefPatNode {
let syntax = ast.syntax().owned();
RefPatNode(syntax)
}
}
2018-08-26 11:09:28 +02:00
#[derive(Debug, Clone, Copy)]
pub struct RefPat<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for RefPat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
REF_PAT => Some(RefPat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> RefPat<'a> {}
2018-08-14 11:38:20 +02:00
// ReferenceType
#[derive(Debug, Clone)]
pub struct ReferenceTypeNode(SyntaxNode);
impl ReferenceTypeNode {
pub fn ast(&self) -> ReferenceType {
ReferenceType::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ReferenceType<'a>> for ReferenceTypeNode {
fn from(ast: ReferenceType<'a>) -> ReferenceTypeNode {
let syntax = ast.syntax().owned();
ReferenceTypeNode(syntax)
}
}
2018-08-14 11:38:20 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct ReferenceType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for ReferenceType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
REFERENCE_TYPE => Some(ReferenceType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> ReferenceType<'a> {}
2018-08-14 11:38:20 +02:00
2018-08-28 20:11:17 +02:00
// RetType
#[derive(Debug, Clone)]
pub struct RetTypeNode(SyntaxNode);
impl RetTypeNode {
pub fn ast(&self) -> RetType {
RetType::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<RetType<'a>> for RetTypeNode {
fn from(ast: RetType<'a>) -> RetTypeNode {
let syntax = ast.syntax().owned();
RetTypeNode(syntax)
}
}
2018-08-28 20:11:17 +02:00
#[derive(Debug, Clone, Copy)]
pub struct RetType<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for RetType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
RET_TYPE => Some(RetType { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> RetType<'a> {}
2018-08-25 12:42:40 +02:00
// ReturnExpr
#[derive(Debug, Clone)]
pub struct ReturnExprNode(SyntaxNode);
impl ReturnExprNode {
pub fn ast(&self) -> ReturnExpr {
ReturnExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<ReturnExpr<'a>> for ReturnExprNode {
fn from(ast: ReturnExpr<'a>) -> ReturnExprNode {
let syntax = ast.syntax().owned();
ReturnExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct ReturnExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for ReturnExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
RETURN_EXPR => Some(ReturnExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> ReturnExpr<'a> {}
2018-08-25 10:44:17 +02:00
// Root
#[derive(Debug, Clone)]
pub struct RootNode(SyntaxNode);
impl RootNode {
pub fn ast(&self) -> Root {
Root::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Root<'a>> for RootNode {
fn from(ast: Root<'a>) -> RootNode {
let syntax = ast.syntax().owned();
RootNode(syntax)
}
}
2018-08-25 10:44:17 +02:00
#[derive(Debug, Clone, Copy)]
pub struct Root<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for Root<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
ROOT => Some(Root { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-09-08 00:35:20 +02:00
impl<'a> ast::ModuleItemOwner<'a> for Root<'a> {}
2018-09-03 14:10:06 +02:00
impl<'a> ast::FnDefOwner<'a> for Root<'a> {}
2018-08-25 10:44:17 +02:00
impl<'a> Root<'a> {
pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a {
super::children(self)
}
}
2018-08-31 15:30:42 +02:00
// SelfParam
#[derive(Debug, Clone)]
pub struct SelfParamNode(SyntaxNode);
impl SelfParamNode {
pub fn ast(&self) -> SelfParam {
SelfParam::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<SelfParam<'a>> for SelfParamNode {
fn from(ast: SelfParam<'a>) -> SelfParamNode {
let syntax = ast.syntax().owned();
SelfParamNode(syntax)
}
}
2018-08-31 15:30:42 +02:00
#[derive(Debug, Clone, Copy)]
pub struct SelfParam<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for SelfParam<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
SELF_PARAM => Some(SelfParam { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> SelfParam<'a> {}
2018-08-26 11:09:28 +02:00
// SlicePat
#[derive(Debug, Clone)]
pub struct SlicePatNode(SyntaxNode);
impl SlicePatNode {
pub fn ast(&self) -> SlicePat {
SlicePat::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<SlicePat<'a>> for SlicePatNode {
fn from(ast: SlicePat<'a>) -> SlicePatNode {
let syntax = ast.syntax().owned();
SlicePatNode(syntax)
}
}
2018-08-26 11:09:28 +02:00
#[derive(Debug, Clone, Copy)]
pub struct SlicePat<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for SlicePat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
SLICE_PAT => Some(SlicePat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> SlicePat<'a> {}
2018-08-14 11:38:20 +02:00
// SliceType
#[derive(Debug, Clone)]
pub struct SliceTypeNode(SyntaxNode);
impl SliceTypeNode {
pub fn ast(&self) -> SliceType {
SliceType::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<SliceType<'a>> for SliceTypeNode {
fn from(ast: SliceType<'a>) -> SliceTypeNode {
let syntax = ast.syntax().owned();
SliceTypeNode(syntax)
}
}
2018-08-14 11:38:20 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct SliceType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for SliceType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
SLICE_TYPE => Some(SliceType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> SliceType<'a> {}
2018-08-14 11:38:20 +02:00
2018-08-13 17:36:16 +02:00
// StaticDef
#[derive(Debug, Clone)]
pub struct StaticDefNode(SyntaxNode);
impl StaticDefNode {
pub fn ast(&self) -> StaticDef {
StaticDef::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<StaticDef<'a>> for StaticDefNode {
fn from(ast: StaticDef<'a>) -> StaticDefNode {
let syntax = ast.syntax().owned();
StaticDefNode(syntax)
}
}
2018-08-11 10:03:22 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct StaticDef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-11 10:03:22 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for StaticDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 10:03:22 +02:00
match syntax.kind() {
2018-08-13 17:36:16 +02:00
STATIC_DEF => Some(StaticDef { syntax }),
2018-08-11 10:03:22 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 10:03:22 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> ast::NameOwner<'a> for StaticDef<'a> {}
2018-08-22 15:46:42 +02:00
impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {}
impl<'a> StaticDef<'a> {}
2018-08-11 10:03:22 +02:00
2018-08-27 09:12:28 +02:00
// Stmt
#[derive(Debug, Clone)]
pub struct StmtNode(SyntaxNode);
impl StmtNode {
pub fn ast(&self) -> Stmt {
Stmt::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Stmt<'a>> for StmtNode {
fn from(ast: Stmt<'a>) -> StmtNode {
let syntax = ast.syntax().owned();
StmtNode(syntax)
}
}
2018-08-27 09:12:28 +02:00
#[derive(Debug, Clone, Copy)]
pub enum Stmt<'a> {
ExprStmt(ExprStmt<'a>),
LetStmt(LetStmt<'a>),
}
impl<'a> AstNode<'a> for Stmt<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
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> {}
2018-08-13 17:36:16 +02:00
// StructDef
#[derive(Debug, Clone)]
pub struct StructDefNode(SyntaxNode);
impl StructDefNode {
pub fn ast(&self) -> StructDef {
StructDef::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<StructDef<'a>> for StructDefNode {
fn from(ast: StructDef<'a>) -> StructDefNode {
let syntax = ast.syntax().owned();
StructDefNode(syntax)
}
}
2018-08-11 09:56:40 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct StructDef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-11 09:56:40 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for StructDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 09:56:40 +02:00
match syntax.kind() {
2018-08-13 17:36:16 +02:00
STRUCT_DEF => Some(StructDef { syntax }),
2018-08-11 09:56:40 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 09:56:40 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> ast::NameOwner<'a> for StructDef<'a> {}
2018-08-22 15:46:42 +02:00
impl<'a> ast::TypeParamsOwner<'a> for StructDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> ast::AttrsOwner<'a> for StructDef<'a> {}
impl<'a> StructDef<'a> {
2018-08-24 18:27:30 +02:00
pub fn fields(self) -> impl Iterator<Item = NamedFieldDef<'a>> + 'a {
2018-08-22 16:01:51 +02:00
super::children(self)
2018-08-14 13:45:56 +02:00
}
}
2018-08-11 09:56:40 +02:00
2018-08-25 12:42:40 +02:00
// StructLit
#[derive(Debug, Clone)]
pub struct StructLitNode(SyntaxNode);
impl StructLitNode {
pub fn ast(&self) -> StructLit {
StructLit::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<StructLit<'a>> for StructLitNode {
fn from(ast: StructLit<'a>) -> StructLitNode {
let syntax = ast.syntax().owned();
StructLitNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct StructLit<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for StructLit<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
STRUCT_LIT => Some(StructLit { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> StructLit<'a> {}
2018-08-26 11:09:28 +02:00
// StructPat
#[derive(Debug, Clone)]
pub struct StructPatNode(SyntaxNode);
impl StructPatNode {
pub fn ast(&self) -> StructPat {
StructPat::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<StructPat<'a>> for StructPatNode {
fn from(ast: StructPat<'a>) -> StructPatNode {
let syntax = ast.syntax().owned();
StructPatNode(syntax)
}
}
2018-08-26 11:09:28 +02:00
#[derive(Debug, Clone, Copy)]
pub struct StructPat<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for StructPat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
STRUCT_PAT => Some(StructPat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> StructPat<'a> {}
2018-08-16 11:51:40 +02:00
// TokenTree
#[derive(Debug, Clone)]
pub struct TokenTreeNode(SyntaxNode);
impl TokenTreeNode {
pub fn ast(&self) -> TokenTree {
TokenTree::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<TokenTree<'a>> for TokenTreeNode {
fn from(ast: TokenTree<'a>) -> TokenTreeNode {
let syntax = ast.syntax().owned();
TokenTreeNode(syntax)
}
}
2018-08-16 11:51:40 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct TokenTree<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-16 11:51:40 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for TokenTree<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-16 11:51:40 +02:00
match syntax.kind() {
TOKEN_TREE => Some(TokenTree { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-16 11:51:40 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> TokenTree<'a> {}
2018-08-16 11:51:40 +02:00
2018-08-13 17:36:16 +02:00
// TraitDef
#[derive(Debug, Clone)]
pub struct TraitDefNode(SyntaxNode);
impl TraitDefNode {
pub fn ast(&self) -> TraitDef {
TraitDef::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<TraitDef<'a>> for TraitDefNode {
fn from(ast: TraitDef<'a>) -> TraitDefNode {
let syntax = ast.syntax().owned();
TraitDefNode(syntax)
}
}
2018-08-11 10:03:22 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct TraitDef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-11 10:03:22 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for TraitDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 10:03:22 +02:00
match syntax.kind() {
2018-08-13 17:36:16 +02:00
TRAIT_DEF => Some(TraitDef { syntax }),
2018-08-11 10:03:22 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 10:03:22 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> ast::NameOwner<'a> for TraitDef<'a> {}
impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {}
impl<'a> TraitDef<'a> {}
2018-08-11 10:03:22 +02:00
2018-08-25 12:42:40 +02:00
// TryExpr
#[derive(Debug, Clone)]
pub struct TryExprNode(SyntaxNode);
impl TryExprNode {
pub fn ast(&self) -> TryExpr {
TryExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<TryExpr<'a>> for TryExprNode {
fn from(ast: TryExpr<'a>) -> TryExprNode {
let syntax = ast.syntax().owned();
TryExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct TryExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for TryExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
TRY_EXPR => Some(TryExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> TryExpr<'a> {}
// TupleExpr
#[derive(Debug, Clone)]
pub struct TupleExprNode(SyntaxNode);
impl TupleExprNode {
pub fn ast(&self) -> TupleExpr {
TupleExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<TupleExpr<'a>> for TupleExprNode {
fn from(ast: TupleExpr<'a>) -> TupleExprNode {
let syntax = ast.syntax().owned();
TupleExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct TupleExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for TupleExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
TUPLE_EXPR => Some(TupleExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> TupleExpr<'a> {}
2018-08-26 11:09:28 +02:00
// TuplePat
#[derive(Debug, Clone)]
pub struct TuplePatNode(SyntaxNode);
impl TuplePatNode {
pub fn ast(&self) -> TuplePat {
TuplePat::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<TuplePat<'a>> for TuplePatNode {
fn from(ast: TuplePat<'a>) -> TuplePatNode {
let syntax = ast.syntax().owned();
TuplePatNode(syntax)
}
}
2018-08-26 11:09:28 +02:00
#[derive(Debug, Clone, Copy)]
pub struct TuplePat<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for TuplePat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
TUPLE_PAT => Some(TuplePat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> TuplePat<'a> {}
// TupleStructPat
#[derive(Debug, Clone)]
pub struct TupleStructPatNode(SyntaxNode);
impl TupleStructPatNode {
pub fn ast(&self) -> TupleStructPat {
TupleStructPat::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<TupleStructPat<'a>> for TupleStructPatNode {
fn from(ast: TupleStructPat<'a>) -> TupleStructPatNode {
let syntax = ast.syntax().owned();
TupleStructPatNode(syntax)
}
}
2018-08-26 11:09:28 +02:00
#[derive(Debug, Clone, Copy)]
pub struct TupleStructPat<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for TupleStructPat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
TUPLE_STRUCT_PAT => Some(TupleStructPat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> TupleStructPat<'a> {}
2018-08-14 11:38:20 +02:00
// TupleType
#[derive(Debug, Clone)]
pub struct TupleTypeNode(SyntaxNode);
impl TupleTypeNode {
pub fn ast(&self) -> TupleType {
TupleType::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<TupleType<'a>> for TupleTypeNode {
fn from(ast: TupleType<'a>) -> TupleTypeNode {
let syntax = ast.syntax().owned();
TupleTypeNode(syntax)
}
}
2018-08-14 11:38:20 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct TupleType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for TupleType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
TUPLE_TYPE => Some(TupleType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> TupleType<'a> {}
2018-08-14 11:38:20 +02:00
2018-08-13 17:36:16 +02:00
// TypeDef
#[derive(Debug, Clone)]
pub struct TypeDefNode(SyntaxNode);
impl TypeDefNode {
pub fn ast(&self) -> TypeDef {
TypeDef::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<TypeDef<'a>> for TypeDefNode {
fn from(ast: TypeDef<'a>) -> TypeDefNode {
let syntax = ast.syntax().owned();
TypeDefNode(syntax)
}
}
2018-08-11 15:20:37 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
pub struct TypeDef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-11 15:20:37 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for TypeDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 15:20:37 +02:00
match syntax.kind() {
2018-08-13 17:36:16 +02:00
TYPE_DEF => Some(TypeDef { syntax }),
2018-08-11 15:20:37 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 15:20:37 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> ast::NameOwner<'a> for TypeDef<'a> {}
2018-08-22 15:46:42 +02:00
impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {}
impl<'a> TypeDef<'a> {}
2018-08-11 15:20:37 +02:00
2018-08-22 18:02:37 +02:00
// TypeParam
#[derive(Debug, Clone)]
pub struct TypeParamNode(SyntaxNode);
impl TypeParamNode {
pub fn ast(&self) -> TypeParam {
TypeParam::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<TypeParam<'a>> for TypeParamNode {
fn from(ast: TypeParam<'a>) -> TypeParamNode {
let syntax = ast.syntax().owned();
TypeParamNode(syntax)
}
}
2018-08-22 18:02:37 +02:00
#[derive(Debug, Clone, Copy)]
pub struct TypeParam<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for TypeParam<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
TYPE_PARAM => Some(TypeParam { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> ast::NameOwner<'a> for TypeParam<'a> {}
impl<'a> TypeParam<'a> {}
2018-08-22 15:46:42 +02:00
// TypeParamList
#[derive(Debug, Clone)]
pub struct TypeParamListNode(SyntaxNode);
impl TypeParamListNode {
pub fn ast(&self) -> TypeParamList {
TypeParamList::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<TypeParamList<'a>> for TypeParamListNode {
fn from(ast: TypeParamList<'a>) -> TypeParamListNode {
let syntax = ast.syntax().owned();
TypeParamListNode(syntax)
}
}
2018-08-22 15:46:42 +02:00
#[derive(Debug, Clone, Copy)]
pub struct TypeParamList<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for TypeParamList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
TYPE_PARAM_LIST => Some(TypeParamList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-08-22 18:02:37 +02:00
impl<'a> TypeParamList<'a> {
pub fn type_params(self) -> impl Iterator<Item = TypeParam<'a>> + 'a {
super::children(self)
}
2018-08-28 22:59:57 +02:00
pub fn lifetime_params(self) -> impl Iterator<Item = LifetimeParam<'a>> + 'a {
super::children(self)
}
2018-08-22 18:02:37 +02:00
}
2018-08-22 15:46:42 +02:00
2018-08-14 11:38:20 +02:00
// TypeRef
#[derive(Debug, Clone)]
pub struct TypeRefNode(SyntaxNode);
impl TypeRefNode {
pub fn ast(&self) -> TypeRef {
TypeRef::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<TypeRef<'a>> for TypeRefNode {
fn from(ast: TypeRef<'a>) -> TypeRefNode {
let syntax = ast.syntax().owned();
TypeRefNode(syntax)
}
}
2018-08-14 11:38:20 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-17 21:00:13 +02:00
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<Self> {
2018-08-14 11:38:20 +02:00
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,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> {
2018-08-14 11:38:20 +02:00
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(),
}
}
}
2018-08-17 21:00:13 +02:00
impl<'a> TypeRef<'a> {}
2018-08-14 11:38:20 +02:00
2018-08-28 10:12:42 +02:00
// UseItem
#[derive(Debug, Clone)]
pub struct UseItemNode(SyntaxNode);
impl UseItemNode {
pub fn ast(&self) -> UseItem {
UseItem::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<UseItem<'a>> for UseItemNode {
fn from(ast: UseItem<'a>) -> UseItemNode {
let syntax = ast.syntax().owned();
UseItemNode(syntax)
}
}
2018-08-28 10:12:42 +02:00
#[derive(Debug, Clone, Copy)]
pub struct UseItem<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for UseItem<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
USE_ITEM => Some(UseItem { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> UseItem<'a> {
pub fn use_tree(self) -> Option<UseTree<'a>> {
2018-08-30 19:37:33 +02:00
super::child_opt(self)
}
}
// UseTree
#[derive(Debug, Clone)]
pub struct UseTreeNode(SyntaxNode);
impl UseTreeNode {
pub fn ast(&self) -> UseTree {
UseTree::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<UseTree<'a>> for UseTreeNode {
fn from(ast: UseTree<'a>) -> UseTreeNode {
let syntax = ast.syntax().owned();
UseTreeNode(syntax)
}
}
2018-08-30 19:37:33 +02:00
#[derive(Debug, Clone, Copy)]
pub struct UseTree<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for UseTree<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
USE_TREE => Some(UseTree { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> UseTree<'a> {
pub fn path(self) -> Option<Path<'a>> {
2018-08-30 19:37:33 +02:00
super::child_opt(self)
}
pub fn use_tree_list(self) -> Option<UseTreeList<'a>> {
2018-08-30 19:37:33 +02:00
super::child_opt(self)
}
}
// UseTreeList
#[derive(Debug, Clone)]
pub struct UseTreeListNode(SyntaxNode);
impl UseTreeListNode {
pub fn ast(&self) -> UseTreeList {
UseTreeList::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<UseTreeList<'a>> for UseTreeListNode {
fn from(ast: UseTreeList<'a>) -> UseTreeListNode {
let syntax = ast.syntax().owned();
UseTreeListNode(syntax)
}
}
2018-08-30 19:37:33 +02:00
#[derive(Debug, Clone, Copy)]
pub struct UseTreeList<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for UseTreeList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
USE_TREE_LIST => Some(UseTreeList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> UseTreeList<'a> {
pub fn use_trees(self) -> impl Iterator<Item = UseTree<'a>> + 'a {
super::children(self)
}
}
2018-08-28 10:12:42 +02:00
2018-08-22 15:46:42 +02:00
// WhereClause
#[derive(Debug, Clone)]
pub struct WhereClauseNode(SyntaxNode);
impl WhereClauseNode {
pub fn ast(&self) -> WhereClause {
WhereClause::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<WhereClause<'a>> for WhereClauseNode {
fn from(ast: WhereClause<'a>) -> WhereClauseNode {
let syntax = ast.syntax().owned();
WhereClauseNode(syntax)
}
}
2018-08-22 10:56:36 +02:00
#[derive(Debug, Clone, Copy)]
2018-08-22 15:46:42 +02:00
pub struct WhereClause<'a> {
2018-08-22 10:56:36 +02:00
syntax: SyntaxNodeRef<'a>,
}
2018-08-22 15:46:42 +02:00
impl<'a> AstNode<'a> for WhereClause<'a> {
2018-08-22 10:56:36 +02:00
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
2018-08-22 15:46:42 +02:00
WHERE_CLAUSE => Some(WhereClause { syntax }),
2018-08-22 10:56:36 +02:00
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-08-22 15:46:42 +02:00
impl<'a> WhereClause<'a> {}
2018-08-22 10:56:36 +02:00
2018-08-25 12:42:40 +02:00
// WhileExpr
#[derive(Debug, Clone)]
pub struct WhileExprNode(SyntaxNode);
impl WhileExprNode {
pub fn ast(&self) -> WhileExpr {
WhileExpr::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<WhileExpr<'a>> for WhileExprNode {
fn from(ast: WhileExpr<'a>) -> WhileExprNode {
let syntax = ast.syntax().owned();
WhileExprNode(syntax)
}
}
2018-08-25 12:42:40 +02:00
#[derive(Debug, Clone, Copy)]
pub struct WhileExpr<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for WhileExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
WHILE_EXPR => Some(WhileExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-08-30 20:32:12 +02:00
impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {}
impl<'a> WhileExpr<'a> {
pub fn condition(self) -> Option<Condition<'a>> {
2018-08-27 11:22:09 +02:00
super::child_opt(self)
}
}
2018-08-25 12:42:40 +02:00
// Whitespace
#[derive(Debug, Clone)]
pub struct WhitespaceNode(SyntaxNode);
impl WhitespaceNode {
pub fn ast(&self) -> Whitespace {
Whitespace::cast(self.0.borrowed()).unwrap()
}
}
2018-11-01 11:41:04 +01:00
impl<'a> From<Whitespace<'a>> for WhitespaceNode {
fn from(ast: Whitespace<'a>) -> WhitespaceNode {
let syntax = ast.syntax().owned();
WhitespaceNode(syntax)
}
}
#[derive(Debug, Clone, Copy)]
pub struct Whitespace<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for Whitespace<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
WHITESPACE => Some(Whitespace { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> Whitespace<'a> {}