1 个不稳定版本
| 0.1.0 | 2023 年 9 月 17 日 |
|---|
1444 在 Rust 模式 中排名
163 次月下载
用于 3 个 crate (2 个直接使用)
26KB
444 行
fastrand
fastrand crate 的扩展功能。
此 crate 包含可能对 "fastrand" 用户有用的代码。由于以下原因,此代码未包含在 "fastrand" 中:该利基不够大,无法证明新功能是有必要的,或者存在 semver 问题。
使用方法
在此 crate 中公开了各种函数作为顶级函数。这些函数操作全局线程局部 RNG,可以无状态地使用。请注意,这些函数需要启用 "std" 默认功能。
use fastrand_contrib::f32_range;
let x = f32_range(1.5..3.0);
assert!(x >= 1.5 && x < 3.0);
要扩展 fastrand::Rng,导入 RngExt trait。
use fastrand_contrib::RngExt;
现在,所有新方法都可在 fastrand::Rng 上使用。
use fastrand::Rng;
use fastrand_contrib::RngExt;
let mut rng = Rng::with_seed(0x1234);
let x = rng.f32_range(1.5..3.0);
assert!(x >= 1.5 && x < 3.0);
功能
std(默认启用): 启用std库。仅当此功能启用时,自由站立函数才有效。同时启用fastrand/std功能。libm: 在no_std环境中使用libm依赖项进行数学函数。
许可证
根据您选择,许可如下:
- Apache 许可证 2.0 (LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT 许可证 (LICENSE-MIT 或 https://open-source.org.cn/licenses/MIT)
。
贡献
除非您明确声明,否则您按照Apache-2.0许可中定义的方式有意提交供作品包含的任何贡献,应双许可如上所述,无需任何附加条款或条件。
依赖关系
~130KB