rustmax::proptest::arbitrary

Trait Arbitrary

Source
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 Strategys 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.

If you do not have unique constraints on how to generate the data for your custom types, consider using the derive macro to implement Arbitrary

Required Associated Types§

Source

type Parameters: Default

The type of parameters that arbitrary_with accepts for configuration of the generated Strategy. Parameters must implement Default.

Source

type Strategy: Strategy<Value = Self>

The type of Strategy used to generate values of type Self.

Required Methods§

Source

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

Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args.

If you wish to use the default() arguments, use arbitrary instead.

Provided Methods§

Source

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Arbitrary for bool

Source§

impl Arbitrary for char

Source§

impl Arbitrary for f32

Source§

impl Arbitrary for f64

Source§

impl Arbitrary for i8

Source§

impl Arbitrary for i16

Source§

impl Arbitrary for i32

Source§

impl Arbitrary for i64

Source§

impl Arbitrary for i128

Source§

impl Arbitrary for isize

Source§

impl Arbitrary for u8

Source§

impl Arbitrary for u16

Source§

impl Arbitrary for u32

Source§

impl Arbitrary for u64

Source§

impl Arbitrary for u128

Source§

impl Arbitrary for ()

Source§

impl Arbitrary for usize

Source§

impl<A> Arbitrary for (Sender<A>, IntoIter<A>)
where A: Debug,

Source§

impl<A> Arbitrary for (Sender<A>, Receiver<A>)

Source§

impl<A> Arbitrary for (SyncSender<A>, IntoIter<A>)
where A: Debug,

Source§

impl<A> Arbitrary for (SyncSender<A>, Receiver<A>)

Source§

impl<A, const N: usize> Arbitrary for [A; N]
where A: Arbitrary,

Source§

impl<T0> Arbitrary for (T0,)
where T0: Arbitrary,

Source§

impl<T0, T1> Arbitrary for (T0, T1)
where T0: Arbitrary, T1: Arbitrary,

Source§

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

Source§

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

Source§

impl<T0, T1, T2, T3, T4> Arbitrary for (T0, T1, T2, T3, T4)
where T0: Arbitrary, T1: Arbitrary, T2: Arbitrary, T3: Arbitrary, T4: Arbitrary,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§

Source§

impl Arbitrary for rustmax::std::cmp::Ordering

Source§

impl Arbitrary for VarError

Source§

impl Arbitrary for ErrorKind

Source§

impl Arbitrary for SeekFrom

Source§

impl Arbitrary for IpAddr

Source§

impl Arbitrary for Shutdown

Source§

impl Arbitrary for SocketAddr

Source§

impl Arbitrary for FpCategory

Source§

impl Arbitrary for Option<Infallible>

Source§

impl Arbitrary for rustmax::std::sync::atomic::Ordering

Source§

impl Arbitrary for RecvTimeoutError

Source§

impl Arbitrary for TryRecvError

Source§

impl Arbitrary for rustmax::std::ascii::EscapeDefault

Source§

impl Arbitrary for Box<str>

Source§

impl Arbitrary for Box<CStr>

Source§

impl Arbitrary for Box<OsStr>

Source§

impl Arbitrary for Box<Path>

This implementation is identical to the Arbitrary implementation for PathBuf.

Source§

impl Arbitrary for BorrowError

Source§

impl Arbitrary for BorrowMutError

Source§

impl Arbitrary for DecodeUtf16<<Vec<u16> as IntoIterator>::IntoIter>

Source§

impl Arbitrary for DecodeUtf16Error

Source§

impl Arbitrary for EscapeDebug

Source§

impl Arbitrary for rustmax::std::char::EscapeDefault

Source§

impl Arbitrary for EscapeUnicode

Source§

impl Arbitrary for ParseCharError

Source§

impl Arbitrary for Args

Source§

impl Arbitrary for ArgsOs

Source§

impl Arbitrary for JoinPathsError

Source§

impl Arbitrary for Vars

Source§

impl Arbitrary for VarsOs

Source§

impl Arbitrary for CString

Source§

impl Arbitrary for FromBytesWithNulError

Source§

impl Arbitrary for IntoStringError

Source§

impl Arbitrary for OsString

Source§

impl Arbitrary for rustmax::std::fmt::Error

Source§

impl Arbitrary for DirBuilder

Source§

impl Arbitrary for DefaultHasher

Source§

impl Arbitrary for RandomState

Source§

impl Arbitrary for rustmax::std::io::Empty

Source§

impl Arbitrary for rustmax::std::io::Error

Source§

impl Arbitrary for rustmax::std::io::Repeat

Source§

impl Arbitrary for Sink

Source§

impl Arbitrary for Stderr

Source§

impl Arbitrary for Stdin

Source§

impl Arbitrary for Stdout

Source§

impl Arbitrary for AddrParseError

Source§

impl Arbitrary for Ipv4Addr

Source§

impl Arbitrary for Ipv6Addr

Source§

impl Arbitrary for SocketAddrV4

Source§

impl Arbitrary for SocketAddrV6

