#[non_exhaustive]
pub enum Stmt {
Show 17 variants Noop(Position), If(Box<(Expr, StmtBlock, StmtBlock)>, Position), Switch(Box<(Expr, SwitchCasesCollection)>, Position), While(Box<(Expr, StmtBlock)>, Position), Do(Box<(Expr, StmtBlock)>, ASTFlagsPosition), For(Box<(Ident, Ident, Expr, StmtBlock)>, Position), Var(Box<(Ident, Expr, Option<NonZeroUsize>)>, ASTFlagsPosition), Assignment(Box<(OpAssignment, BinaryExpr)>), FnCall(Box<FnCallExpr>, Position), Block(Box<StmtBlock>), TryCatch(Box<TryCatchBlock>, Position), Expr(Box<Expr>), BreakLoop(ASTFlagsPosition), Return(Option<Box<Expr>>, ASTFlagsPosition), Import(Box<(Expr, Ident)>, Position), Export(Box<(Ident, Ident)>, Position), Share(ImmutableStringPosition),
}
Expand description

(internals) A statement. Exported under the internals feature only.

Variants (Non-exhaustive)

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.

Noop(Position)

No-op.

If(Box<(Expr, StmtBlock, StmtBlock)>, Position)

if expr { stmt } else { stmt }

Switch(Box<(Expr, SwitchCasesCollection)>, Position)

switch expr { literal or range or _ if condition => stmt ,}

Data Structure
  1. Hash table for (condition, block)
  2. Default block
  3. List of ranges: (start, end, inclusive, condition, statement)

While(Box<(Expr, StmtBlock)>, Position)

while expr { stmt } | loop { stmt }

If the guard expression is UNIT, then it is a loop statement.

Do(Box<(Expr, StmtBlock)>, ASTFlagsPosition)

do { stmt } while|until expr

Flags

For(Box<(Ident, Ident, Expr, StmtBlock)>, Position)

for ( id , counter ) in expr { stmt }

Var(Box<(Ident, Expr, Option<NonZeroUsize>)>, ASTFlagsPosition)

[export] let|const id = expr

Flags

Assignment(Box<(OpAssignment, BinaryExpr)>)

expr op= expr

FnCall(Box<FnCallExpr>, Position)

func ( expr ,)

Note - 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<TryCatchBlock>, Position)

try { stmt; … } catch ( var ) { stmt; … }

Expr(Box<Expr>)

BreakLoop(ASTFlagsPosition)

continue/break

Flags

Return(Option<Box<Expr>>, ASTFlagsPosition)

return/throw

Flags

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.

Share(ImmutableStringPosition)

Convert a variable 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 a normal variable into a shared variable when the variable is captured by a closure.

Implementations

Is this statement Noop?

Get the position of this statement.

Override the position of this statement.

Does this statement return a value?

Is this statement self-terminated (i.e. no need for a semicolon terminator)?

Is this statement pure?

A pure statement has no side effects.

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.

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.

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.

Recursively walk this statement. Return false from the callback to terminate the walk.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Extends a collection with the contents of an iterator. Read more

🔬This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

🔬This is a nightly-only experimental API. (extend_one)

Reserves capacity in a collection for the given number of additional elements. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.