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

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

The possible states a value can be in.

Variants

Var(LVar<T>)
Resolved(Rc<T>)

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.

Implementations

impl<T: Debug> Val<T>[src]

pub fn resolved(&self) -> Result<&T, LVar<T>>[src]

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));

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

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());

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

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

impl<T: Debug> Clone for Val<T>[src]

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

impl<T: Eq + Debug> Eq for Val<T>[src]

impl<T: Hash + Debug> Hash for Val<T>[src]

impl<T: Debug> IntoVal<T> for Val<T>[src]

impl<'_, T: Debug> IntoVal<T> for &'_ Val<T>[src]

impl<T: PartialEq + Debug> PartialEq<Val<T>> for Val<T>[src]

impl<'a, T, D> ReifyIn<'a, D> for Val<T> where
    T: ReifyIn<'a, D> + Debug,
    D: DomainType<'a, T> + 'a, 
[src]

type Reified = T::Reified

The "concrete" type that Self reifies to.

Auto Trait Implementations

impl<T> !RefUnwindSafe for Val<T>

impl<T> !Send for Val<T>

impl<T> !Sync for Val<T>

impl<T: ?Sized> Unpin for Val<T> where
    T: Unpin

impl<T: ?Sized> UnwindSafe for Val<T> where
    T: RefUnwindSafe + UnwindSafe

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> From<T> for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Owned = T

The resulting type after obtaining ownership.

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>,