pub trait RandomStrategy {
type Functor<I: Inner>: Functor<I>;
// Required methods
fn fmap<A: Inner, B: Inner, F: Fn(A) -> B>(
f: Self::Functor<A>,
func: F,
) -> Self::Functor<B>;
fn fmap_rand<A: Inner, B: Inner, R: RandomVariable, F: Fn(A, R) -> B>(
f: Self::Functor<A>,
rng: &mut impl Rng,
func: F,
) -> Self::Functor<B>
where StandardUniform: Distribution<R>;
fn fmap_rand_range<A: Inner, B: Inner, R: RandomVariable + SampleUniform, F: Fn(A, R) -> B>(
f: Self::Functor<A>,
range: impl RandomVariableRange<R>,
rng: &mut impl Rng,
func: F,
) -> Self::Functor<B>
where StandardUniform: Distribution<R>;
}Expand description
A strategy for evaluating sequences of functions of random data.
Types implementing RandomStrategy are typically not constructed. For this
same reason, they are typically unit structs. Behaviour should be specified
at compile-time, to allow calls to fmap_rand and Functor::fmap to be
properly inlined.
Required Associated Types§
Required Methods§
Sourcefn fmap<A: Inner, B: Inner, F: Fn(A) -> B>(
f: Self::Functor<A>,
func: F,
) -> Self::Functor<B>
fn fmap<A: Inner, B: Inner, F: Fn(A) -> B>( f: Self::Functor<A>, func: F, ) -> Self::Functor<B>
Applies the given function to the functor’s inner.
Sourcefn fmap_rand<A: Inner, B: Inner, R: RandomVariable, F: Fn(A, R) -> B>(
f: Self::Functor<A>,
rng: &mut impl Rng,
func: F,
) -> Self::Functor<B>where
StandardUniform: Distribution<R>,
fn fmap_rand<A: Inner, B: Inner, R: RandomVariable, F: Fn(A, R) -> B>(
f: Self::Functor<A>,
rng: &mut impl Rng,
func: F,
) -> Self::Functor<B>where
StandardUniform: Distribution<R>,
Using the strategy specified by the implementor, applies the given
binary function to the given functor and an element of the sample space
of a RandomVariable.
Note that no guarantees are made about whether or how the rand
parameter will be used. It may be sampled zero, one, or arbitrarily many
times. It may be used to sample values of type R, of type usize,
or some other type. If some model of the random number generator is
available, then that model should be responsible for enumerating
possible outcomes.
Sourcefn fmap_rand_range<A: Inner, B: Inner, R: RandomVariable + SampleUniform, F: Fn(A, R) -> B>(
f: Self::Functor<A>,
range: impl RandomVariableRange<R>,
rng: &mut impl Rng,
func: F,
) -> Self::Functor<B>where
StandardUniform: Distribution<R>,
fn fmap_rand_range<A: Inner, B: Inner, R: RandomVariable + SampleUniform, F: Fn(A, R) -> B>(
f: Self::Functor<A>,
range: impl RandomVariableRange<R>,
rng: &mut impl Rng,
func: F,
) -> Self::Functor<B>where
StandardUniform: Distribution<R>,
Using the strategy specified by the implementor, applies the given
binary function to the given functor and an element of the sample space
of a RandomVariableRange.
Note that no guarantees are made about whether or how the rand
parameter will be used. It may be sampled zero, one, or arbitrarily many
times. It may be used to sample values of type R, of type usize,
or some other type. If some model of the random number generator is
available, then that model should be responsible for enumerating
possible outcomes.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.