zebra_test::prelude::prop::arbitrary

Function any

pub fn any<A>() -> <A as Arbitrary>::Strategy
where A: Arbitrary,
Expand description

Generates a Strategy producing Arbitrary values of A. Unlike arbitrary, it should be used for being explicit on what A is. For clarity, this may be a good idea.

Use this version instead of arbitrary if you want to be clear which type you want to generate a Strategy for, or if you don’t have an anchoring type for type inference to work with.

If you want to customize how the strategy is generated, use any_with::<A>(args) where args are any arguments accepted by the Arbitrary impl in question.

§Example

The function can be used as:

use proptest::prelude::*;

proptest! {
    fn reverse_reverse_is_identity(ref vec in any::<Vec<u32>>()) {
        let vec2 = vec.iter().cloned().rev().rev().collect::<Vec<u32>>();
        prop_assert_eq!(vec, &vec2);
    }
}

fn main() {
    reverse_reverse_is_identity();
}