proptest::sample

Function select

source
pub fn select<T: Clone + Debug + 'static>(
    values: impl Into<Cow<'static, [T]>>,
) -> Select<T>
Expand description

Create a strategy which uniformly selects one value from values.

values should be a &'static [T] or a Vec<T>, or potentially another type that can be coerced to Cow<'static,[T]>.

This is largely equivalent to making a Union of a bunch of Just strategies, but is substantially more efficient and shrinks by binary search.

If values is also to be generated by a strategy, see Index for a more efficient way to select values than using prop_flat_map().