Enum rhai::Expr[][src]

pub enum Expr {
Show 20 variants DynamicConstant(Box<Dynamic>, Position), BoolConstant(boolPosition), IntegerConstant(INTPosition), FloatConstant(FloatWrapper<FLOAT>, Position), CharConstant(charPosition), StringConstant(ImmutableStringPosition), InterpolatedString(Box<StaticVec<Expr>>, Position), Array(Box<StaticVec<Expr>>, Position), Map(Box<(StaticVec<(Ident, Expr)>, BTreeMap<Identifier, Dynamic>)>, Position), Unit(Position), Variable(Option<NonZeroU8>, PositionBox<(Option<NonZeroUsize>, Option<(NamespaceRef, u64)>, Identifier)>), Property(Box<((Identifier, u64), (Identifier, u64), (ImmutableString, Position))>), Stack(usizePosition), Stmt(Box<StmtBlock>), FnCall(Box<FnCallExpr>, Position), Dot(Box<BinaryExpr>, boolPosition), Index(Box<BinaryExpr>, boolPosition), And(Box<BinaryExpr>, Position), Or(Box<BinaryExpr>, Position), Custom(Box<CustomExpr>, Position),
}
Expand description

(internals) An expression sub-tree. Exported under the internals feature only.

Volatile Data Structure

This type is volatile and may change.

Variants

DynamicConstant(Box<Dynamic>, Position)

Dynamic constant. Used to hold either an Array or Map literal for quick cloning. All other primitive data types should use the appropriate variants for better speed.

Tuple Fields of DynamicConstant

0: Box<Dynamic>1: Position
BoolConstant(boolPosition)

Boolean constant.

Tuple Fields of BoolConstant

0: bool1: Position
IntegerConstant(INTPosition)

Integer constant.

Tuple Fields of IntegerConstant

0: INT1: Position
FloatConstant(FloatWrapper<FLOAT>, Position)

Floating-point constant.

Not available under no_float.

Tuple Fields of FloatConstant

0: FloatWrapper<FLOAT>1: Position
CharConstant(charPosition)

Character constant.

Tuple Fields of CharConstant

0: char1: Position
StringConstant(ImmutableStringPosition)

String constant.

Tuple Fields of StringConstant

0: ImmutableString1: Position
InterpolatedString(Box<StaticVec<Expr>>, Position)

An interpolated string.

Tuple Fields of InterpolatedString

0: Box<StaticVec<Expr>>1: Position

[ expr, … ]

Tuple Fields of Array

0: Box<StaticVec<Expr>>1: Position

#{ name:expr, … }

Tuple Fields of Map

0: Box<(StaticVec<(Ident, Expr)>, BTreeMap<Identifier, Dynamic>)>1: Position
Unit(Position)

()

Tuple Fields of Unit

0: Position

Variable access - optional short index, position, (optional index, optional (hash, modules), variable name)

The short index is u8 which is used when the index is <= 255, which should be the vast majority of cases (unless there are more than 255 variables defined!). This is to avoid reading a pointer redirection during each variable access.

Property access - ((getter, hash), (setter, hash), prop)

Tuple Fields of Property

0: Box<((Identifier, u64), (Identifier, u64), (ImmutableString, Position))>
Stack(usizePosition)

Stack slot

Tuple Fields of Stack

0: usize1: Position
Stmt(Box<StmtBlock>)

{ statement … }

Tuple Fields of Stmt

0: Box<StmtBlock>

func ( expr ,)

Tuple Fields of FnCall

0: Box<FnCallExpr>1: Position

lhs . rhs - bool variable is a dummy

Tuple Fields of Dot

0: Box<BinaryExpr>1: bool2: Position

expr [ expr ] - boolean indicates whether the dotting/indexing chain stops

Tuple Fields of Index

0: Box<BinaryExpr>1: bool2: Position

lhs && rhs

Tuple Fields of And

0: Box<BinaryExpr>1: Position

lhs || rhs

Tuple Fields of Or

0: Box<BinaryExpr>1: Position

Custom syntax

Tuple Fields of Custom

0: Box<CustomExpr>1: Position

Implementations

Get the Dynamic value of a literal constant expression.

Returns None if the expression is not a literal constant.

Create an Expr from a Dynamic value.

Get the position of the expression.

Override the position of the expression.

Is the expression pure?

A pure expression has no side effects.

Is the expression the unit () literal?

Is the expression a constant?

Is a particular token allowed as a postfix operator to this expression?

Recursively walk this expression. 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.

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.