Struct Union
#[must_use = "strategies do nothing unless used"]
pub struct Union<T: Strategy> { /* private fields */ }
A Strategy which picks from one of several delegate Strategys.
See Strategy::prop_union().
Implementations
impl<T: Strategy> Union<T>
fn new(options: impl IntoIterator<Item = T>) -> SelfCreate a strategy which selects uniformly from the given delegate strategies.
When shrinking, after maximal simplification of the chosen element, the strategy will move to earlier options and continue simplification with those.
Panics
Panics if
optionsis empty.fn new_weighted(options: Vec<W<T>>) -> SelfCreate a strategy which selects from the given delegate strategies.
Each strategy is assigned a non-zero weight which determines how frequently that strategy is chosen. For example, a strategy with a weight of 2 will be chosen twice as frequently as one with a weight of 1.
Panics
Panics if
optionsis empty or any element has a weight of 0.Panics if the sum of the weights overflows a
u32.fn or(self, other: T) -> SelfAdd
otheras an additional alternate strategy with weight 1.
Trait Implementations
impl<T: Clone + Strategy> Clone for Union<T>
fn clone(&self) -> Self
impl<T: Debug + Strategy> Debug for Union<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T: Strategy> Strategy for Union<T>
type Tree = UnionValueTree<T>;type Value = <T as Strategy>::Value;fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
Auto Trait Implementations
impl<T> Freeze for Union<T>
where
Vec<(u32, Arc<T>)>: Freeze,
impl<T> RefUnwindSafe for Union<T>
where
Vec<(u32, Arc<T>)>: RefUnwindSafe,
impl<T> Send for Union<T>
where
Vec<(u32, Arc<T>)>: Send,
impl<T> Sync for Union<T>
where
Vec<(u32, Arc<T>)>: Sync,
impl<T> Unpin for Union<T>
where
Vec<(u32, Arc<T>)>: Unpin,
impl<T> UnsafeUnpin for Union<T>
where
Vec<(u32, Arc<T>)>: UnsafeUnpin,
impl<T> UnwindSafe for Union<T>
where
Vec<(u32, Arc<T>)>: UnwindSafe,
Blanket Implementations
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for Union<T>
where
ST: ?Sized,
DT: ?Sized,
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for Union<T>
where
ST: ?Sized,
DT: ?Sized,
impl<T> Any for Union<T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Union<T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Union<T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Union<T>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Union<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Read<Exclusive, BecauseExclusive> for Union<T>
where
T: ?Sized,
impl<T> ToOwned for Union<T>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for Union<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 Union<T>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Union<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 Union<T>
where
V: MultiLane<T>,
fn vzip(self) -> V