Enum canrun::value::Val[][src]

pub enum Val<T: Debug + ?Sized> {
    Var(LVar<T>),
    Resolved(Rc<T>),
}
Expand description

The possible states a value can be in.

Variants

Var

Tuple Fields of Var

0: LVar<T>
Resolved

A resolved value.

When a state is split into an arbitrary number of resolved states, some of the internal data structures often need to be cloned. In an attempt to avoid unnecessary cloning of every value in the state, we wrap it in an Rc so that references can be shared.

Tuple Fields of Resolved

0: Rc<T>

Implementations

Attempt to extract a reference to resolved value (&T) or return the LVar if the value is not yet resolved.

Examples:

use canrun::{var, val, LVar};

let x: LVar<i32> = var();
let x_val = val!(x);
assert_eq!(x_val.resolved(), Err(x));
let y_val = val!(1);
assert_eq!(y_val.resolved(), Ok(&1));

Return true if the Val is an unresolved variable.

Example:

use canrun::{var, val, Val};

let x: Val<i32> = val!(var());
assert!(x.is_var());

Return true if the Val is a resolved value.

Example:

use canrun::{var, val, Val};

let x: Val<i32> = val!(1);
assert!(x.is_resolved());

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

Feeds this value into the given Hasher. Read more

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

Convert various T related values into a Val<T>. Read more

Convert various T related values into a Val<T>. Read more

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

This method tests for !=.

The “concrete” type that Self reifies to.

Extract a reified Self from a compatible ResolvedState. This trait is usually used indirectly through the Query trait. Read more

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.

Should always be Self

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)

recently added

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.