Trait canrun::core::Reify

source ·
pub trait Reify {
    type Reified;

    // Required method
    fn reify_in(&self, state: &ReadyState) -> Option<Self::Reified>;
}
Expand description

Extract a fully resolved T from a Value<T> associated with a State.

Used by Query to ensure that result values are fully and recursively resolved.

Required Associated Types§

source

type Reified

The “concrete” type that Self reifies to.

Required Methods§

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.

Examples:

Simple values are typically copied or cloned (since the Value uses an Rc internally).

use canrun::{Value, Reify, StateIterator, State};
State::new()
    .into_states()
    .filter_map(|s| s.ready())
    .for_each(|state| {
        let x = Value::new(1);
        // This value is already resolved, so we simply get it back.
        assert_eq!(x.reify_in(&state), Some(1));
    });

Structures containing additional Values should be recursively reified. Reify is implemented for several tuple sizes to allow easy querying of multiple Values.

State::new()
    .into_states()
    .filter_map(|s| s.ready())
    .for_each(|state| {
        let x = (Value::new(1), Value::new(2));
        assert_eq!(x.reify_in(&state), Some((1, 2)));
    });

Returns None if the Value is unresolved. Note that this does not currently do anything to help you if there are pending forks or constraints that could affect resolution.

State::new()
    .into_states()
    .filter_map(|s| s.ready())
    .for_each(|state| {
        let x: Value<usize> = Value::var();
        assert_eq!(x.reify_in(&state), None);
    });

Also returns None if Self is a structure containing any unresolved Values.

State::new()
    .into_states()
    .filter_map(|s| s.ready())
    .for_each(|state| {
        let x: Value<i32> = Value::var();
        let y = (x, Value::new(2));
        assert_eq!(y.reify_in(&state), None);
    });

Implementations on Foreign Types§

source§

impl Reify for String

source§

impl Reify for i8

§

type Reified = i8

source§

fn reify_in(&self, _: &ReadyState) -> Option<i8>

source§

impl Reify for usize

source§

impl Reify for char

source§

impl Reify for i64

source§

impl Reify for isize

source§

impl Reify for i16

source§

impl<Av: Reify<Reified = Ar>, Ar, Bv: Reify<Reified = Br>, Br, Cv: Reify<Reified = Cr>, Cr> Reify for (Av, Bv, Cv)

§

type Reified = (<Av as Reify>::Reified, <Bv as Reify>::Reified, <Cv as Reify>::Reified)

source§

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

source§

impl Reify for &'static str

§

type Reified = &'static str

source§

fn reify_in(&self, _: &ReadyState) -> Option<&'static str>

source§

impl<Av: Reify<Reified = Ar>, Ar, Bv: Reify<Reified = Br>, Br, Cv: Reify<Reified = Cr>, Cr, Dv: Reify<Reified = Dr>, Dr, Ev: Reify<Reified = Er>, Er> Reify for (Av, Bv, Cv, Dv, Ev)

§

type Reified = (<Av as Reify>::Reified, <Bv as Reify>::Reified, <Cv as Reify>::Reified, <Dv as Reify>::Reified, <Ev as Reify>::Reified)

source§

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

source§

impl Reify for u16

source§

impl Reify for bool

source§

impl Reify for u64

source§

impl<Av: Reify<Reified = Ar>, Ar, Bv: Reify<Reified = Br>, Br, Cv: Reify<Reified = Cr>, Cr, Dv: Reify<Reified = Dr>, Dr> Reify for (Av, Bv, Cv, Dv)

§

type Reified = (<Av as Reify>::Reified, <Bv as Reify>::Reified, <Cv as Reify>::Reified, <Dv as Reify>::Reified)

source§

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

source§

impl Reify for u8

§

type Reified = u8

source§

fn reify_in(&self, _: &ReadyState) -> Option<u8>

source§

impl Reify for f32

source§

impl Reify for f64

source§

impl Reify for i32

source§

impl Reify for u32

source§

impl<Av: Reify<Reified = Ar>, Ar, Bv: Reify<Reified = Br>, Br> Reify for (Av, Bv)

§

type Reified = (<Av as Reify>::Reified, <Bv as Reify>::Reified)

source§

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

Implementors§

source§

impl<Kv, Kr, Vv, Vr> Reify for LMap<Kv, Vv>where Kv: Unify + Eq + Hash + Reify<Reified = Kr>, Kr: Eq + Hash, Vv: Unify + Reify<Reified = Vr>,

§

type Reified = HashMap<Kr, Vr, RandomState>

source§

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

§

type Reified = <T as Reify>::Reified

source§

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

§

type Reified = Vec<<T as Reify>::Reified, Global>

source§

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

§

type Reified = <T as Reify>::Reified