Enum rhai::Expr[][src]

pub enum Expr {
Show 22 variants IntegerConstant(Box<(INT, Position)>), FloatConstant(Box<FloatWrapper>), CharConstant(Box<(char, Position)>), StringConstant(Box<(ImmutableString, Position)>), FnPointer(Box<(ImmutableString, Position)>), Variable(Box<((String, Position), Option<Box<ModuleRef>>, u64, Option<NonZeroUsize>)>), Property(Box<((ImmutableString, String, String), Position)>), Stmt(Box<(Stmt, Position)>), Expr(Box<Expr>), FnCall(Box<((Cow<'static, str>, bool, bool, Position), Option<Box<ModuleRef>>, u64, StaticVec<Expr>, Option<bool>)>), Assignment(Box<(Expr, Cow<'static, str>, Expr, Position)>), Dot(Box<(Expr, Expr, Position)>), Index(Box<(Expr, Expr, Position)>), Array(Box<(StaticVec<Expr>, Position)>), Map(Box<(StaticVec<((ImmutableString, Position), Expr)>, Position)>), In(Box<(Expr, Expr, Position)>), And(Box<(Expr, Expr, Position)>), Or(Box<(Expr, Expr, Position)>), True(Position), False(Position), Unit(Position), Custom(Box<(CustomExpr, Position)>),
}
Expand description

[INTERNALS] An expression sub-tree. Exported under the internals feature only.

Each variant is at most one pointer in size (for speed), with everything being allocated together in one single tuple.

WARNING

This type is volatile and may change.

Variants

IntegerConstant(Box<(INT, Position)>)

Tuple Fields

Integer constant.

FloatConstant(Box<FloatWrapper>)

Tuple Fields

Floating-point constant.

CharConstant(Box<(char, Position)>)

Tuple Fields

Character constant.

StringConstant(Box<(ImmutableString, Position)>)

Tuple Fields

String constant.

FnPointer(Box<(ImmutableString, Position)>)

Tuple Fields

FnPtr constant.

Variable(Box<((String, Position), Option<Box<ModuleRef>>, u64, Option<NonZeroUsize>)>)

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

Property(Box<((ImmutableString, String, String), Position)>)

Property access.

Stmt(Box<(Stmt, Position)>)

Tuple Fields

{ stmt }

Expr(Box<Expr>)

Tuple Fields

0: Box<Expr>

Wrapped expression - should not be optimized away.

FnCall(Box<((Cow<'static, str>, bool, bool, Position), Option<Box<ModuleRef>>, u64, StaticVec<Expr>, Option<bool>)>)

Tuple Fields

func(expr, … ) - ((function name, native_only, capture, position), optional modules, hash, arguments, optional default value) Use Cow<'static, str> because a lot of operators (e.g. ==, >=) are implemented as function calls and the function names are predictable, so no need to allocate a new String.

Assignment(Box<(Expr, Cow<'static, str>, Expr, Position)>)

Tuple Fields

0: Box<(Expr, Cow<'static, str>, Expr, Position)>

expr op= expr

Dot(Box<(Expr, Expr, Position)>)

Tuple Fields

lhs.rhs

Index(Box<(Expr, Expr, Position)>)

Tuple Fields

expr[expr]

Array(Box<(StaticVec<Expr>, Position)>)

Tuple Fields

[ expr, … ]

Map(Box<(StaticVec<((ImmutableString, Position), Expr)>, Position)>)

#{ name:expr, … }

In(Box<(Expr, Expr, Position)>)

Tuple Fields

lhs in rhs

And(Box<(Expr, Expr, Position)>)

Tuple Fields

lhs && rhs

Or(Box<(Expr, Expr, Position)>)

Tuple Fields

lhs || rhs

True(Position)

Tuple Fields

true

False(Position)

Tuple Fields

false

Unit(Position)

Tuple Fields

()

Custom(Box<(CustomExpr, Position)>)

Tuple Fields

Custom syntax

Implementations

Get the type of an expression.

Returns None if the expression’s result type is not constant.

Get the Dynamic value of a constant expression.

Returns None if the expression is not constant.

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 simple constant literal?

Is the expression a constant?

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

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.

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.