syntax::ast

Trait AstNode

source
pub trait AstNode {
    // Required methods
    fn can_cast(kind: SyntaxKind) -> bool
       where Self: Sized;
    fn cast(syntax: SyntaxNode) -> Option<Self>
       where Self: Sized;
    fn syntax(&self) -> &SyntaxNode;

    // Provided methods
    fn clone_for_update(&self) -> Self
       where Self: Sized { ... }
    fn clone_subtree(&self) -> Self
       where Self: Sized { ... }
}
Expand description

The main trait to go from untyped SyntaxNode to a typed ast. The conversion itself has zero runtime cost: ast and syntax nodes have exactly the same representation: a pointer to the tree root and a pointer to the node itself.

Required Methods§

source

fn can_cast(kind: SyntaxKind) -> bool
where Self: Sized,

source

fn cast(syntax: SyntaxNode) -> Option<Self>
where Self: Sized,

source

fn syntax(&self) -> &SyntaxNode

Provided Methods§

source

fn clone_for_update(&self) -> Self
where Self: Sized,

source

fn clone_subtree(&self) -> Self
where Self: Sized,

Implementations on Foreign Types§

source§

impl<L, R> AstNode for Either<L, R>
where L: AstNode, R: AstNode,

source§

fn can_cast(kind: SyntaxKind) -> bool
where Self: Sized,

source§

fn cast(syntax: SyntaxNode) -> Option<Self>
where Self: Sized,

source§

fn syntax(&self) -> &SyntaxNode

Implementors§

source§

impl AstNode for Adt

source§

impl AstNode for AsmOperand

source§

impl AstNode for AsmPiece

source§

impl AstNode for AssocItem

source§

impl AstNode for CallableExpr

source§

impl AstNode for Expr

source§

impl AstNode for ExternItem

source§

impl AstNode for FieldList

source§

impl AstNode for GenericArg

source§

impl AstNode for GenericParam

source§

impl AstNode for Item

source§

impl AstNode for Macro

source§

impl AstNode for NameLike

source§

impl AstNode for NameOrNameRef

source§

impl AstNode for Pat

source§

impl AstNode for Stmt

source§

impl AstNode for TraitOrAlias

source§

impl AstNode for Type

source§

impl AstNode for TypeOrConstParam

source§

impl AstNode for UseBoundGenericArg

source§

impl AstNode for Abi

source§

impl AstNode for AnyHasArgList

source§

impl AstNode for AnyHasAttrs

source§

impl AstNode for AnyHasDocComments

source§

impl AstNode for AnyHasGenericArgs

source§

impl AstNode for AnyHasGenericParams

source§

impl AstNode for AnyHasLoopBody

source§

impl AstNode for AnyHasModuleItem

source§

impl AstNode for AnyHasName

source§

impl AstNode for AnyHasTypeBounds

source§

impl AstNode for AnyHasVisibility

source§

impl AstNode for ArgList

source§

impl AstNode for ArrayExpr

source§

impl AstNode for ArrayType

source§

impl AstNode for AsmClobberAbi

source§

impl AstNode for AsmConst

source§

impl AstNode for AsmDirSpec

source§

impl AstNode for AsmExpr

source§

impl AstNode for AsmLabel

source§

impl AstNode for AsmOperandExpr

source§

impl AstNode for AsmOperandNamed

source§

impl AstNode for AsmOption

source§

impl AstNode for AsmOptions

source§

impl AstNode for AsmRegOperand

source§

impl AstNode for AsmRegSpec

source§

impl AstNode for AsmSym

source§

impl AstNode for AssocItemList

source§

impl AstNode for AssocTypeArg

source§

impl AstNode for Attr

source§

impl AstNode for AwaitExpr

source§

impl AstNode for BecomeExpr

source§

impl AstNode for BinExpr

source§

impl AstNode for BlockExpr

source§

impl AstNode for BoxPat

source§

impl AstNode for BreakExpr

source§

impl AstNode for CallExpr

source§

impl AstNode for CastExpr

source§

impl AstNode for ClosureBinder

source§

impl AstNode for ClosureExpr

source§

impl AstNode for Const

source§

impl AstNode for ConstArg

source§

impl AstNode for ConstBlockPat

source§

impl AstNode for ConstParam

source§

impl AstNode for ContinueExpr

source§

impl AstNode for DynTraitType

source§

impl AstNode for Enum

source§

impl AstNode for ExprStmt

source§

impl AstNode for ExternBlock

source§

impl AstNode for ExternCrate

source§

impl AstNode for ExternItemList

source§

impl AstNode for FieldExpr

