```
pub trait Arbitrary: Sized + Debug {
type Parameters: Default;
type Strategy: Strategy<Value = Self>;
// Required method
fn arbitrary_with(args: Self::Parameters) -> Self::Strategy;
// Provided method
fn arbitrary() -> Self::Strategy { ... }
}
```

## Expand description

Arbitrary determines a canonical `Strategy`

for the implementing type.

It provides the method `arbitrary_with`

which generates a `Strategy`

for
producing arbitrary values of the implementing type *( Self)*. In general,
these strategies will produce the entire set of values possible for the
type, up to some size limitation or constraints set by their parameters.
When this is not desired, strategies to produce the desired values can be
built by combining

`Strategy`

s as described in the crate documentation.This trait analogous to
Haskell QuickCheck’s implementation of `Arbitrary`

.
In this interpretation of `Arbitrary`

, `Strategy`

is the equivalent of
the `Gen`

monad. Unlike in QuickCheck, `Arbitrary`

is not a core component;
types do not need to implement `Arbitrary`

unless one wants to use
`any`

or other free functions in this module.

`Arbitrary`

currently only works for types which represent owned data as
opposed to borrowed data. This is a fundamental restriction of `proptest`

which may be lifted in the future as the generic associated types (GAT)
feature of Rust is implemented and stabilized.

## Required Associated Types§

source#### type Parameters: Default

#### type Parameters: Default

The type of parameters that `arbitrary_with`

accepts for configuration
of the generated `Strategy`

. Parameters must implement `Default`

.

## Required Methods§

source#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

## Provided Methods§

source#### fn arbitrary() -> Self::Strategy

#### fn arbitrary() -> Self::Strategy

Generates a `Strategy`

for producing arbitrary values
of type the implementing type (`Self`

).

Calling this for the type `X`

is the equivalent of using
`X::arbitrary_with(Default::default())`

.

This method is defined in the trait for optimization for the default if you want to do that. It is a logic error to not preserve the semantics when overriding.

## Implementations on Foreign Types§

source§### impl<A: Arbitrary> Arbitrary for Discriminant<A>

### impl<A: Arbitrary> Arbitrary for Discriminant<A>

#### type Parameters = <A as Arbitrary>::Parameters

#### type Strategy = Map<<A as Arbitrary>::Strategy, fn(_: A) -> Discriminant<A>>

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl<A: Arbitrary + Ord, B: Arbitrary> Arbitrary for BTreeMap<A, B>

### impl<A: Arbitrary + Ord, B: Arbitrary> Arbitrary for BTreeMap<A, B>

#### type Parameters = (SizeRange, <A as Arbitrary>::Parameters, <B as Arbitrary>::Parameters)

#### type Strategy = BTreeMapStrategy<<A as Arbitrary>::Strategy, <B as Arbitrary>::Strategy>

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl<A: Arbitrary> Arbitrary for Wrapping<A>

### impl<A: Arbitrary> Arbitrary for Wrapping<A>

#### type Parameters = <A as Arbitrary>::Parameters

#### type Strategy = Map<<A as Arbitrary>::Strategy, fn(_: A) -> Wrapping<A>>

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for Arc<str>

### impl Arbitrary for Arc<str>

#### type Parameters = StringParam

#### type Strategy = MapInto<<String as Arbitrary>::Strategy, Arc<str>>

#### fn arbitrary_with(a: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for EscapeDefault

### impl Arbitrary for EscapeDefault

#### type Parameters = ()

#### type Strategy = Map<<u8 as Arbitrary>::Strategy, fn(_: u8) -> EscapeDefault>

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for WaitTimeoutResult

### impl Arbitrary for WaitTimeoutResult

#### type Parameters = ()

#### type Strategy = TupleUnion<((u32, Arc<Just<WaitTimeoutResult>>), (u32, Arc<Just<WaitTimeoutResult>>))>

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl<P: Clone + Default, T: Arbitrary<Parameters = P>> Arbitrary for TrySendError<T>

### impl<P: Clone + Default, T: Arbitrary<Parameters = P>> Arbitrary for TrySendError<T>

#### type Parameters = P

#### type Strategy = TupleUnion<((u32, Arc<Map<<T as Arbitrary>::Strategy, fn(_: T) -> TrySendError<T>>>), (u32, Arc<Map<<T as Arbitrary>::Strategy, fn(_: T) -> TrySendError<T>>>))>

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl<T0: Arbitrary, T1: Arbitrary, T2: Arbitrary, T3: Arbitrary, T4: Arbitrary, T5: Arbitrary, T6: Arbitrary> Arbitrary for (T0, T1, T2, T3, T4, T5, T6)

### impl<T0: Arbitrary, T1: Arbitrary, T2: Arbitrary, T3: Arbitrary, T4: Arbitrary, T5: Arbitrary, T6: Arbitrary> Arbitrary for (T0, T1, T2, T3, T4, T5, T6)

