Derive macro for generating random types with the rand
crate.
It will implement the rand::distributions::Standard
for a given type.
Check out the example crate or follow the instructions below.
toml
[dependencies]
rand-derive = "0.1"
rand = "0.7"
rust
use rand_derive2::RandGen;
Alternatively, use this to global import the macro: ```rust
extern crate rand_derive2; ```
struct MyStruct {} ```
rust
fn generate_my_struct() -> MyStruct {
rand::random()
}
Note: all things that can be customized is covered in the example crate
To make sure an option is never generated with None
, add the always_some
attribute on top of the property.
If a variant should never be generated, add the skip_variant
attribute on the variant.
If you want a custom value for one of the properties, add the custom_rand
attribute.
A trait is created called TestDataProviderFor$TYPE$.
This trait will require the user to provider the values.
It calls rng.gen()
on all the fields.
It will generate a random variant.
rand::distributions::Standard
)MIT