Trait proptest::arbitrary::Arbitrary [−][src]
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.
Associated Types
type Parameters: Default
[src]
The type of parameters that arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.
type Strategy: Strategy<Value = Self>
[src]
The type of Strategy
used to generate values of type Self
.
Required methods
fn arbitrary_with(args: Self::Parameters) -> Self::Strategy
[src]
Provided methods
fn arbitrary() -> Self::Strategy
[src]
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.