#### type Parameters = (<T0 as Arbitrary>::Parameters, <T1 as Arbitrary>::Parameters, <T2 as Arbitrary>::Parameters, <T3 as Arbitrary>::Parameters, <T4 as Arbitrary>::Parameters, <T5 as Arbitrary>::Parameters, <T6 as Arbitrary>::Parameters)

#### type Strategy = (<T0 as Arbitrary>::Strategy, <T1 as Arbitrary>::Strategy, <T2 as Arbitrary>::Strategy, <T3 as Arbitrary>::Strategy, <T4 as Arbitrary>::Strategy, <T5 as Arbitrary>::Strategy, <T6 as Arbitrary>::Strategy)

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for Instant

### impl Arbitrary for Instant

#### type Parameters = ()

#### type Strategy = Just<Instant>

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl<A: Arbitrary + Read> Arbitrary for BufReader<A>

### impl<A: Arbitrary + Read> Arbitrary for BufReader<A>

#### type Parameters = <A as Arbitrary>::Parameters

#### type Strategy = Map<<(A, Option<u16>) as Arbitrary>::Strategy, fn(_: (A, Option<u16>)) -> BufReader<A>>

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for OsString

### impl Arbitrary for OsString

#### type Parameters = <String as Arbitrary>::Parameters

#### type Strategy = MapInto<<String as Arbitrary>::Strategy, OsString>

#### fn arbitrary_with(a: Self::Parameters) -> Self::Strategy

source§### impl<A: Arbitrary> Arbitrary for RefCell<A>

### impl<A: Arbitrary> Arbitrary for RefCell<A>

#### type Parameters = <A as Arbitrary>::Parameters

#### type Strategy = MapInto<<A as Arbitrary>::Strategy, RefCell<A>>

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for i64

### impl Arbitrary for i64

#### type Parameters = ()

#### type Strategy = Any

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for u32

### impl Arbitrary for u32

#### type Parameters = ()

#### type Strategy = Any

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for ParseBoolError

### impl Arbitrary for ParseBoolError

#### type Parameters = ()

#### type Strategy = Just<ParseBoolError>

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl<A: Arbitrary + Write> Arbitrary for LineWriter<A>

### impl<A: Arbitrary + Write> Arbitrary for LineWriter<A>

#### type Parameters = <A as Arbitrary>::Parameters

#### type Strategy = Map<<(A, Option<u16>) as Arbitrary>::Strategy, fn(_: (A, Option<u16>)) -> LineWriter<A>>

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for CString

### impl Arbitrary for CString

#### type Parameters = SizeRange

#### type Strategy = Map<VecStrategy<RangeInclusive<u8>>, fn(_: <VecStrategy<RangeInclusive<u8>> as Strategy>::Value) -> CString>

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl<T, A: Arbitrary + Iterator<Item = T>, B: Arbitrary + Iterator<Item = T>> Arbitrary for Chain<A, B>

### impl<T, A: Arbitrary + Iterator<Item = T>, B: Arbitrary + Iterator<Item = T>> Arbitrary for Chain<A, B>

#### type Parameters = (<A as Arbitrary>::Parameters, <B as Arbitrary>::Parameters)

#### type Strategy = Map<<(A, B) as Arbitrary>::Strategy, fn(_: (A, B)) -> Chain<A, B>>

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for SocketAddrV6

### impl Arbitrary for SocketAddrV6

source§### impl Arbitrary for AddrParseError

### impl Arbitrary for AddrParseError

#### type Parameters = ()

#### type Strategy = Just<AddrParseError>

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl<A: Arbitrary + Hash + Eq> Arbitrary for IntoIter<A>

### impl<A: Arbitrary + Hash + Eq> Arbitrary for IntoIter<A>

#### type Parameters = <HashSet<A, RandomState> as Arbitrary>::Parameters

#### type Strategy = Map<<HashSet<A, RandomState> as Arbitrary>::Strategy, fn(_: HashSet<A, RandomState>) -> IntoIter<A>>

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl<T0: Arbitrary, T1: Arbitrary, T2: Arbitrary> Arbitrary for (T0, T1, T2)

### impl<T0: Arbitrary, T1: Arbitrary, T2: Arbitrary> Arbitrary for (T0, T1, T2)

#### type Parameters = (<T0 as Arbitrary>::Parameters, <T1 as Arbitrary>::Parameters, <T2 as Arbitrary>::Parameters)

#### type Strategy = (<T0 as Arbitrary>::Strategy, <T1 as Arbitrary>::Strategy, <T2 as Arbitrary>::Strategy)

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl<A: Arbitrary> Arbitrary for [A; 6]

### impl<A: Arbitrary> Arbitrary for [A; 6]

