pub trait Arbitrary:
Clone
+ Send
+ 'static {
// Required method
fn arbitrary<G: Gen>(g: &mut G) -> Self;
// Provided method
fn shrink(&self) -> Box<dyn Iterator<Item = Self>> { ... }
}Expand description
Arbitrary describes types whose values can be randomly generated and
shrunk.
Aside from shrinking, Arbitrary is different from the std::Rand trait
in that it uses a Gen to control the distribution of random values.
As of now, all types that implement Arbitrary must also implement
Clone. (I’m not sure if this is a permanent restriction.)
They must also be sendable and static since every test is run in its own
thread using thread::Builder::spawn, which requires the Send + 'static
bounds.
Required Methods§
Provided Methods§
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.