#[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<NonZero<usize>>)>, 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<NonZero<usize>>); 5]>>),
}rhai only.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<NonZero<usize>>)>, 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)
no_module only.import expr as alias
Not available under no_module.
Export(Box<(Ident, Ident)>, Position)
no_module only.export var as alias
Not available under no_module.
no_closure only.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 Stmt
pub fn set_position(&mut self, new_pos: Position) -> &mut Stmt
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) -> Stmt
pub fn take(&mut self) -> Stmt
Return this Stmt, replacing it with Stmt::Noop.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Stmt
impl !UnwindSafe for Stmt
impl Freeze for Stmt
impl Send for Stmt
impl Sync for Stmt
impl Unpin for Stmt
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
map-response-body only.Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
trace only.Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
trace only.Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
follow-redirect only.Source§impl<T> Variant for T
impl<T> Variant for T
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>.