Enum rhai::Stmt[][src]

pub enum Stmt {
Show 18 variants Noop(Position), If(ExprBox<(StmtBlock, StmtBlock)>, Position), Switch(ExprBox<(BTreeMap<u64, Box<(Option<Expr>, StmtBlock)>>, StmtBlock)>, Position), While(ExprBox<StmtBlock>, Position), Do(Box<StmtBlock>, ExprOptionFlagsPosition), For(ExprBox<(Ident, Option<Ident>, StmtBlock)>, Position), Var(ExprBox<Ident>, OptionFlagsPosition), Assignment(Box<(Expr, Option<OpAssignment<'static>>, Expr)>, Position), FnCall(Box<FnCallExpr>, Position), Block(Box<[Stmt]>, Position), TryCatch(Box<(StmtBlock, Option<Ident>, StmtBlock)>, Position), Expr(Expr), Continue(Position), Break(Position), Return(ReturnTypeOption<Expr>, Position), Import(ExprOption<Box<Ident>>, Position), Export(Box<[(Ident, Ident)]>, Position), Share(Identifier),
}
Expand description

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

Volatile Data Structure

This type is volatile and may change.

Variants

Noop(Position)

No-op.

Tuple Fields of Noop

0: Position

if expr { stmt } else { stmt }

Tuple Fields of If

0: Expr1: Box<(StmtBlock, StmtBlock)>2: Position

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

Tuple Fields of Switch

0: Expr1: Box<(BTreeMap<u64, Box<(Option<Expr>, StmtBlock)>>, StmtBlock)>2: Position

while expr { stmt } | loop { stmt }

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

Tuple Fields of While

0: Expr1: Box<StmtBlock>2: Position

do { stmt } while|until expr

Option Flags

  • [AST_FLAG_NONE][AST_FLAGS::AST_FLAG_NONE] = while
  • [AST_FLAG_NEGATED][AST_FLAGS::AST_FLAG_NEGATED] = until

Tuple Fields of Do

0: Box<StmtBlock>1: Expr2: OptionFlags3: Position

for ( id , counter ) in expr { stmt }

Tuple Fields of For

0: Expr1: Box<(Ident, Option<Ident>, StmtBlock)>2: Position

[export] let|const id = expr

Option Flags

  • [AST_FLAG_EXPORTED][AST_FLAGS::AST_FLAG_EXPORTED] = export
  • [AST_FLAG_CONSTANT][AST_FLAGS::AST_FLAG_CONSTANT] = const

Tuple Fields of Var

0: Expr1: Box<Ident>2: OptionFlags3: Position
Assignment(Box<(Expr, Option<OpAssignment<'static>>, Expr)>, Position)

expr op= expr

Tuple Fields of Assignment

0: Box<(Expr, Option<OpAssignment<'static>>, Expr)>1: 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.

Tuple Fields of FnCall

0: Box<FnCallExpr>1: Position
Block(Box<[Stmt]>, Position)

{ stmt;}

Tuple Fields of Block

0: Box<[Stmt]>1: Position

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

Tuple Fields of TryCatch

0: Box<(StmtBlock, Option<Ident>, StmtBlock)>1: Position
Expr(Expr)

Tuple Fields of Expr

0: Expr
Continue(Position)

continue

Tuple Fields of Continue

0: Position
Break(Position)

break

Tuple Fields of Break

0: Position

return/throw

Tuple Fields of Return

0: ReturnType1: Option<Expr>2: Position
Import(ExprOption<Box<Ident>>, Position)

import expr as var

Not available under no_module.

Tuple Fields of Import

0: Expr1: Option<Box<Ident>>2: Position

export var as var ,

Not available under no_module.

Tuple Fields of Export

0: Box<[(Ident, Ident)]>1: Position
Share(Identifier)

Convert a variable to shared.

Not available under no_closure.

Tuple Fields of Share

0: Identifier

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.

Is this statement pure within the containing block?

An internally pure statement only has side effects that disappear outside the block.

Only variable declarations (i.e. let and const) and import/export statements are internally pure.

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

Performs the conversion.

Performs the conversion.

Performs the conversion.

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

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

recently added

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.