pub struct Selector { /* fields omitted */ }
A value for picking random values out of iterators.
This is, in a sense, a more flexible variant of
Index
in that it can operate on arbitrary
IntoIterator
values.
Initially, the selection is roughly uniform, with a very slight bias
towards items earlier in the iterator.
Shrinking causes the selection to move toward items earlier in the
iterator, ultimately settling on the very first, but this currently happens
in a very haphazard way that may fail to find the earliest failing input.
Generate a non-indexable collection and a value to pick out of it.
use proptest::prelude::*;
proptest! {
#[test]
fn my_test(
names in prop::collection::hash_set("[a-z]+", 10..20),
selector in any::<prop::sample::Selector>()
) {
println!("Selected name: {}", selector.select(&names));
}
}
Pick a random element from iterable it
.
The selection is unaffected by the elements themselves, and is
dependent only on the actual length of it
.
it
is always iterated completely.
Panics if it
has no elements.
Pick a random element from iterable it
.
Returns None
if it
is empty.
The selection is unaffected by the elements themselves, and is
dependent only on the actual length of it
.
it
is always iterated completely.
The type of parameters that [arbitrary_with
] accepts for configuration of the generated [Strategy
]. Parameters must implement [Default
]. Read more
The type of [Strategy
] used to generate values of type Self
. Read more
Generates a [Strategy
] for producing arbitrary values of type the implementing type (Self
). The strategy is passed the arguments given in args. Read more
Generates a [Strategy
] for producing arbitrary values of type the implementing type (Self
). Read more
Formats the value using the given formatter. Read more
Performs copy-assignment from source
. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more