pub enum ExprKind {
Show 26 variants
Int(i64),
Float(f64),
Bool(bool),
Duration(i64),
Str(Vec<StrPart>),
Unit,
Ident(String),
ArrayLit(Vec<Expr>),
Field {
base: Box<Expr>,
name: Ident,
},
Call {
callee: Box<Expr>,
generics: Vec<Type>,
args: Vec<Arg>,
trailing: Option<Box<Expr>>,
},
Unary {
op: UnaryOp,
operand: Box<Expr>,
},
Binary {
op: BinaryOp,
lhs: Box<Expr>,
rhs: Box<Expr>,
},
Assign {
op: Option<BinaryOp>,
target: Box<Expr>,
value: Box<Expr>,
},
Try(Box<Expr>),
Await(Box<Expr>),
Block(Block),
If {
condition: Box<Expr>,
then_branch: Block,
else_branch: Option<Box<Expr>>,
},
Match {
scrutinee: Box<Expr>,
arms: Vec<MatchArm>,
},
For {
binding: Ident,
iterable: Box<Expr>,
body: Block,
},
While {
condition: Box<Expr>,
body: Block,
},
Return(Option<Box<Expr>>),
Break(Option<Box<Expr>>),
Continue,
Lambda {
is_async: bool,
params: Vec<Param>,
body: Block,
},
Scope {
name: Ident,
body: Block,
},
Range {
start: Box<Expr>,
end: Box<Expr>,
inclusive_end: bool,
},
}Variants§
Int(i64)
Float(f64)
Bool(bool)
Duration(i64)
Str(Vec<StrPart>)
A string literal with its interpolated expressions already parsed.
Unit
()
Ident(String)
A bare name.
ArrayLit(Vec<Expr>)
[1, 2] produces an immutable Array.
Field
console.println, LogLevel.Debug, self.status
Call
f(a, b: c); also struct initialization via synthesized labeled calls.
Fields
Unary
Binary
Assign
place = value, place += value
Try(Box<Expr>)
expr? returns the error from the current function.
Await(Box<Expr>)
Block(Block)
If
Match
match must cover every enum case.
For
A loop is an expression. It evaluates to Unit, because it can
reach its end without breaking and there is nothing at that end to
produce but Unit.
While
Return(Option<Box<Expr>>)
Break(Option<Box<Expr>>)
break / break expr. Exits the nearest enclosing loop, which is
Unit however it leaves: expr is evaluated for its effects and its
value discarded. Resolve rejects a break outside a loop.
Continue
continue. Skips to the next iteration of the nearest enclosing loop.
Resolve rejects this outside a loop.
Lambda
fn(x) { ... } / async fn(x) { ... }
Scope
scope tasks { ... }
Range
0..<attempts and 0..n