Enum-Derived
Use enum-derived's Rand macro to generate random variants of your enums and structs. All fields are populated with independent random values.
Need custom constraints applied to a variant or field? Use the #[custom_rand(your_function)]
attribute to override the default behavior or extend support to types without default support.
Need some variants to be generated more ofter? Use the #[weight(VARIANT_WEIGHT)]
to change the distribution.
Rand
Rand allows for a random variant of an enum, or struct, to be generated.
The [rand] crate's [rand::random] method is used for the default implementation of [Rand]. Unsupported variants can us the #[custom_rand(your_function)]
to extend the functionality.
Note
Support for String, Vec, HashMap<K, V>, and HashSet has been added. The implementation for String and Vec will create an instance with a lenght between 1 and 64 elements. The implementation for HashMap and HashSet will create an instance with 1 to 16 elements.
Example
use ;
use Rand;
;