Struct canrun::core::LVar

source ·
pub struct LVar<T> { /* private fields */ }
Expand description

A logical variable that represents a potential value of type T.

LVars are are passed into goals to relate values and other variables to each other. They can also be used to query for values.

The main reason to deal with an LVar directly as opposed to just Value::Var is that LVar implements Copy, which makes it more convenient when the same var is shared between various goals, closures and other places.

The identity of each LVar is tracked using an internal id. While this id is visible through the Debug implementation, it should only be used for debugging purposes as no guarantees are made about the type or generation of the id value. Also, these ids are only valid within the context of a single execution. They cannot be safely persisted or shared between processes.

Implementations§

source§

impl<T: Unify> LVar<T>

source

pub fn new() -> Self

Create a new logical var.

Example:
use canrun::LVar;
let x: LVar<isize> = LVar::new();

Trait Implementations§

source§

impl<T> Clone for LVar<T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for LVar<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: Unify> Default for LVar<T>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T: Unify> From<&LVar<T>> for Value<T>

source§

fn from(var: &LVar<T>) -> Self

Converts to this type from the input type.
source§

impl<T: Unify> From<LVar<T>> for Value<T>

source§

fn from(var: LVar<T>) -> Self

Converts to this type from the input type.
source§

impl<T> Hash for LVar<T>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

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

impl<T> PartialEq<LVar<T>> for LVar<T>

source§

fn eq(&self, other: &LVar<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Unify + Reify> Reify for LVar<T>

§

type Reified = <T as Reify>::Reified

The “concrete” type that Self reifies to.
source§

fn reify_in(&self, state: &ReadyState) -> Option<Self::Reified>

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

impl<T: Copy> Copy for LVar<T>

source§

impl<T: Eq> Eq for LVar<T>

source§

impl<T> StructuralEq for LVar<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for LVar<T>where T: RefUnwindSafe,

§

impl<T> Send for LVar<T>where T: Send,

§

impl<T> Sync for LVar<T>where T: Sync,

§

impl<T> Unpin for LVar<T>where T: Unpin,

§

impl<T> UnwindSafe for LVar<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.