Enum canrun::core::Value

source ·
pub enum Value<T: Unify> {
    Var(LVar<T>),
    Resolved(Rc<T>),
}
Expand description

Contain individual resolved values or variables that can be bound through unification.

Variants§

§

Var(LVar<T>)

A logical variable.

Even though they do not contain a value, they are parameterized with the type they can potentially be bound to. This ensures that they can only be unified with values of the same type.

§

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§

Create a new logical Value wrapping a T.

Example:
use canrun::Value;
let x: Value<i32> = Value::new(1);

Create a new logical Value with an unresolved Var.

This is a shorthand for Value::Var(LVar::new()).

Example:
use canrun::Value;
let x: Value<i32> = Value::var();

Return T if the Value is a resolved.

Example:

use canrun::Value;

let x: Value<i32> = Value::new(1);
assert_eq!(x.resolved(), Some(&1));

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
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Creates a value from an iterator. Read more
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 ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
The “concrete” type that Self reifies to.
Extract a reified Self from a compatible State. 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
Converts to this type from the input type.

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.