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>