Struct rhai::Expression
source · [−]pub struct Expression<'a>(_);
Expand description
An expression sub-tree in an AST
.
Implementations
sourceimpl Expression<'_>
impl Expression<'_>
sourcepub fn get_string_value(&self) -> Option<&str>
pub fn get_string_value(&self) -> Option<&str>
Get the value of this expression if it is a variable name or a string constant.
Returns None
also if the constant is not of the specified type.
sourcepub fn get_literal_value<T: Variant>(&self) -> Option<T>
pub fn get_literal_value<T: Variant>(&self) -> Option<T>
Get the value of this expression if it is a literal constant.
Supports INT
, FLOAT
, ()
, char
, bool
and
ImmutableString
.
Returns None
also if the constant is not of the specified type.
sourceimpl Expression<'_>
impl Expression<'_>
sourcepub fn get_variable_name(&self) -> Option<&str>
👎 Deprecated since 1.4.0: use get_string_value
instead
pub fn get_variable_name(&self) -> Option<&str>
use get_string_value
instead
If this expression is a variable name, return it. Otherwise None
.
Deprecated
This method is deprecated. Use get_string_value
instead.
This method will be removed in the next major version.
Methods from Deref<Target = Expr>
sourcepub fn get_literal_value(&self) -> Option<Dynamic>
pub fn get_literal_value(&self) -> Option<Dynamic>
sourcepub fn start_position(&self) -> Position
pub fn start_position(&self) -> Position
Get the starting position of the expression. For a binary expression, this will be the left-most LHS instead of the operator.
sourcepub fn is_constant(&self) -> bool
pub fn is_constant(&self) -> bool
Is the expression a constant?
sourcepub fn is_valid_postfix(&self, token: &Token) -> bool
pub fn is_valid_postfix(&self, token: &Token) -> bool
Is a particular token allowed as a postfix operator to this expression?
Trait Implementations
sourceimpl AsRef<Expr> for Expression<'_>
impl AsRef<Expr> for Expression<'_>
sourceimpl<'a> Clone for Expression<'a>
impl<'a> Clone for Expression<'a>
sourcefn clone(&self) -> Expression<'a>
fn clone(&self) -> Expression<'a>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'a> Debug for Expression<'a>
impl<'a> Debug for Expression<'a>
sourceimpl Deref for Expression<'_>
impl Deref for Expression<'_>
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Expression<'a>
impl<'a> !Send for Expression<'a>
impl<'a> !Sync for Expression<'a>
impl<'a> Unpin for Expression<'a>
impl<'a> !UnwindSafe for Expression<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more