#### type Parameters = <A as Arbitrary>::Parameters

#### type Strategy = UniformArrayStrategy<<A as Arbitrary>::Strategy, [A; 6]>

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl<A: Arbitrary> Arbitrary for [A; 19]

### impl<A: Arbitrary> Arbitrary for [A; 19]

#### type Parameters = <A as Arbitrary>::Parameters

#### type Strategy = UniformArrayStrategy<<A as Arbitrary>::Strategy, [A; 19]>

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for FpCategory

### impl Arbitrary for FpCategory

#### type Parameters = ()

#### type Strategy = TupleUnion<((u32, Arc<Just<FpCategory>>), (u32, Arc<Just<FpCategory>>), (u32, Arc<Just<FpCategory>>), (u32, Arc<Just<FpCategory>>), (u32, Arc<Just<FpCategory>>))>

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for f32

### impl Arbitrary for f32

#### type Parameters = ()

#### type Strategy = Any

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for AtomicIsize

### impl Arbitrary for AtomicIsize

#### type Parameters = ()

#### type Strategy = Map<<isize as Arbitrary>::Strategy, fn(_: isize) -> AtomicIsize>

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for SeekFrom

### impl Arbitrary for SeekFrom

#### type Parameters = ()

#### type Strategy = TupleUnion<((u32, Arc<Map<<u64 as Arbitrary>::Strategy, fn(_: u64) -> SeekFrom>>), (u32, Arc<Map<<i64 as Arbitrary>::Strategy, fn(_: i64) -> SeekFrom>>), (u32, Arc<Map<<i64 as Arbitrary>::Strategy, fn(_: i64) -> SeekFrom>>))>

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl<A: Arbitrary + Iterator> Arbitrary for Enumerate<A>

### impl<A: Arbitrary + Iterator> Arbitrary for Enumerate<A>

#### type Parameters = <A as Arbitrary>::Parameters

#### type Strategy = Map<<A as Arbitrary>::Strategy, fn(_: A) -> Enumerate<A>>

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl<T: ?Sized> Arbitrary for PhantomData<T>

### impl<T: ?Sized> Arbitrary for PhantomData<T>

#### type Parameters = ()

#### type Strategy = Just<PhantomData<T>>

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for Once

### impl Arbitrary for Once

#### type Parameters = ()

#### type Strategy = LazyJust<Once, fn() -> Once>

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for Sink

### impl Arbitrary for Sink

#### type Parameters = ()

#### type Strategy = LazyJust<Sink, fn() -> Sink>

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for u16

### impl Arbitrary for u16

#### type Parameters = ()

#### type Strategy = Any

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for RandomState

### impl Arbitrary for RandomState

#### type Parameters = ()

#### type Strategy = LazyJust<RandomState, fn() -> RandomState>

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for AtomicUsize

### impl Arbitrary for AtomicUsize

#### type Parameters = ()

#### type Strategy = Map<<usize as Arbitrary>::Strategy, fn(_: usize) -> AtomicUsize>

#### fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

source§### impl<A: Arbitrary> Arbitrary for Cursor<A>

### impl<A: Arbitrary> Arbitrary for Cursor<A>

#### type Parameters = <A as Arbitrary>::Parameters

#### type Strategy = Map<<A as Arbitrary>::Strategy, fn(_: A) -> Cursor<A>>

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl<T0: Arbitrary, T1: Arbitrary, T2: Arbitrary, T3: Arbitrary, T4: Arbitrary, T5: Arbitrary, T6: Arbitrary, T7: Arbitrary> Arbitrary for (T0, T1, T2, T3, T4, T5, T6, T7)

### impl<T0: Arbitrary, T1: Arbitrary, T2: Arbitrary, T3: Arbitrary, T4: Arbitrary, T5: Arbitrary, T6: Arbitrary, T7: Arbitrary> Arbitrary for (T0, T1, T2, T3, T4, T5, T6, T7)

#### type Parameters = (<T0 as Arbitrary>::Parameters, <T1 as Arbitrary>::Parameters, <T2 as Arbitrary>::Parameters, <T3 as Arbitrary>::Parameters, <T4 as Arbitrary>::Parameters, <T5 as Arbitrary>::Parameters, <T6 as Arbitrary>::Parameters, <T7 as Arbitrary>::Parameters)

#### type Strategy = (<T0 as Arbitrary>::Strategy, <T1 as Arbitrary>::Strategy, <T2 as Arbitrary>::Strategy, <T3 as Arbitrary>::Strategy, <T4 as Arbitrary>::Strategy, <T5 as Arbitrary>::Strategy, <T6 as Arbitrary>::Strategy, <T7 as Arbitrary>::Strategy)

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

source§### impl Arbitrary for String

### impl Arbitrary for String

source§#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

#### fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

###### Panics

This implementation panics if the input is not a valid regex proptest can handle.