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) -> Self

Directly 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 uniformXX functions at module-level unless something precludes their use.

Trait Implementations

impl<S: Clone, T: Clone> Clone for UniformArrayStrategy<S, T>

fn clone(&self) -> UniformArrayStrategy<S, T>

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>

Auto Trait Implementations

impl<S, T> Freeze for UniformArrayStrategy<S, T> where S: Freeze, PhantomData<T>: Freeze,

impl<S, T> RefUnwindSafe for UniformArrayStrategy<S, T> where S: RefUnwindSafe, PhantomData<T>: RefUnwindSafe,

impl<S, T> Send for UniformArrayStrategy<S, T> where S: Send, PhantomData<T>: Send,

impl<S, T> Sync for UniformArrayStrategy<S, T> where S: Sync, PhantomData<T>: Sync,

impl<S, T> Unpin for UniformArrayStrategy<S, T> where S: Unpin, PhantomData<T>: Unpin,

impl<S, T> UnsafeUnpin for UniformArrayStrategy<S, T> where S: UnsafeUnpin, PhantomData<T>: UnsafeUnpin,

impl<S, T> UnwindSafe for UniformArrayStrategy<S, T> where S: UnwindSafe, PhantomData<T>: UnwindSafe,

Blanket Implementations

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for UniformArrayStrategy<S, T> where ST: ?Sized, DT: ?Sized,

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for UniformArrayStrategy<S, T> where ST: ?Sized, DT: ?Sized,

impl<T> Any for UniformArrayStrategy<S, T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for UniformArrayStrategy<S, T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for UniformArrayStrategy<S, T> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for UniformArrayStrategy<S, T> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for UniformArrayStrategy<S, T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Read<Exclusive, BecauseExclusive> for UniformArrayStrategy<S, T> where T: ?Sized,

impl<T> ToOwned for UniformArrayStrategy<S, T> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for UniformArrayStrategy<S, T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for UniformArrayStrategy<S, T> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for UniformArrayStrategy<S, T> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

impl<V, T> VZip<V> for UniformArrayStrategy<S, T> where V: MultiLane<T>,

fn vzip(self) -> V