proptest_arbitrary/_std/
result.rs

1//! Arbitrary implementations for `std::result`.
2//! 
3use super::*;
4use std::result::IntoIter;
5use proptest::result;
6
7// We assume that `MaybeOk` is canonical as it's the most likely Strategy
8// a user wants.
9
10arbitrary!([A: Arbitrary<'a>, B: Arbitrary<'a>] Result<A, B>,
11    result::MaybeOk<A::Strategy, B::Strategy>,
12    product_type![Probability, A::Parameters, B::Parameters];
13    args => {
14        let product_unpack![prob, a, b] = args;
15        let (p, a, b) = (prob.into(), any_with::<A>(a), any_with::<B>(b));
16        result::maybe_ok_weighted(p, a, b)
17    }
18);
19
20arbitrary!([A: Arbitrary<'a>] IntoIter<A>,
21    SMapped<'a, Result<A, ()>, Self>,
22    <Result<A, ()> as Arbitrary<'a>>::Parameters;
23    args => any_with_smap(args, Result::into_iter)
24);
25
26#[cfg(test)]
27mod test {
28    no_panic_test!(
29        result    => Result<u8, u16>,
30        into_iter => IntoIter<u8>
31    );
32}