[][src]Enum rhai::Expr

pub enum Expr {
    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)>),
}

[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>)

Floating-point constant.

CharConstant(Box<(char, Position)>)

Character constant.

StringConstant(Box<(ImmutableString, Position)>)

String constant.

FnPtr constant.

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

Property access.

{ stmt }

Expr(Box<Expr>)

Wrapped expression - should not be optimized away.

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

lhs.rhs

expr[expr]

[ expr, ... ]

#{ name:expr, ... }

lhs in rhs

lhs && rhs

lhs || rhs

True(Position)

true

False(Position)

false

Unit(Position)

()

Custom syntax

Implementations

impl Expr[src]

pub fn get_type_id(&self) -> Option<TypeId>[src]

Get the type of an expression.

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

pub fn get_constant_value(&self) -> Option<Dynamic>[src]

Get the Dynamic value of a constant expression.

Returns None if the expression is not constant.

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

Get the Position of the expression.

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

Notable traits for &'_ mut W

impl<'_, W> Write for &'_ mut W where
    W: Write + ?Sized
impl<'_, R> Read for &'_ mut R where
    R: Read + ?Sized
impl<'_, I> Iterator for &'_ mut I where
    I: Iterator + ?Sized
type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
    F: Unpin + Future + ?Sized
type Output = <F as Future>::Output;
[src]

Override the Position of the expression.

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

Is the expression pure?

A pure expression has no side effects.

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

Is the expression the unit () literal?

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

Is the expression a simple constant literal?

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

Is the expression a constant?

pub fn is_valid_postfix(&self, token: &Token) -> bool[src]

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

Trait Implementations

impl Clone for Expr[src]

impl Debug for Expr[src]

impl Default for Expr[src]

impl<'a> From<&'a Expr> for Expression<'a>[src]

impl Hash for Expr[src]

Auto Trait Implementations

impl !RefUnwindSafe for Expr

impl !Send for Expr

impl !Sync for Expr

impl Unpin for Expr

impl !UnwindSafe for Expr

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.