Struct proptest::strategy::Union[][src]

#[must_use = "strategies do nothing unless used"]pub struct Union<T: Strategy> { /* fields omitted */ }

A Strategy which picks from one of several delegate Stragegys.

See Strategy::prop_union().

Implementations

impl<T: Strategy> Union<T>[src]

pub fn new(options: impl IntoIterator<Item = T>) -> Self[src]

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.

pub fn new_weighted(options: Vec<W<T>>) -> Self[src]

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.

pub fn or(mut self: Self, other: T) -> Self[src]

Add other as an additional alternate strategy with weight 1.

Trait Implementations

impl<T: Clone + Strategy> Clone for Union<T>[src]

impl<T: Debug + Strategy> Debug for Union<T>[src]

impl<T: Strategy> Strategy for Union<T>[src]

type Tree = UnionValueTree<T>

The value tree generated by this Strategy.

type Value = T::Value

The type of value used by functions under test generated by this Strategy. Read more

Auto Trait Implementations

impl<T> Send for Union<T> where
    T: Send + Sync
[src]

impl<T> Sync for Union<T> where
    T: Send + Sync
[src]

impl<T> Unpin for Union<T>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,