#[non_exhaustive]pub enum Stmt {
Show 17 variants
Noop(Position),
If(Box<FlowControl>, Position),
Switch(Box<(Expr, SwitchCasesCollection)>, Position),
While(Box<FlowControl>, Position),
Do(Box<FlowControl>, ASTFlags, Position),
For(Box<(Ident, Option<Ident>, FlowControl)>, Position),
Var(Box<(Ident, Expr, Option<NonZeroUsize>)>, ASTFlags, Position),
Assignment(Box<(OpAssignment, BinaryExpr)>),
FnCall(Box<FnCallExpr>, Position),
Block(Box<StmtBlock>),
TryCatch(Box<FlowControl>, Position),
Expr(Box<Expr>),
BreakLoop(Option<Box<Expr>>, ASTFlags, Position),
Return(Option<Box<Expr>>, ASTFlags, Position),
Import(Box<(Expr, Ident)>, Position),
Export(Box<(Ident, Ident)>, Position),
Share(Box<SmallVec<[(Ident, Option<NonZeroUsize>); 5]>>),
}Expand description
(internals) A statement.
Exported under the internals feature only.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Noop(Position)
No-op.
If(Box<FlowControl>, Position)
if expr { stmt } else { stmt }
Switch(Box<(Expr, SwitchCasesCollection)>, Position)
switch expr { literal or range or _ if condition => stmt , … }
Data Structure
- Hash table for (condition, block)
- Default block
- List of ranges: (start, end, inclusive, condition, statement)
While(Box<FlowControl>, Position)
while expr { stmt } | loop { stmt }
If the guard expression is UNIT, then it is a loop statement.
Do(Box<FlowControl>, ASTFlags, Position)
For(Box<(Ident, Option<Ident>, FlowControl)>, Position)
for ( id , counter ) in expr { stmt }
Var(Box<(Ident, Expr, Option<NonZeroUsize>)>, ASTFlags, Position)
Assignment(Box<(OpAssignment, BinaryExpr)>)
expr op= expr
FnCall(Box<FnCallExpr>, Position)
func ( expr , … )
This is a duplicate of Expr::FnCall to cover the very common pattern of a single
function call forming one statement.
Block(Box<StmtBlock>)
{ stmt; … }
TryCatch(Box<FlowControl>, Position)
try { stmt; … } catch ( var ) { stmt; … }
Expr(Box<Expr>)
BreakLoop(Option<Box<Expr>>, ASTFlags, Position)
Return(Option<Box<Expr>>, ASTFlags, Position)
Import(Box<(Expr, Ident)>, Position)
import expr as alias
Not available under no_module.
Export(Box<(Ident, Ident)>, Position)
export var as alias
Not available under no_module.
Convert a list of variables to shared.
Not available under no_closure.
Notes
This variant does not map to any language structure. It is currently only used only to convert normal variables into shared variables when they are captured by a closure.
Implementations§
source§impl Stmt
impl Stmt
sourcepub fn set_position(&mut self, new_pos: Position) -> &mut Self
pub fn set_position(&mut self, new_pos: Position) -> &mut Self
Override the position of this statement.
sourcepub const fn returns_value(&self) -> bool
pub const fn returns_value(&self) -> bool
Does this statement return a value?
sourcepub const fn is_self_terminated(&self) -> bool
pub const fn is_self_terminated(&self) -> bool
Is this statement self-terminated (i.e. no need for a semicolon terminator)?
sourcepub fn is_block_dependent(&self) -> bool
pub fn is_block_dependent(&self) -> bool
Does this statement’s behavior depend on its containing block?
A statement that depends on its containing block behaves differently when promoted to an upper block.
Currently only variable definitions (i.e. let and const), import/export statements,
and eval calls (which may in turn define variables) fall under this category.
sourcepub fn is_internally_pure(&self) -> bool
pub fn is_internally_pure(&self) -> bool
Is this statement pure within the containing block?
An internally pure statement only has side effects that disappear outside the block.
Currently only variable definitions (i.e. let and const) and import/export
statements are internally pure, other than pure expressions.
sourcepub const fn is_control_flow_break(&self) -> bool
pub const fn is_control_flow_break(&self) -> bool
Does this statement break the current control flow through the containing block?
Currently this is only true for return, throw, break and continue.
All statements following this statement will essentially be dead code.
sourcepub fn take(&mut self) -> Self
pub fn take(&mut self) -> Self
Return this Stmt, replacing it with Stmt::Noop.
Trait Implementations§
source§impl Extend<Stmt> for StmtBlock
impl Extend<Stmt> for StmtBlock
source§fn extend<T: IntoIterator<Item = Stmt>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Stmt>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Auto Trait Implementations§
impl !RefUnwindSafe for Stmt
impl !Send for Stmt
impl !Sync for Stmt
impl Unpin for Stmt
impl !UnwindSafe for Stmt
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Variant for Twhere
T: Any + Clone + SendSync,
impl<T> Variant for Twhere T: Any + Clone + SendSync,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Variant trait object to &mut dyn Any.source§fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
Variant trait object to Box<dyn Any>.