Struct UniformArrayStrategy
#[must_use = "strategies do nothing unless used"]
pub struct UniformArrayStrategy<S, T> { /* private fields */ }
A Strategy which generates fixed-size arrays containing values drawn from
an inner strategy.
T must be an array type of length 1 to 32 whose values are produced by
strategy S. Instances of this type are normally created by the various
uniformXX functions in this module.
This is mainly useful when the inner strategy is not Copy, precluding
expressing the strategy as [myStrategy; 32], for example.
Example
use proptest::prelude::*;
proptest! {
#[test]
fn test_something(a in prop::array::uniform32(1u32..)) {
let unexpected = [0u32;32];
// `a` is also a [u32;32], so we can compare them directly
assert_ne!(unexpected, a);
}
}
# fn main() { }
Implementations
impl<S, T> UniformArrayStrategy<S, T>
fn new(strategy: S) -> SelfDirectly create a
UniformArrayStrategy.This is only intended for advanced use, since the only way to specify the array size is with the turbofish operator and explicitly naming the type of the values in the array and the strategy itself.
Prefer the
uniformXXfunctions at module-level unless something precludes their use.
Trait Implementations
impl<S: Clone, T: Clone> Clone for UniformArrayStrategy<S, T>
fn clone(&self) -> Self
impl<S: Copy, T: Copy> Copy for UniformArrayStrategy<S, T>
impl<S: Debug, T: Debug> Debug for UniformArrayStrategy<S, T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<S: Strategy, const N: usize> Strategy for UniformArrayStrategy<S, [S::Value; N]>
type Tree = ArrayValueTree<[<S as Strategy>::Tree; N]>;type Value = [<S as Strategy>::Value; N];fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>