Struct TupleUnion
#[must_use = "strategies do nothing unless used"]
pub struct TupleUnion<T>(/* private field */);
Similar to Union, but internally uses a tuple to hold the strategies.
This allows better performance than vanilla Union since one does not need
to resort to boxing and dynamic dispatch to handle heterogeneous
strategies.
The difference between this and TupleUnion is that with this, value trees
for variants that aren't picked at first are generated lazily.
Implementations
impl<T> TupleUnion<T>
fn new(tuple: T) -> SelfWrap
tuplein aTupleUnion.The struct definition allows any
Tfortuple, but to be useful, it must be a 2- to 10-tuple of(u32, Arc<impl Strategy>)pairs where all strategies ultimately produce the same value. Eachu32indicates the relative weight of its corresponding strategy. You may useWA<S>as an alias for(u32, Arc<S>).Using this constructor directly is discouraged; prefer to use
prop_oneof!since it is generally clearer.
Trait Implementations
impl<A: Strategy, B: Strategy<Value = A::Value>> Strategy for TupleUnion<(WA<A>, WA<B>)>
type Tree = TupleUnionValueTree<(LazyValueTree<A>, Option<LazyValueTree<B>>)>;type Value = <A as Strategy>::Value;fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
impl<A: Strategy, B: Strategy<Value = A::Value>, C: Strategy<Value = A::Value>> Strategy for TupleUnion<(WA<A>, WA<B>, WA<C>)>
type Tree = TupleUnionValueTree<(LazyValueTree<A>, Option<LazyValueTree<B>>, Option<LazyValueTree<C>>)>;type Value = <A as Strategy>::Value;fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
impl<A: Strategy, B: Strategy<Value = A::Value>, C: Strategy<Value = A::Value>, D: Strategy<Value = A::Value>> Strategy for TupleUnion<(WA<A>, WA<B>, WA<C>, WA<D>)>
type Tree = TupleUnionValueTree<(LazyValueTree<A>, Option<LazyValueTree<B>>, Option<LazyValueTree<C>>, Option<LazyValueTree<D>>)>;type Value = <A as Strategy>::Value;fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
impl<A: Strategy, B: Strategy<Value = A::Value>, C: Strategy<Value = A::Value>, D: Strategy<Value = A::Value>, E: Strategy<Value = A::Value>> Strategy for TupleUnion<(WA<A>, WA<B>, WA<C>, WA<D>, WA<E>)>
type Tree = TupleUnionValueTree<(LazyValueTree<A>, Option<LazyValueTree<B>>, Option<LazyValueTree<C>>, Option<LazyValueTree<D>>, Option<LazyValueTree<E>>)>;type Value = <A as Strategy>::Value;fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
impl<A: Strategy, B: Strategy<Value = A::Value>, C: Strategy<Value = A::Value>, D: Strategy<Value = A::Value>, E: Strategy<Value = A::Value>, F: Strategy<Value = A::Value>> Strategy for TupleUnion<(WA<A>, WA<B>, WA<C>, WA<D>, WA<E>, WA<F>)>
type Tree = TupleUnionValueTree<(LazyValueTree<A>, Option<LazyValueTree<B>>, Option<LazyValueTree<C>>, Option<LazyValueTree<D>>, Option<LazyValueTree<E>>, Option<LazyValueTree<F>>)>;type Value = <A as Strategy>::Value;fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
impl<A: Strategy, B: Strategy<Value = A::Value>, C: Strategy<Value = A::Value>, D: Strategy<Value = A::Value>, E: Strategy<Value = A::Value>, F: Strategy<Value = A::Value>, G: Strategy<Value = A::Value>> Strategy for TupleUnion<(WA<A>, WA<B>, WA<C>, WA<D>, WA<E>, WA<F>, WA<G>)>
type Tree = TupleUnionValueTree<(LazyValueTree<A>, Option<LazyValueTree<B>>, Option<LazyValueTree<C>>, Option<LazyValueTree<D>>, Option<LazyValueTree<E>>, Option<LazyValueTree<F>>, Option<LazyValueTree<G>>)>;type Value = <A as Strategy>::Value;fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
impl<A: Strategy, B: Strategy<Value = A::Value>, C: Strategy<Value = A::Value>, D: Strategy<Value = A::Value>, E: Strategy<Value = A::Value>, F: Strategy<Value = A::Value>, G: Strategy<Value = A::Value>, H: Strategy<Value = A::Value>> Strategy for TupleUnion<(WA<A>, WA<B>, WA<C>, WA<D>, WA<E>, WA<F>, WA<G>, WA<H>)>
type Tree = TupleUnionValueTree<(LazyValueTree<A>, Option<LazyValueTree<B>>, Option<LazyValueTree<C>>, Option<LazyValueTree<D>>, Option<LazyValueTree<E>>, Option<LazyValueTree<F>>, Option<LazyValueTree<G>>, Option<LazyValueTree<H>>)>;type Value = <A as Strategy>::Value;fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
impl<A: Strategy, B: Strategy<Value = A::Value>, C: Strategy<Value = A::Value>, D: Strategy<Value = A::Value>, E: Strategy<Value = A::Value>, F: Strategy<Value = A::Value>, G: Strategy<Value = A::Value>, H: Strategy<Value = A::Value>, I: Strategy<Value = A::Value>> Strategy for TupleUnion<(WA<A>, WA<B>, WA<C>, WA<D>, WA<E>, WA<F>, WA<G>, WA<H>, WA<I>)>
type Tree = TupleUnionValueTree<(LazyValueTree<A>, Option<LazyValueTree<B>>, Option<LazyValueTree<C>>, Option<LazyValueTree<D>>, Option<LazyValueTree<E>>, Option<LazyValueTree<F>>, Option<LazyValueTree<G>>, Option<LazyValueTree<H>>, Option<LazyValueTree<I>>)>;type Value = <A as Strategy>::Value;fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
impl<A: Strategy, B: Strategy<Value = A::Value>, C: Strategy<Value = A::Value>, D: Strategy<Value = A::Value>, E: Strategy<Value = A::Value>, F: Strategy<Value = A::Value>, G: Strategy<Value = A::Value>, H: Strategy<Value = A::Value>, I: Strategy<Value = A::Value>, J: Strategy<Value = A::Value>> Strategy for TupleUnion<(WA<A>, WA<B>, WA<C>, WA<D>, WA<E>, WA<F>, WA<G>, WA<H>, WA<I>, WA<J>)>
type Tree = TupleUnionValueTree<(LazyValueTree<A>, Option<LazyValueTree<B>>, Option<LazyValueTree<C>>, Option<LazyValueTree<D>>, Option<LazyValueTree<E>>, Option<LazyValueTree<F>>, Option<LazyValueTree<G>>, Option<LazyValueTree<H>>, Option<LazyValueTree<I>>, Option<LazyValueTree<J>>)>;type Value = <A as Strategy>::Value;fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
impl<T: Clone> Clone for TupleUnion<T>
fn clone(&self) -> Self
impl<T: Copy> Copy for TupleUnion<T>
impl<T: Debug> Debug for TupleUnion<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result