Enum rhai::Stmt[][src]

pub enum Stmt {
Show 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>, ExprboolPosition), For(ExprBox<(Ident, StmtBlock)>, Position), Let(ExprBox<Ident>, boolPosition), Const(ExprBox<Ident>, boolPosition), Assignment(Box<(Expr, Option<OpAssignment>, Expr)>, Position), FnCall(Box<FnCallExpr>, Position), Block(Box<[Stmt]>, Position), TryCatch(Box<(StmtBlock, Option<Ident>, StmtBlock)>, PositionPosition), Expr(Expr), Continue(Position), Break(Position), Return(ReturnTypeOption<Expr>, Position), Import(ExprOption<Box<Ident>>, Position), Export(Box<[(Ident, Option<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.

if expr { stmt } else { stmt }

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

while expr { stmt }

do { stmt } while|until expr

for id in expr { stmt }

Let(ExprBox<Ident>, boolPosition)

[export] let id = expr

Const(ExprBox<Ident>, boolPosition)

[export] const id = expr

expr op= expr

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<[Stmt]>, Position)

{ stmt;}

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

Expr(Expr)
Continue(Position)

continue

Break(Position)

break

return/throw

Import(ExprOption<Box<Ident>>, Position)

import expr as var

Not available under no_module.

export var as var ,

Not available under no_module.

Share(Identifier)

Convert a variable to shared.

Not available under no_closure.

Implementations

impl Stmt[src]

pub fn is_noop(&self) -> bool[src]

Is this statement Noop?

pub fn position(&self) -> Position[src]

Get the position of this statement.

pub fn set_position(&mut self, new_pos: Position) -> &mut Self[src]

Override the position of this statement.

pub fn returns_value(&self) -> bool[src]

Does this statement return a value?

pub fn is_self_terminated(&self) -> bool[src]

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

pub fn is_pure(&self) -> bool[src]

Is this statement pure?

A pure statement has no side effects.

pub fn is_internally_pure(&self) -> bool[src]

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.

pub fn is_control_flow_break(&self) -> bool[src]

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.

pub fn walk<'a>(
    &'a self,
    path: &mut Vec<ASTNode<'a>>,
    on_node: &mut impl FnMut(&[ASTNode<'_>]) -> bool
) -> bool
[src]

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

Trait Implementations

impl Clone for Stmt[src]

fn clone(&self) -> Stmt[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Stmt[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Default for Stmt[src]

fn default() -> Self[src]

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

impl<'a> From<&'a Stmt> for ASTNode<'a>[src]

fn from(stmt: &'a Stmt) -> Self[src]

Performs the conversion.

impl From<Stmt> for StmtBlock[src]

fn from(stmt: Stmt) -> Self[src]

Performs the conversion.

impl From<StmtBlock> for Stmt[src]

fn from(block: StmtBlock) -> Self[src]

Performs the conversion.

impl Hash for Stmt[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

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

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> CallHasher for T where
    T: Hash + ?Sized
[src]

pub default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64 where
    H: Hash + ?Sized,
    B: BuildHasher
[src]

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

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

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.