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.
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.
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.
Create a new logical Value
wrapping a T
.
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())
.
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));
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.
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
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.
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.