pub enum Expr {
Show 20 variants
Literal(Literal),
Variable(VariableExpr),
Reference(ReferenceExpr),
Dict(Dict),
List(List),
Tuple(Tuple),
Spread(SpreadExpr),
Comprehension(Comprehension),
Binary(BinaryExpr),
Unary(UnaryExpr),
Ternary(TernaryExpr),
Call(CallExpr),
FString(FString),
Type(TypeNode),
Wildcard(Wildcard),
Where(WhereExpr),
Match(MatchExpr),
Closure(Closure),
VariantCtor(VariantCtor),
Error(ErrorNode),
}Expand description
Typed view over any expression-shaped CST node. Returned by
Expr::cast.
Note the variant naming follows the CST kinds, not the legacy
crate::Expr enum — Literal covers true / false / numeric / string atoms uniformly,
plus the removed null spelling for diagnostics. The legacy enum split
them into Bool / Int / Float / String plus internal Missing. Downstream
callers that need the specific literal type read it from
Literal::kind / Literal::value_text.
Variants§
Literal(Literal)
Variable(VariableExpr)
Reference(ReferenceExpr)
Dict(Dict)
List(List)
Tuple(Tuple)
Spread(SpreadExpr)
Comprehension(Comprehension)
Binary(BinaryExpr)
Unary(UnaryExpr)
Ternary(TernaryExpr)
Call(CallExpr)
FString(FString)
Type(TypeNode)
Wildcard(Wildcard)
Where(WhereExpr)
Match(MatchExpr)
Closure(Closure)
VariantCtor(VariantCtor)
Error(ErrorNode)
New variant introduced by the CST rewrite — spans bytes the parser couldn’t fit into any production. Downstream callers must handle it (typically by skipping or surfacing a diagnostic).
Implementations§
Source§impl Expr
impl Expr
Sourcepub fn cast(node: SyntaxNode) -> Option<Self>
pub fn cast(node: SyntaxNode) -> Option<Self>
Wrap node if it names an expression-shaped CST kind.
Returns None for non-expression nodes (DICT_FIELD,
CLOSURE_PARAM, etc.) — those have their own typed wrappers.
Sourcepub fn syntax(&self) -> &SyntaxNode
pub fn syntax(&self) -> &SyntaxNode
Borrow the underlying SyntaxNode regardless of variant.