Crates.io | generate-random |
lib.rs | generate-random |
version | 0.1.0 |
source | src |
created_at | 2022-04-21 20:34:04.325127 |
updated_at | 2022-04-21 20:34:04.325127 |
description | Generate random data |
homepage | https://github.com/alvra/generate-random |
repository | https://github.com/alvra/generate-random |
max_upload_size | |
id | 571864 |
size | 5,172 |
Generate random data.
use generate_random::GenerateRandom;
#[derive(GenerateRandom)]
enum MyEnum {
A,
C(bool),
B {
x: u8,
},
// Providing a weight allows changing the probabilities.
// This variant is now twice as likely to be generated as the others.
#[weight(2)]
D,
}
let mut rng = rand::thread_rng();
let my_value = MyEnum::generate_random(&mut rng);