aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: c2458aecb20989f7ef29debd94f814ac0aaf5339 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Generate-Random

Generate random data.

## Example

```rust
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](https://lib.rs/crates/generate-random)