Source§

impl Arbitrary for NonZero<i8>

Source§

impl Arbitrary for NonZero<i16>

Source§

impl Arbitrary for NonZero<i32>

Source§

impl Arbitrary for NonZero<i64>

Source§

impl Arbitrary for NonZero<i128>

Source§

impl Arbitrary for NonZero<isize>

Source§

impl Arbitrary for NonZero<u8>

Source§

impl Arbitrary for NonZero<u16>

Source§

impl Arbitrary for NonZero<u32>

Source§

impl Arbitrary for NonZero<u64>

Source§

impl Arbitrary for NonZero<u128>

Source§

impl Arbitrary for NonZero<usize>

Source§

impl Arbitrary for ParseFloatError

Source§

impl Arbitrary for ParseIntError

Source§

impl Arbitrary for RangeFull

Source§

impl Arbitrary for PathBuf

This implementation accepts as its argument a PathParams struct. It generates either a relative or an absolute path with equal probability.

Currently, this implementation does not generate:

  • Paths that are not valid UTF-8 (this is unlikely to change)
  • Paths with a PrefixComponent on Windows, e.g. C:\ (this may change in the future)
Source§

type Parameters = PathParams

Source§

type Strategy = Map<<PathParamsOutput as Arbitrary>::Strategy, fn(_: PathParamsOutput) -> PathBuf>

Source§

impl Arbitrary for StripPrefixError

Source§

impl Arbitrary for Rc<str>

Source§

impl Arbitrary for Rc<Path>

This implementation is identical to the Arbitrary implementation for PathBuf.

Source§

impl Arbitrary for ParseBoolError

Source§

impl Arbitrary for Utf8Error

Source§

type Parameters = ()

Source§

type Strategy = Map<(<u16 as Arbitrary>::Strategy, TupleUnion<((u32, Arc<Just<&'static [u8]>>), (u32, Arc<Just<&'static [u8]>>), (u32, Arc<Just<&'static [u8]>>), (u32, Arc<Just<&'static [u8]>>))>), fn(_: <(<u16 as Arbitrary>::Strategy, TupleUnion<((u32, Arc<Just<&'static [u8]>>), (u32, Arc<Just<&'static [u8]>>), (u32, Arc<Just<&'static [u8]>>), (u32, Arc<Just<&'static [u8]>>))>) as Strategy>::Value) -> Utf8Error>

Source§

impl Arbitrary for FromUtf8Error

Source§

impl Arbitrary for FromUtf16Error

Source§

impl Arbitrary for String

Source§

impl Arbitrary for AtomicBool

Source§

impl Arbitrary for AtomicIsize

Source§

impl Arbitrary for AtomicUsize

Source§

impl Arbitrary for RecvError

Source§

impl Arbitrary for Arc<str>

Source§

impl Arbitrary for Arc<Path>

This implementation is identical to the Arbitrary implementation for PathBuf.

Source§

impl Arbitrary for Barrier

Source§

impl Arbitrary for BarrierWaitResult

Source§

impl Arbitrary for Condvar

Source§

impl Arbitrary for rustmax::std::sync::Once

Source§

impl Arbitrary for WaitTimeoutResult

Source§

impl Arbitrary for Builder

Source§

impl Arbitrary for Duration

Source§

impl Arbitrary for Instant

Source§

impl Arbitrary for SystemTime

Source§

impl Arbitrary for Probability

Source§

impl Arbitrary for Index

Source§

impl Arbitrary for Selector

Source§

impl Arbitrary for SizeRange

Source§

impl<'a, T, A> Arbitrary for Cloned<A>
where T: 'a + Clone, A: Arbitrary + Iterator<Item = &'a T>,

Source§

impl<A> Arbitrary for Bound<A>
where A: Arbitrary,

Source§

type Parameters = <A as Arbitrary>::Parameters

Source§

type Strategy = TupleUnion<((u32, Arc<Map<Arc<<A as Arbitrary>::Strategy>, fn(_: <Arc<<A as Arbitrary>::Strategy> as Strategy>::Value) -> Bound<A>>>), (u32, Arc<Map<Arc<<A as Arbitrary>::Strategy>, fn(_: <Arc<<A as Arbitrary>::Strategy> as Strategy>::Value) -> Bound<A>>>), (u32, Arc<LazyJust<Bound<A>, fn() -> Bound<A>>>))>

Source§

impl<A> Arbitrary for Option<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for Result<Infallible, A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for Result<A, Infallible>
where A: Arbitrary,

Source§

impl<A> Arbitrary for Box<[A]>
where A: Arbitrary,

Source§

impl<A> Arbitrary for Box<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for Cell<A>
where A: Arbitrary + Copy,

Source§

impl<A> Arbitrary for RefCell<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for UnsafeCell<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for Reverse<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for BinaryHeap<A>
where A: Arbitrary + Ord,

Source§

impl<A> Arbitrary for rustmax::std::collections::binary_heap::IntoIter<A>
where A: Arbitrary + Ord,

Source§

