Trait canrun::value::ReifyIn [−][src]
pub trait ReifyIn<'a, D>: Sized { type Reified; fn reify_in(&self, state: &ResolvedState<D>) -> Option<Self::Reified>; }
Expand description
Associated Types
Required methods
fn reify_in(&self, state: &ResolvedState<D>) -> Option<Self::Reified>
fn reify_in(&self, state: &ResolvedState<D>) -> Option<Self::Reified>
Extract a reified Self
from a compatible
ResolvedState
. This trait is usually
used indirectly through the Query
trait.
Examples:
Simple values are typically copied or cloned (since the Val
stores in
an Rc internally).
use canrun::{Val, val, var, ReifyIn, IterResolved, State, ResolvedState}; use canrun::example::{I32, TupleI32}; State::new() .iter_resolved() .for_each(|state: ResolvedState<I32>| { let x = val!(1); assert_eq!(x.reify_in(&state), Some(1)); });
Structures containing additional Val
s should be recursively reified.
State::new() .iter_resolved() .for_each(|state: ResolvedState<TupleI32>| { let x = (val!(1), val!(2)); assert_eq!(x.reify_in(&state), Some((1, 2))); });
Returns None
if the Val
is unresolved.
State::new() .iter_resolved() .for_each(|state: ResolvedState<I32>| { let x: Val<i32> = val!(var()); assert_eq!(x.reify_in(&state), None); });
Also returns None
if Self
is a structure containing any unresolved
Val
s.
State::new() .iter_resolved() .for_each(|state: ResolvedState<TupleI32>| { let x: Val<i32> = val!(var()); let y = (x, val!(2)); assert_eq!(y.reify_in(&state), None); });