TrieFnState

Enum TrieFnState 

Source
pub enum TrieFnState<A, T> {
    Simulate {
        trace: Trace<A, Trie<(Rc<dyn Any>, f64)>, T>,
    },
    Generate {
        trace: Trace<A, Trie<(Rc<dyn Any>, f64)>, T>,
        weight: f64,
        constraints: Trie<Rc<dyn Any>>,
    },
    Update {
        trace: Trace<A, Trie<(Rc<dyn Any>, f64)>, T>,
        constraints: Trie<Rc<dyn Any>>,
        weight: f64,
        discard: Trie<Rc<dyn Any>>,
        visitor: AddrTrie,
    },
}
Expand description

Incremental computational state of a trace during the execution of the different GenFn methods with a TrieFn.

Variants§

§

Simulate

State for executing GenFn::simulate in a TrieFn.

Fields

§trace: Trace<A, Trie<(Rc<dyn Any>, f64)>, T>
§

Generate

State for executing GenFn::generate in a TrieFn.

Fields

§trace: Trace<A, Trie<(Rc<dyn Any>, f64)>, T>
§weight: f64
§constraints: Trie<Rc<dyn Any>>
§

Update

State for executing GenFn::update in a TrieFn.

Fields

§trace: Trace<A, Trie<(Rc<dyn Any>, f64)>, T>
§constraints: Trie<Rc<dyn Any>>
§weight: f64
§discard: Trie<Rc<dyn Any>>
§visitor: AddrTrie

Implementations§

Source§

impl<A: 'static, T: 'static> TrieFnState<A, T>

Source

pub fn sample_at<V: Clone + 'static, W: Clone + 'static>( &mut self, dist: &impl Distribution<V, W>, args: W, addr: &str, ) -> V

Sample a random value from a distribution and insert it into the self.trace.data trie as a weighted leaf node.

Return a clone of the sampled value.

Source

pub fn trace_at<X: Clone + 'static, Y: Clone + 'static>( &mut self, gen_fn: &impl GenFn<X, Trie<(Rc<dyn Any>, f64)>, Y>, args: X, addr: &str, ) -> Y

Recursively sample a trace from another gen_fn.

Insert its subtrace.data trie as a weighted internal node of the current trace.data trie. Insert its retv as a (zero-weighted) internal node of the current trace.data trie.

Return a clone of the retv.

Source

pub fn gc(self) -> Self

For all addr present in self.trace.data, but not present in self.visitor, remove addr from self.trace.data and merge into self.discard.

Panics if self is not the Self::Update variant.

Auto Trait Implementations§

§

impl<A, T> Freeze for TrieFnState<A, T>
where A: Freeze, T: Freeze,

§

impl<A, T> !RefUnwindSafe for TrieFnState<A, T>

§

impl<A, T> !Send for TrieFnState<A, T>

§

impl<A, T> !Sync for TrieFnState<A, T>

§

impl<A, T> Unpin for TrieFnState<A, T>
where A: Unpin, T: Unpin,

§

impl<A, T> !UnwindSafe for TrieFnState<A, T>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V