pub enum Statement {
Declare {
final_: bool,
type_: Type,
name: Ident,
value: Option<Expr>,
},
Expr(Expr),
Return(Option<Expr>),
If {
condition: Expr,
then: Block,
otherwise: Option<Block>,
},
ForEach {
type_: Type,
binding: Ident,
range: Expr,
body: Block,
},
For {
init: Box<Statement>,
condition: Expr,
step: Expr,
body: Block,
},
While {
condition: Expr,
body: Block,
},
Break,
Switch {
value: Expr,
cases: Vec<SwitchCase>,
},
Throw(Expr),
Comment(Doc),
}Expand description
One statement.
Variants§
Declare
A local declaration.
Fields
Expr(Expr)
An expression followed by ;.
Return(Option<Expr>)
return expr;
If
if (cond) { .. } else { .. }
ForEach
for (T name : range) { .. }
Fields
For
for (init; cond; step) { .. }
Not Statement::ForEach. A generated codec walks a collection
by index because the index is what the wire needs — an element’s
position decides its alignment and, in a map written in
ascending key order, which entry is written at all. A for-each
hands the element and hides the position.
Fields
While
while (cond) { .. }
Not a for with the two clauses left empty. A decoder walks a
@mutable aggregate’s headers until the delimiter is used up and
a PL_CDR1 list until its sentinel; neither has a counter, and
writing one as for (; cond;) says there was an induction
variable somebody forgot.
Break
break;
A PL_CDR1 parameter list ends at PID_LIST_END and not at a
count, so the loop leaves from the middle.
Switch
switch (value) { case ..: }
Throw(Expr)
throw expr;
Comment(Doc)
A comment on its own line.