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>) -> Self

Create 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 options is empty.

fn new_weighted(options: Vec<W<T>>) -> Self

Create 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 options is empty or any element has a weight of 0.

Panics if the sum of the weights overflows a u32.

fn or(self, other: T) -> Self

Add other as 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<T> Any for Union<T> where T: 'static + ?Sized,

impl<T> Borrow<T> for Union<T> where T: ?Sized,

impl<T> BorrowMut<T> for Union<T> where T: ?Sized,

impl<T> CloneToUninit for Union<T> where T: Clone,

impl<T> From<T> for Union<T>

impl<T> ToOwned for Union<T> where T: Clone,

impl<T, U> Into<U> for Union<T> where U: From<T>,

impl<T, U> TryFrom<U> for Union<T> where U: Into<T>,

impl<T, U> TryInto<U> for Union<T> where U: TryFrom<T>,