pub struct Expression<'a>(_);
Expand description

An expression sub-tree in an AST.

Implementations

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.

Get the position of this expression.

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.

👎 Deprecated since 1.4.0:

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>

Get the Dynamic value of a literal constant expression.

Returns None if the expression is not a literal constant.

Get the position of the expression.

Get the starting position of the expression. For a binary expression, this will be the left-most LHS instead of the operator.

Is the expression pure?

A pure expression has no side effects.

Is the expression the unit () literal?

Is the expression a constant?

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

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

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

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

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.