pub struct Expr { /* private fields */ }
Expand description

Wolfram Language expression.

Example

Construct the expression {1, 2, 3}:

use wolfram_expr::{Expr, Symbol};

let expr = Expr::normal(Symbol::new("System`List"), vec![
    Expr::from(1),
    Expr::from(2),
    Expr::from(3)
]);

Reference counting

Internally, Expr is an atomically reference-counted ExprKind. This makes cloning an expression computationally inexpensive.

Implementations

Construct a new expression from an ExprKind.

Consume self and return an owned ExprKind.

If the reference count of self is equal to 1 this function will not perform a clone of the stored ExprKind, making this operation very cheap in that case.

Get the ExprKind representing this expression.

Get mutable access to the ExprKind that represents this expression.

If the reference count of the underlying shared pointer is not equal to 1, this will clone the ExprKind to make it unique.

Retrieve the reference count of this expression.

Construct a new normal expression from the head and elements.

Construct a new expression from a Symbol.

Construct a new expression from a Number.

Construct a new expression from a String.

Construct an expression from a floating-point number.

let expr = Expr::real(3.14159);
Panics

This function will panic if real is NaN.

Returns the outer-most symbol “tag” used in this expression.

To illustrate:

ExpressionTag
5None
"hello"None
foofoo
f[1, 2, 3]f
g[x][y]g

If this represents a Normal expression, return its head. Otherwise, return None.

Attempt to get the element at index of a Normal expression.

Return None if this is not a Normal expression, or the given index is out of bounds.

index is 0-based. The 0th index is the first element, not the head.

This function does not panic.

If this is a Normal expression, return that. Otherwise return None.

If this is a Symbol expression, return that. Otherwise return None.

If this is a Number expression, return that. Otherwise return None.

Returns true if self is a Normal expr with the head sym.

NullWL.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

By default, this should generate a string which can be unambiguously parsed to reconstruct the Expr being displayed. This means symbols will always include their contexts, special characters in String’s will always be properly escaped, and numeric literals needing precision and accuracy marks will have them.

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Performs the conversion.

Performs the conversion.

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

Converts the given value to a String. 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.