pub enum Stmt {
Show 22 variants
Local {
ty: Option<Type>,
binding: Binding,
value: Option<Expr>,
mutable: bool,
},
Assign {
place: Expr,
op: Option<BinOp>,
value: Expr,
},
If {
cond: Expr,
then: Box<Stmt>,
otherwise: Option<Box<Stmt>>,
},
Foreach {
ty: Option<Type>,
binding: Binding,
iter: Expr,
body: Box<Stmt>,
mutable: bool,
awaits: bool,
},
For {
init: Option<Box<Stmt>>,
cond: Option<Expr>,
step: Option<Box<Stmt>>,
body: Box<Stmt>,
},
While {
cond: Expr,
body: Box<Stmt>,
},
DoWhile {
body: Box<Stmt>,
cond: Expr,
},
Block(Block),
Label(Name),
Goto(Goto, Span),
Break(Span),
Continue(Span),
Return(Option<Expr>, Span),
Skip(Option<Expr>, Span),
Yield(Option<Expr>, Span),
Unsafe(Block, Span),
Checked(Block, bool),
Switch {
expr: Expr,
sections: Vec<Section>,
},
Function(Box<Decl>),
Lock {
target: Expr,
value: Option<Name>,
body: Box<Stmt>,
at: Span,
},
Expr(Expr),
Value(Expr),
}Variants§
Local
let x = …;, let mut x = …;, i32 x;,
let (a, b) = …;; ty None: its value’s.
Fields
Assign
place op= value;; op None for =.
If
Foreach
Fields
For
While
DoWhile
Block(Block)
Label(Name)
name: (C#’s label): where a goto name; in its block (or one
inside it) goes on from.
Goto(Goto, Span)
goto name;, goto case value;, goto default;.
Break(Span)
Continue(Span)
Return(Option<Expr>, Span)
Skip(Option<Expr>, Span)
skip value; in a patch’s before: the method ends with it.
Yield(Option<Expr>, Span)
yield return value; (Some) or yield break; (None), in an
iterator.
Unsafe(Block, Span)
unsafe { … }: the threads checks skipped inside (a warning).
Checked(Block, bool)
checked { … } (checked) or unchecked { … }: the block’s
whole-number arithmetic panicking on overflow, or wrapping.
Switch
switch (expr) { case p when g: … break; default: … } (C#’s
statement): the first section a label of takes the value runs; its
break leaves the switch.
Function(Box<Decl>)
A local function (C#’s): a method declared in a block, reaching the block’s locals, called anywhere in it (before it too).
Lock
lock (target) body or lock (target, ref let value) body: a
Lock<T> held for body, its value lent as value.
Expr(Expr)
Value(Expr)
A block lambda’s last expression, without ;: its value.
Implementations§
Source§impl Stmt
impl Stmt
Sourcepub fn inner(&self) -> Vec<&Stmt>
pub fn inner(&self) -> Vec<&Stmt>
The statements directly inside it (a local function’s aside: its own code).
Sourcepub fn any_inside(
&self,
found: &dyn Fn(&Stmt) -> bool,
enter: &dyn Fn(&Stmt) -> bool,
) -> bool
pub fn any_inside( &self, found: &dyn Fn(&Stmt) -> bool, enter: &dyn Fn(&Stmt) -> bool, ) -> bool
Whether it or a statement inside it is found (looking into a
statement only when enter lets it).
Sourcepub fn has_labels(&self) -> bool
pub fn has_labels(&self) -> bool
Whether a label is in it: a goto may jump there.
Sourcepub fn goes_to_case(&self) -> bool
pub fn goes_to_case(&self) -> bool
Whether a goto case or goto default of the switch it’s in is
in it (not one of a switch inside it).