impl<A> Arbitrary for BTreeSet<A>
where A: Arbitrary + Ord,

Source§

impl<A> Arbitrary for rustmax::std::collections::btree_set::IntoIter<A>
where A: Arbitrary + Ord,

Source§

impl<A> Arbitrary for rustmax::std::collections::hash_set::IntoIter<A>
where A: Arbitrary + Hash + Eq,

Source§

impl<A> Arbitrary for rustmax::std::collections::linked_list::IntoIter<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for LinkedList<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for HashSet<A>
where A: Arbitrary + Hash + Eq,

Source§

impl<A> Arbitrary for rustmax::std::collections::vec_deque::IntoIter<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for VecDeque<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for BufReader<A>
where A: Arbitrary + Read,

Source§

impl<A> Arbitrary for BufWriter<A>
where A: Arbitrary + Write,

Source§

impl<A> Arbitrary for Cursor<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for LineWriter<A>
where A: Arbitrary + Write,

Source§

impl<A> Arbitrary for Lines<A>
where A: Arbitrary + BufRead,

Source§

impl<A> Arbitrary for Split<A>
where A: BufRead + Arbitrary,

Source§

type Parameters = <A as Arbitrary>::Parameters

Source§

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

Source§

impl<A> Arbitrary for rustmax::std::io::Take<A>
where A: Read + Arbitrary,

Source§

type Parameters = <A as Arbitrary>::Parameters

Source§

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

Source§

impl<A> Arbitrary for Cycle<A>
where A: Arbitrary + Iterator + Clone,

Source§

impl<A> Arbitrary for rustmax::std::iter::Empty<A>

Source§

impl<A> Arbitrary for Enumerate<A>
where A: Arbitrary + Iterator,

Source§

impl<A> Arbitrary for Fuse<A>
where A: Arbitrary + Iterator,

Source§

impl<A> Arbitrary for rustmax::std::iter::Once<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for rustmax::std::iter::Repeat<A>
where A: Arbitrary + Clone,

Source§

impl<A> Arbitrary for Rev<A>

Source§

impl<A> Arbitrary for Skip<A>
where A: Arbitrary + Iterator,

Source§

impl<A> Arbitrary for rustmax::std::iter::Take<A>
where A: Arbitrary + Iterator,

Source§

impl<A> Arbitrary for Discriminant<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for Wrapping<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for Range<A>
where A: PartialOrd + Arbitrary,

Source§

impl<A> Arbitrary for RangeFrom<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for RangeInclusive<A>
where A: PartialOrd + Arbitrary,

Source§

impl<A> Arbitrary for RangeTo<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for RangeToInclusive<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for rustmax::std::option::IntoIter<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for AssertUnwindSafe<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for Rc<[A]>
where A: Arbitrary,

Source§

impl<A> Arbitrary for Rc<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for rustmax::std::result::IntoIter<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for Arc<[A]>
where A: Arbitrary,

Source§

impl<A> Arbitrary for Arc<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for Mutex<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for RwLock<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for rustmax::std::vec::IntoIter<A>
where A: Arbitrary,

Source§

impl<A> Arbitrary for Vec<A>
where A: Arbitrary,

Source§

impl<A, B> Arbitrary for Cow<'static, B>
where A: Arbitrary + Borrow<B>, B: ToOwned<Owned = A> + Debug + ?Sized,

Source§

type Parameters = <A as Arbitrary>::Parameters

Source§

type Strategy = Map<<A as Arbitrary>::Strategy, fn(_: A) -> Cow<'static, B>>

Source§

impl<A, B> Arbitrary for Result<A, B>
where A: Arbitrary, B: Arbitrary,

Source§

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

Source§

impl<A, B> Arbitrary for rustmax::std::collections::btree_map::IntoIter<A, B>
where A: Arbitrary + Ord, B: Arbitrary,

Source§

impl<A, B> Arbitrary for rustmax::std::collections::hash_map::IntoIter<A, B>
where A: Arbitrary + Hash + Eq, B: Arbitrary,

Source§

impl<A, B> Arbitrary for HashMap<A, B>
where A: Arbitrary + Hash + Eq, B: Arbitrary,

Source§

impl<A, B> Arbitrary for rustmax::std::io::Chain<A, B>
where A: Read + Arbitrary, B: Read + Arbitrary,

Source§

impl<A, B> Arbitrary for Zip<A, B>

Source§

impl<A, T> Arbitrary for Peekable<A>
where A: Arbitrary + Iterator<Item = T>, T: Debug,

Source§

impl<H> Arbitrary for BuildHasherDefault<H>
where H: Default + Hasher,

Source§

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

Source§

type Parameters = P

Source§

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

Source§

impl<T> Arbitrary for PhantomData<T>
where T: ?Sized,

Source§

impl<T> Arbitrary for SendError<T>
where T: Arbitrary,

Source§

impl<T, A, B> Arbitrary for rustmax::std::iter::Chain<A, B>
where A: Arbitrary + Iterator<Item = T>, B: Arbitrary + Iterator<Item = T>,