Function proptest_arbitrary::arbitrary_with [] [src]

pub fn arbitrary_with<'a, A, S, V, P>(args: P) -> S where
    P: Default,
    V: ValueTree<Value = A>,
    S: Strategy<Value = V>,
    A: Arbitrary<'a, Strategy = S, ValueTree = V, Parameters = P>, 

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::<A>()] 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_arbitrary;
use proptest_arbitrary::{arbitrary_with, StrategyFor, size_bounds};

fn gen_vec_5_u32() -> StrategyFor<Vec<u32>> {
    arbitrary_with(size_bounds(10).lift())
}