Enum rhai::Expr[][src]

pub enum Expr {
Show 20 variants DynamicConstant(Box<Dynamic>, Position), BoolConstant(bool, Position), IntegerConstant(INT, Position), FloatConstant(FloatWrapper<FLOAT>, Position), CharConstant(char, Position), StringConstant(ImmutableString, Position), InterpolatedString(Box<StaticVec<Expr>>, Position), Array(Box<StaticVec<Expr>>, Position), Map(Box<(StaticVec<(Ident, Expr)>, BTreeMap<Identifier, Dynamic>)>, Position), Unit(Position), Variable(Option<NonZeroU8>, Position, Box<(Option<NonZeroUsize>, Option<(NamespaceRef, u64)>, Identifier)>), Property(Box<((Identifier, u64), (Identifier, u64), (ImmutableString, Position))>), Stack(usize, Position), Stmt(Box<StmtBlock>), FnCall(Box<FnCallExpr>, Position), Dot(Box<BinaryExpr>, bool, Position), Index(Box<BinaryExpr>, bool, Position), 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

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

Boolean constant.

Tuple Fields of BoolConstant

0: bool1: Position
IntegerConstant

Integer constant.

Tuple Fields of IntegerConstant

0: INT1: Position
FloatConstant

Floating-point constant.

Not available under no_float.

Tuple Fields of FloatConstant

0: FloatWrapper<FLOAT>1: Position
CharConstant

Character constant.

Tuple Fields of CharConstant

0: char1: Position
StringConstant

String constant.

Tuple Fields of StringConstant

0: ImmutableString1: Position
InterpolatedString

An interpolated string.

Tuple Fields of InterpolatedString

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

[ expr, … ]

Tuple Fields of Array

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

#{ name:expr, … }

Tuple Fields of Map

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

()

Tuple Fields of Unit

0: Position
Variable

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

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

Tuple Fields of Property

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

Stack slot

Tuple Fields of Stack

0: usize1: Position
Stmt

{ statement … }

Tuple Fields of Stmt

0: Box<StmtBlock>
FnCall

func ( expr ,)

Tuple Fields of FnCall

0: Box<FnCallExpr>1: Position
Dot

lhs . rhs - bool variable is a dummy

Tuple Fields of Dot

0: Box<BinaryExpr>1: bool2: Position
Index

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

Tuple Fields of Index

0: Box<BinaryExpr>1: bool2: Position
And

lhs && rhs

Tuple Fields of And

0: Box<BinaryExpr>1: Position
Or

lhs || rhs

Tuple Fields of Or

0: Box<BinaryExpr>1: Position
Custom

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.