#random #unique #range #no-repetition

randge

生成不重复的随机数

2个稳定版本

1.1.0 2020年12月6日
1.0.0 2020年12月4日

2173 in 算法

MIT 许可证

22KB
579

randge

Rust version documentation LICENSE

生成不重复的随机数

示例

use rand::thread_rng;

let v = randge(-15..15, 5, thread_rng());
let v: Vec<_> = v.collect();
// output: like [13, -3, -14, 5, 3]

lib.rs:

生成指定范围内的不重复随机数

示例

use rand::thread_rng;

let v = randge(-15..15, 5, thread_rng());
let v: Vec<_> = v.collect();
// output: like [13, -3, -14, 5, 3]

功能

  • rand

依赖

~1.5–2.2MB
~39K SLoC