Trait Random
Source pub trait Random {
// Required method
fn random() -> Self;
}
Available on crate features rand-expand and rand only.
Expand description
可随机生成的类型。
熵源取自 next。各实现的取值语义:
- 整数:取
next() 输出并截断为目标位宽(as 转换);
bool:取最低位;
- 浮点(
f32 / f64):[0, 1) 区间内均匀分布。
§Feature Requirement
需要启用 "rand-expand" 特性。
§Examples
use lib_unknown::rand::{Random, random};
let v: u64 = random();
let _ = v;
生成一个该类型的随机值(语义见 trait 级文档)。
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Available on crate feature rand-expand only.
Available on crate feature rand-expand only.
Available on crate feature rand-expand only.
Available on crate feature rand-expand only.
Available on crate feature rand-expand only.
Available on crate feature rand-expand only.
Available on crate feature rand-expand only.
Available on crate feature rand-expand only.
Available on crate feature rand-expand only.
Available on crate feature rand-expand only.
Available on crate feature rand-expand only.
Available on crate feature rand-expand only.
Available on crate feature rand-expand only.