Trait jaq_interpret::FilterT

source ·
pub trait FilterT<'a, V: ValT = Val>: Clone + 'a {
    // Required methods
    fn run(
        self,
        cv: (Ctx<'a, V>, V)
    ) -> Box<dyn Iterator<Item = Result<V, Error<V>>> + 'a>;
    fn update(
        self,
        cv: (Ctx<'a, V>, V),
        f: Box<dyn Update<'a, V> + 'a>
    ) -> Box<dyn Iterator<Item = Result<V, Error<V>>> + 'a>;

    // Provided methods
    fn pipe<T: 'a, F>(
        self,
        cv: (Ctx<'a, V>, V),
        f: F
    ) -> Results<'a, T, Error<V>>
       where F: Fn((Ctx<'a, V>, V), V) -> Results<'a, T, Error<V>> + 'a { ... }
    fn cartesian(
        self,
        r: Self,
        cv: (Ctx<'a, V>, V)
    ) -> Box<dyn Iterator<Item = (Result<V, Error<V>>, Result<V, Error<V>>)> + 'a> { ... }
    fn cartesian3(
        self,
        m: Self,
        r: Self,
        cv: (Ctx<'a, V>, V)
    ) -> Box<dyn Iterator<Item = (Result<V, Error<V>>, Result<V, Error<V>>, Result<V, Error<V>>)> + 'a> { ... }
    fn recurse(
        self,
        inner: bool,
        outer: bool,
        cv: (Ctx<'a, V>, V)
    ) -> Box<dyn Iterator<Item = Result<V, Error<V>>> + '_> { ... }
    fn recurse_update(
        self,
        cv: (Ctx<'a, V>, V),
        f: Box<dyn Update<'a, V> + 'a>
    ) -> Box<dyn Iterator<Item = Result<V, Error<V>>> + 'a> { ... }
}
Expand description

Function from a value to a stream of value results.

Required Methods§

source

fn run( self, cv: (Ctx<'a, V>, V) ) -> Box<dyn Iterator<Item = Result<V, Error<V>>> + 'a>

f.run((c, v)) returns the output of v | f in the context c.

source

fn update( self, cv: (Ctx<'a, V>, V), f: Box<dyn Update<'a, V> + 'a> ) -> Box<dyn Iterator<Item = Result<V, Error<V>>> + 'a>

p.update((c, v), f) returns the output of v | p |= f in the context c.

Provided Methods§

source

fn pipe<T: 'a, F>(self, cv: (Ctx<'a, V>, V), f: F) -> Results<'a, T, Error<V>>
where F: Fn((Ctx<'a, V>, V), V) -> Results<'a, T, Error<V>> + 'a,

For every value v returned by self.run(cv), call f(cv, v) and return all results.

This has a special optimisation for the case where only a single v is returned. In that case, we can consume cv instead of cloning it.

source

fn cartesian( self, r: Self, cv: (Ctx<'a, V>, V) ) -> Box<dyn Iterator<Item = (Result<V, Error<V>>, Result<V, Error<V>>)> + 'a>

Run self and r and return the cartesian product of their outputs.

source

fn cartesian3( self, m: Self, r: Self, cv: (Ctx<'a, V>, V) ) -> Box<dyn Iterator<Item = (Result<V, Error<V>>, Result<V, Error<V>>, Result<V, Error<V>>)> + 'a>

Run self, m, and r, and return the cartesian product of their outputs.

source

fn recurse( self, inner: bool, outer: bool, cv: (Ctx<'a, V>, V) ) -> Box<dyn Iterator<Item = Result<V, Error<V>>> + '_>

👎Deprecated since 1.2.0

Return the output of recurse(f) if inner and outer are true.

This function implements a generalisation of recurse(f): if inner is true, it returns values for which f yields at least one output, and if outer is true, it returns values for which f yields no output. This is useful to implement while and until.

source

fn recurse_update( self, cv: (Ctx<'a, V>, V), f: Box<dyn Update<'a, V> + 'a> ) -> Box<dyn Iterator<Item = Result<V, Error<V>>> + 'a>

👎Deprecated since 1.2.0

Return the output of recurse(l) |= f.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'a, V: ValT> FilterT<'a, V> for &'a Owned<V>