Function proptest::arbitrary::arbitrary_with
source · pub fn arbitrary_with<A, S, P>(args: P) -> S
Expand description
Generates a Strategy
producing Arbitrary
values of A
with the
given configuration arguments passed in args
.
Works better with type inference than any_with::<A>(args)
.
With this version, you shouldn’t need to specify any of the (many) type
parameters explicitly. This can have a positive effect on type inference.
However, if you want specify A
, you should use
any_with::<A>(args)
instead.
For clarity, it is often a good idea to specify the type generated, and
so using any_with::<A>(args)
can be a good idea.
If you don’t want to specify any arguments and instead use the default
behavior, you should use arbitrary()
.
§Example
The function can be used as:
extern crate proptest;
use proptest::arbitrary::{arbitrary_with, StrategyFor};
use proptest::collection::size_range;
fn gen_vec_10_u32() -> StrategyFor<Vec<u32>> {
arbitrary_with(size_range(10).lift())
}