1 个不稳定版本

0.1.0 2022 年 4 月 21 日

#2983 in Rust 模式

Download history 18/week @ 2024-04-15 34/week @ 2024-04-29 9/week @ 2024-05-06 21/week @ 2024-05-13 9/week @ 2024-05-20 59/week @ 2024-05-27 95/week @ 2024-06-03 52/week @ 2024-06-10 49/week @ 2024-06-17 26/week @ 2024-06-24 19/week @ 2024-07-01 36/week @ 2024-07-08 37/week @ 2024-07-15 32/week @ 2024-07-22

134 每月下载次数

MIT/Apache

6KB
94

Generate-Random

生成随机数据。

示例

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

文档

文档


lib.rs:

生成随机数据。

示例

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

依赖

~2MB
~40K SLoC