#[non_exhaustive]pub enum Expr {
Show 22 variants
DynamicConstant(Box<Dynamic>, Position),
BoolConstant(bool, Position),
IntegerConstant(i64, Position),
FloatConstant(FloatWrapper<f64>, Position),
CharConstant(char, Position),
StringConstant(ImmutableString, Position),
InterpolatedString(ThinVec<Expr>, Position),
Array(ThinVec<Expr>, Position),
Map(Box<(SmallVec<[(Ident, Expr); 3]>, BTreeMap<SmartString<LazyCompact>, Dynamic>)>, Position),
Unit(Position),
Variable(Box<(Option<NonZero<usize>>, ImmutableString, Namespace, u64)>, Option<NonZero<u8>>, Position),
ThisPtr(Position),
Property(Box<((ImmutableString, u64), (ImmutableString, u64), ImmutableString)>, Position),
MethodCall(Box<FnCallExpr>, Position),
Stmt(Box<StmtBlock>),
FnCall(Box<FnCallExpr>, Position),
Dot(Box<BinaryExpr>, ASTFlags, Position),
Index(Box<BinaryExpr>, ASTFlags, Position),
And(Box<SmallVec<[Expr; 3]>>, Position),
Or(Box<SmallVec<[Expr; 3]>>, Position),
Coalesce(Box<SmallVec<[Expr; 3]>>, Position),
Custom(Box<CustomExpr>, Position),
}rhai only.Expand description
(internals) An expression sub-tree.
Exported under the internals feature only.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
DynamicConstant(Box<Dynamic>, Position)
Dynamic constant.
Used to hold complex constants such as Array or Map for quick cloning.
Primitive data types should use the appropriate variants to avoid an allocation.
The Dynamic value is boxed in order to avoid bloating the size of Expr.
BoolConstant(bool, Position)
Boolean constant.
IntegerConstant(i64, Position)
Integer constant.
FloatConstant(FloatWrapper<f64>, Position)
no_float only.Floating-point constant.
CharConstant(char, Position)
Character constant.
StringConstant(ImmutableString, Position)
String constant.
InterpolatedString(ThinVec<Expr>, Position)
An interpolated string.
Array(ThinVec<Expr>, Position)
[ expr, … ]
Map(Box<(SmallVec<[(Ident, Expr); 3]>, BTreeMap<SmartString<LazyCompact>, Dynamic>)>, Position)
#{ name:expr, … }
Unit(Position)
()
Variable(Box<(Option<NonZero<usize>>, ImmutableString, Namespace, u64)>, Option<NonZero<u8>>, Position)
Variable access - (optional long index, variable name, namespace, namespace hash), optional short index, position
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.
ThisPtr(Position)
this.
Property(Box<((ImmutableString, u64), (ImmutableString, u64), ImmutableString)>, Position)
Property access - ((getter, hash), (setter, hash), prop)
MethodCall(Box<FnCallExpr>, Position)
xxx . method ( expr , … )
Stmt(Box<StmtBlock>)
{ statement … }
FnCall(Box<FnCallExpr>, Position)
func ( expr , … )
Dot(Box<BinaryExpr>, ASTFlags, Position)
lhs . rhs | lhs ?. rhs
§Flags
Index(Box<BinaryExpr>, ASTFlags, Position)
lhs [ rhs ]
§Flags
And(Box<SmallVec<[Expr; 3]>>, Position)
lhs && rhs
Or(Box<SmallVec<[Expr; 3]>>, Position)
lhs || rhs
Coalesce(Box<SmallVec<[Expr; 3]>>, Position)
lhs ?? rhs
Custom(Box<CustomExpr>, Position)
no_custom_syntax only.Custom syntax
Implementations§
Source§impl Expr
impl Expr
Sourcepub fn get_literal_value(
&self,
global: Option<&GlobalRuntimeState>,
) -> Option<Dynamic>
pub fn get_literal_value( &self, global: Option<&GlobalRuntimeState>, ) -> Option<Dynamic>
Sourcepub fn from_dynamic(value: Dynamic, pos: Position) -> Expr
pub fn from_dynamic(value: Dynamic, pos: Position) -> Expr
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 set_position(&mut self, new_pos: Position) -> &mut Expr
pub fn set_position(&mut self, new_pos: Position) -> &mut Expr
Override the position of the expression.
Sourcepub fn is_constant(&self) -> bool
pub fn is_constant(&self) -> bool
Is the expression a constant?
Sourcepub const fn is_valid_postfix(&self, token: &Token) -> bool
pub const fn is_valid_postfix(&self, token: &Token) -> bool
Is a particular token allowed as a postfix operator to this expression?
Sourcepub fn take(&mut self) -> Expr
pub fn take(&mut self) -> Expr
Return this Expr, replacing it with Expr::Unit.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Expr
impl !UnwindSafe for Expr
impl Freeze for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnsafeUnpin for Expr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
map-response-body only.Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
trace only.Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
trace only.Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
follow-redirect only.Source§impl<T> Variant for T
impl<T> Variant for T
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Variant trait object to &mut dyn Any.Source§fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
Variant trait object to Box<dyn Any>.