generate-random

Crates.iogenerate-random
lib.rsgenerate-random
version0.1.0
sourcesrc
created_at2022-04-21 20:34:04.325127
updated_at2022-04-21 20:34:04.325127
descriptionGenerate random data
homepagehttps://github.com/alvra/generate-random
repositoryhttps://github.com/alvra/generate-random
max_upload_size
id571864
size5,172
Alexander van Ratingen (alvra)

documentation

https://docs.rs/generate-random

README

Generate-Random

Generate random data.

Example

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

Documentation

Documentation

Commit count: 3

cargo fmt