pub enum ExprKind {
Show 31 variants
Int(u64),
Float(f64),
Str(String),
FStr(Vec<FStrPart>),
Bool(bool),
Unit,
Name(Ident),
SelfValue,
SelfType,
Paren(Box<Expr>),
List(Vec<Expr>),
Map(Vec<(Expr, Expr)>),
StructLit {
path: Path,
type_args: Vec<Ty>,
fields: Vec<FieldInit>,
base: Option<Box<Expr>>,
},
Field {
base: Box<Expr>,
name: Ident,
},
TypeArgs {
base: Box<Expr>,
args: Vec<Ty>,
},
Call {
callee: Box<Expr>,
args: Vec<Arg>,
},
Index {
base: Box<Expr>,
index: Box<Expr>,
},
Slice {
base: Box<Expr>,
start: Option<Box<Expr>>,
end: Option<Box<Expr>>,
inclusive: bool,
},
Try(Box<Expr>),
Unary {
op: UnaryOp,
operand: Box<Expr>,
},
Binary {
op: BinaryOp,
lhs: Box<Expr>,
rhs: Box<Expr>,
},
Closure {
params: Vec<ClosureParam>,
ret: Option<Ty>,
body: Box<Expr>,
},
Block(Block),
If {
cond: Box<Expr>,
then: Block,
otherwise: Option<Box<Expr>>,
},
IfLet {
items: Vec<CondItem>,
then: Block,
otherwise: Option<Box<Expr>>,
},
Loop {
label: Option<Ident>,
body: Block,
},
Match {
mode: Mode,
scrutinee: Box<Expr>,
arms: Vec<Arm>,
},
Return(Option<Box<Expr>>),
Break {
label: Option<Ident>,
value: Option<Box<Expr>>,
},
Continue {
label: Option<Ident>,
},
Error,
}Expand description
The forms of expressions.
Variants§
Int(u64)
An integer literal.
Float(f64)
A float literal.
Str(String)
A string literal.
FStr(Vec<FStrPart>)
An interpolated string f"..." (0.2).
Bool(bool)
true or false.
Unit
()
Name(Ident)
A name.
SelfValue
self
SelfType
Self
Paren(Box<Expr>)
(e)
List(Vec<Expr>)
[a, b]
Map(Vec<(Expr, Expr)>)
["a": 1], [:]
StructLit
Path.<T> { field: value, shorthand, ..base }
Fields
Field
base.name
TypeArgs
base.<T, U>
Call
callee(args)
Index
base[index]
Slice
base[a..b] and the other slice forms.
Fields
Try(Box<Expr>)
e?
Unary
-e, !e, ~e
Binary
a op b
Closure
|x, y: Int| body or |x| -> T { body }.
Fields
params: Vec<ClosureParam>The parameters.
Block(Block)
{ ... } as the body of a closure or a match arm.
If
if cond { } else ...
Fields
IfLet
if let pattern = mode? value { } else ... (0.2), or a chain of conditions with a let
among them (spec chapter 3, section 5, rule 14a).
Fields
Loop
label: loop { body } (0.2).
Match
match mode? scrutinee { arms }
Return(Option<Box<Expr>>)
return e?
Break
break, break label, break value. The parser takes a name after break as a label
when an enclosing loop has that label.
Fields
Continue
continue, continue label.
Error
Something that could not be parsed; a diagnostic was reported.