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)>)
Integer constant.
FloatConstant(Box<FloatWrapper>)
Tuple Fields
0: Box<FloatWrapper>
Floating-point constant.
CharConstant(Box<(char, Position)>)
Character constant.
StringConstant(Box<(ImmutableString, Position)>)
Tuple Fields
0: Box<(ImmutableString, Position)>
String constant.
FnPointer(Box<(ImmutableString, Position)>)
Tuple Fields
0: Box<(ImmutableString, Position)>
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)>)
{ stmt }
Expr(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)>)
expr op= expr
Dot(Box<(Expr, Expr, Position)>)
lhs.rhs
Index(Box<(Expr, Expr, Position)>)
expr[expr]
Array(Box<(StaticVec<Expr>, Position)>)
[ expr, … ]
Map(Box<(StaticVec<((ImmutableString, Position), Expr)>, Position)>)
#{ name:expr, … }
In(Box<(Expr, Expr, Position)>)
lhs in rhs
And(Box<(Expr, Expr, Position)>)
lhs && rhs
Or(Box<(Expr, Expr, Position)>)
lhs || rhs
True(Position)
Tuple Fields
0: Position
true
False(Position)
Tuple Fields
0: Position
false
Unit(Position)
Tuple Fields
0: Position
()
Custom(Box<(CustomExpr, Position)>)
Tuple Fields
0: Box<(CustomExpr, Position)>
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.
Override the Position
of the expression.
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
Auto Trait Implementations
impl !RefUnwindSafe for Expr
impl !UnwindSafe for Expr
Blanket Implementations
Mutably borrows from an owned value. Read more