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) -> TupleUnion<T>
impl<T: Copy> Copy for TupleUnion<T>
impl<T: Debug> Debug for TupleUnion<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<T> Freeze for TupleUnion<T>
where
T: Freeze,
impl<T> RefUnwindSafe for TupleUnion<T>
where
T: RefUnwindSafe,
impl<T> Send for TupleUnion<T>
where
T: Send,
impl<T> Sync for TupleUnion<T>
where
T: Sync,
impl<T> Unpin for TupleUnion<T>
where
T: Unpin,
impl<T> UnsafeUnpin for TupleUnion<T>
where
T: UnsafeUnpin,
impl<T> UnwindSafe for TupleUnion<T>
where
T: UnwindSafe,
Blanket Implementations
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for TupleUnion<T>
where
ST: ?Sized,
DT: ?Sized,
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for TupleUnion<T>
where
ST: ?Sized,
DT: ?Sized,
impl<T> Any for TupleUnion<T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for TupleUnion<T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for TupleUnion<T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for TupleUnion<T>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for TupleUnion<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Read<Exclusive, BecauseExclusive> for TupleUnion<T>
where
T: ?Sized,
impl<T> ToOwned for TupleUnion<T>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for TupleUnion<T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for TupleUnion<T>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for TupleUnion<T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<V, T> VZip<V> for TupleUnion<T>
where
V: MultiLane<T>,
fn vzip(self) -> V