Enum rhai::Expr[][src]

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

BoolConstant(boolPosition)

Boolean constant.

IntegerConstant(INTPosition)

Integer constant.

FloatConstant(FloatWrapper<FLOAT>, Position)

Floating-point constant.

Not available under no_float.

CharConstant(charPosition)

Character constant.

StringConstant(ImmutableStringPosition)

String constant.

InterpolatedString(Box<StaticVec<Expr>>)

An interpolated string.

[ expr, … ]

#{ name:expr, … }

Unit(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)

Stmt(Box<StmtBlock>)

{ statement … }

func ( expr ,)

lhs . rhs

expr [ expr ]

lhs && rhs

lhs || rhs

Custom syntax

Implementations

impl Expr[src]

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[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_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?

pub fn walk<'a>(
    &'a self,
    path: &mut Vec<ASTNode<'a>>,
    on_node: &mut impl FnMut(&[ASTNode<'_>]) -> bool
) -> bool
[src]

Recursively walk this expression. Return false from the callback to terminate the walk.

Trait Implementations

impl Clone for Expr[src]

fn clone(&self) -> Expr[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Expr[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Default for Expr[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

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

fn from(expr: &'a Expr) -> Self[src]

Performs the conversion.

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

fn from(expr: &'a Expr) -> Self[src]

Performs the conversion.

impl From<Dynamic> for Expr[src]

fn from(value: Dynamic) -> Self[src]

Performs the conversion.

impl Hash for Expr[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> CallHasher for T where
    T: Hash + ?Sized
[src]

pub default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64 where
    H: Hash + ?Sized,
    B: BuildHasher
[src]

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.