pub struct Generator<V, F: Fn() -> V> { /* private fields */ }Expand description
Strategy for generating Vs from an Fn() -> V.
It’s not a very interesting Strategy, but required sometimes
when the only means of creating an object of some type is
via a function while type type is also not Clone.
Implementations§
Trait Implementations§
Source§impl<V: Debug, F: Clone + Fn() -> V> Strategy for Generator<V, F>
impl<V: Debug, F: Clone + Fn() -> V> Strategy for Generator<V, F>
Source§fn new_value(&self, _: &mut TestRunner) -> Result<Self::Value, String>
fn new_value(&self, _: &mut TestRunner) -> Result<Self::Value, String>
Generate a new value tree from the given runner. Read more
Source§fn prop_map<O, F>(self, fun: F) -> Map<Self, F>
fn prop_map<O, F>(self, fun: F) -> Map<Self, F>
Returns a strategy which produces values transformed by the function
fun. Read moreSource§fn prop_perturb<O, F>(self, fun: F) -> Perturb<Self, F>
fn prop_perturb<O, F>(self, fun: F) -> Perturb<Self, F>
Returns a strategy which produces values transformed by the function
fun, which is additionally given a random number generator. Read moreSource§fn prop_flat_map<S, F>(self, fun: F) -> Flatten<Map<Self, F>>
fn prop_flat_map<S, F>(self, fun: F) -> Flatten<Map<Self, F>>
Maps values produced by this strategy into new strategies and picks
values from those strategies. Read more
Source§fn prop_ind_flat_map<S, F>(self, fun: F) -> IndFlatten<Map<Self, F>>
fn prop_ind_flat_map<S, F>(self, fun: F) -> IndFlatten<Map<Self, F>>
Maps values produced by this strategy into new strategies and picks
values from those strategies while considering the new strategies to be
independent. Read more
Source§fn prop_ind_flat_map2<S, F>(self, fun: F) -> IndFlattenMap<Self, F>
fn prop_ind_flat_map2<S, F>(self, fun: F) -> IndFlattenMap<Self, F>
Similar to
prop_ind_flat_map(), but produces 2-tuples with the input
generated from self in slot 0 and the derived strategy in slot 1. Read moreSource§fn prop_filter<F>(self, whence: String, fun: F) -> Filter<Self, F>
fn prop_filter<F>(self, whence: String, fun: F) -> Filter<Self, F>
Returns a strategy which only produces values accepted by
fun. Read moreSource§fn prop_union(self, other: Self) -> Union<Self>where
Self: Sized,
fn prop_union(self, other: Self) -> Union<Self>where
Self: Sized,
Source§fn prop_recursive<F>(
self,
depth: u32,
desired_size: u32,
expected_branch_size: u32,
recurse: F,
) -> Recursive<Box<dyn Strategy<Value = Box<dyn ValueTree<Value = <Self::Value as ValueTree>::Value>>>>, F>
fn prop_recursive<F>( self, depth: u32, desired_size: u32, expected_branch_size: u32, recurse: F, ) -> Recursive<Box<dyn Strategy<Value = Box<dyn ValueTree<Value = <Self::Value as ValueTree>::Value>>>>, F>
Generate a recursive structure with
self items as leaves. Read moreSource§fn prop_shuffle(self) -> Shuffle<Self>
fn prop_shuffle(self) -> Shuffle<Self>
Shuffle the contents of the values produced by this strategy. Read more
Source§fn boxed(
self,
) -> Box<dyn Strategy<Value = Box<dyn ValueTree<Value = <Self::Value as ValueTree>::Value>>>>where
Self: Sized + 'static,
fn boxed(
self,
) -> Box<dyn Strategy<Value = Box<dyn ValueTree<Value = <Self::Value as ValueTree>::Value>>>>where
Self: Sized + 'static,
Erases the type of this
Strategy so it can be passed around as a
simple trait object. Read moreSource§impl<V: Debug, F: Fn() -> V> ValueTree for Generator<V, F>
impl<V: Debug, F: Fn() -> V> ValueTree for Generator<V, F>
Source§fn simplify(&mut self) -> bool
fn simplify(&mut self) -> bool
Attempts to simplify the current value. Notionally, this sets the
“high” value to the current value, and the current value to a “halfway
point” between high and low, rounding towards low. Read more
Source§fn complicate(&mut self) -> bool
fn complicate(&mut self) -> bool
Attempts to partially undo the last simplification. Notionally, this
sets the “low” value to one plus the current value, and the current
value to a “halfway point” between high and the new low, rounding
towards low. Read more
impl<V: Copy, F: Copy + Fn() -> V> Copy for Generator<V, F>
Auto Trait Implementations§
impl<V, F> Freeze for Generator<V, F>where
F: Freeze,
impl<V, F> RefUnwindSafe for Generator<V, F>where
F: RefUnwindSafe,
impl<V, F> Send for Generator<V, F>where
F: Send,
impl<V, F> Sync for Generator<V, F>where
F: Sync,
impl<V, F> Unpin for Generator<V, F>where
F: Unpin,
impl<V, F> UnwindSafe for Generator<V, F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more