Trait Random
Source pub trait Random: Sized {
// Required method
fn random() -> Self;
}
Expand description
A helper trait to generate random values
Will generate a random Self
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Will generate a random bool
§Example
use hel_random::Random;
let r = bool::random();
println!("r = {r}");
Will generate a random i8
§Example
use hel_random::Random;
let r = i8::random();
println!("r = {r}");
Will generate a random i16
§Example
use hel_random::Random;
let r = i16::random();
println!("r = {r}");
Will generate a random i32
§Example
use hel_random::Random;
let r = i32::random();
println!("r = {r}");
Will generate a random i64
§Example
use hel_random::Random;
let r = i64::random();
println!("r = {r}");
Will generate a random i128
§Example
use hel_random::Random;
let r = i128::random();
println!("r = {r}");
Will generate a random u8
§Example
use hel_random::Random;
let r = u8::random();
println!("r = {r}");
Will generate a random u16
§Example
use hel_random::Random;
let r = u16::random();
println!("r = {r}");
Will generate a random u32
§Example
use hel_random::Random;
let r = u32::random();
println!("r = {r}");
Will generate a random u64
§Example
use hel_random::Random;
let r = u64::random();
println!("r = {r}");
Will generate a random u128
§Example
use hel_random::Random;
let r = u128::random();
println!("r = {r}");