[][src]Enum arithmetic_eval::Value

#[non_exhaustive]pub enum Value<'a, T> {
    Number(T),
    Bool(bool),
    Function(Function<'a, T>),
    Tuple(Vec<Value<'a, T>>),
    Ref(OpaqueRef),
}

Values produced by expressions during their interpretation.

Variants (Non-exhaustive)

Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Number(T)

Primitive value: a single literal.

Bool(bool)

Boolean value.

Function(Function<'a, T>)

Function.

Tuple(Vec<Value<'a, T>>)

Tuple of zero or more values.

Opaque reference to a native value.

Implementations

impl<'a, T> Value<'a, T>[src]

pub fn native_fn(function: impl NativeFn<T> + 'static) -> Self[src]

Creates a value for a native function.

pub fn wrapped_fn<Args, F>(fn_to_wrap: F) -> Self where
    FnWrapper<Args, F>: NativeFn<T> + 'static, 
[src]

Creates a wrapped function.

Calling this method is equivalent to wrapping a function and calling Self::native_fn() on it. Thanks to type inference magic, the Rust compiler will usually be able to extract the Args type param from the function definition, provided that type of function arguments and its return type are defined explicitly or can be unequivocally inferred from the declaration.

pub fn void() -> Self[src]

Creates a void value (an empty tuple).

pub fn opaque_ref(value: impl Any + Debug + PartialEq) -> Self[src]

Creates a reference to a native variable.

pub fn value_type(&self) -> ValueType[src]

Returns the type of this value.

pub fn is_void(&self) -> bool[src]

Checks if this value is void (an empty tuple).

pub fn is_function(&self) -> bool[src]

Checks if this value is a function.

Trait Implementations

impl<T: Clone, '_> Clone for Value<'_, T>[src]

impl<'a, T: Debug> Debug for Value<'a, T>[src]

impl<T: Display, '_> Display for Value<'_, T>[src]

impl<'a, T: Clone, '_> From<&'_ Value<'a, T>> for Value<'a, T>[src]

impl<'a, T> IntoEvalResult<'a, T> for Value<'a, T>[src]

impl<T: PartialEq, '_> PartialEq<Value<'_, T>> for Value<'_, T>[src]

impl<T: 'static + Clone, '_> StripCode for Value<'_, T>[src]

type Stripped = Value<'static, T>

Resulting type after code stripping.

impl<'a, T> TryFromValue<'a, T> for Value<'a, T>[src]

Auto Trait Implementations

impl<'a, T> !RefUnwindSafe for Value<'a, T>

impl<'a, T> !Send for Value<'a, T>

impl<'a, T> !Sync for Value<'a, T>

impl<'a, T> Unpin for Value<'a, T> where
    T: Unpin

impl<'a, T> !UnwindSafe for Value<'a, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

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

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

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

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

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

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> TryConv for T

impl<T> TryConv for T

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.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,