source§

impl AstNode for Fn

source§

impl AstNode for FnPtrType

source§

impl AstNode for ForExpr

source§

impl AstNode for ForType

source§

impl AstNode for FormatArgsArg

source§

impl AstNode for FormatArgsExpr

source§

impl AstNode for GenericArgList

source§

impl AstNode for GenericParamList

source§

impl AstNode for IdentPat

source§

impl AstNode for IfExpr

source§

impl AstNode for Impl

source§

impl AstNode for ImplTraitType

source§

impl AstNode for IndexExpr

source§

impl AstNode for InferType

source§

impl AstNode for ItemList

source§

impl AstNode for Label

source§

impl AstNode for LetElse

source§

impl AstNode for LetExpr

source§

impl AstNode for LetStmt

source§

impl AstNode for Lifetime

source§

impl AstNode for LifetimeArg

source§

impl AstNode for LifetimeParam

source§

impl AstNode for Literal

source§

impl AstNode for LiteralPat

source§

impl AstNode for LoopExpr

source§

impl AstNode for MacroCall

source§

impl AstNode for MacroDef

source§

impl AstNode for MacroExpr

source§

impl AstNode for MacroItems

source§

impl AstNode for MacroPat

source§

impl AstNode for MacroRules

source§

impl AstNode for MacroStmts

source§

impl AstNode for MacroType

source§

impl AstNode for MatchArm

source§

impl AstNode for MatchArmList

source§

impl AstNode for MatchExpr

source§

impl AstNode for MatchGuard

source§

impl AstNode for Meta

source§

impl AstNode for MethodCallExpr

source§

impl AstNode for Module

source§

impl AstNode for Name

source§

impl AstNode for NameRef

source§

impl AstNode for NeverType

source§

impl AstNode for OffsetOfExpr

source§

impl AstNode for OrPat

source§

impl AstNode for Param

source§

impl AstNode for ParamList

source§

impl AstNode for ParenExpr

source§

impl AstNode for ParenPat

source§

impl AstNode for ParenType

source§

impl AstNode for ParenthesizedArgList

source§

impl AstNode for Path

source§

impl AstNode for PathExpr

source§

impl AstNode for PathPat

source§

impl AstNode for PathSegment

source§

impl AstNode for PathType

source§

impl AstNode for PrefixExpr

source§

impl AstNode for PtrType

source§

impl AstNode for RangeExpr

source§

impl AstNode for RangePat

source§

impl AstNode for RecordExpr

source§

impl AstNode for RecordExprField

source§

impl AstNode for RecordExprFieldList

source§

impl AstNode for RecordField

source§

impl AstNode for RecordFieldList

source§

impl AstNode for RecordPat

source§

impl AstNode for RecordPatField

source§

impl AstNode for RecordPatFieldList

source§

impl AstNode for RefExpr

source§

impl AstNode for RefPat

source§

impl AstNode for RefType

source§

impl AstNode for Rename

source§

impl AstNode for RestPat

source§

impl AstNode for RetType

source§

impl AstNode for ReturnExpr

source§

impl AstNode for ReturnTypeSyntax

source§

impl AstNode for SelfParam

source§

impl AstNode for SlicePat

source§

impl AstNode for SliceType

source§

impl AstNode for SourceFile

source§

impl AstNode for Static

source§

impl AstNode for StmtList

source§

impl AstNode for Struct

source§

impl AstNode for TokenTree

source§

impl AstNode for Trait

source§

impl AstNode for TraitAlias

source§

impl AstNode for TryExpr

source§

impl AstNode for TupleExpr

source§

impl AstNode for TupleField

source§

impl AstNode for TupleFieldList

source§

impl AstNode for TuplePat

source§

impl AstNode for TupleStructPat

source§

impl AstNode for TupleType

source§

impl AstNode for TypeAlias

source§

impl AstNode for TypeArg

source§

impl AstNode for TypeBound

source§

impl AstNode for TypeBoundList

source§

impl AstNode for TypeParam

source§

impl AstNode for UnderscoreExpr

source§

impl AstNode for Union

source§

impl AstNode for Use

source§

impl AstNode for UseBoundGenericArgs

source§

impl AstNode for UseTree

source§

impl AstNode for UseTreeList

source§

impl AstNode for Variant

source§

impl AstNode for VariantList

source§

impl AstNode for Visibility

source§

impl AstNode for WhereClause

source§

impl AstNode for WherePred

source§

impl AstNode for WhileExpr

source§

impl AstNode for WildcardPat

source§

impl AstNode for YeetExpr

source§

impl AstNode for YieldExpr