Trait Random

Source
pub trait Random: Sized {
    // Required method
    fn random() -> Self;
}
Expand description

A helper trait to generate random values

Required Methods§

Source

fn random() -> Self

Will generate a random Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Random for bool

Source§

fn random() -> Self

Will generate a random bool

§Example
use hel_random::Random;

let r = bool::random();
println!("r = {r}");
Source§

impl Random for i8

Source§

fn random() -> Self

Will generate a random i8

§Example
use hel_random::Random;

let r = i8::random();
println!("r = {r}");
Source§

impl Random for i16

Source§

fn random() -> Self

Will generate a random i16

§Example
use hel_random::Random;

let r = i16::random();
println!("r = {r}");
Source§

impl Random for i32

Source§

fn random() -> Self

Will generate a random i32

§Example
use hel_random::Random;

let r = i32::random();
println!("r = {r}");
Source§

impl Random for i64

Source§

fn random() -> Self

Will generate a random i64

§Example
use hel_random::Random;

let r = i64::random();
println!("r = {r}");
Source§

impl Random for i128

Source§

fn random() -> Self

Will generate a random i128

§Example
use hel_random::Random;

let r = i128::random();
println!("r = {r}");
Source§

impl Random for u8

Source§

fn random() -> Self

Will generate a random u8

§Example
use hel_random::Random;

let r = u8::random();
println!("r = {r}");
Source§

impl Random for u16

Source§

fn random() -> Self

Will generate a random u16

§Example
use hel_random::Random;

let r = u16::random();
println!("r = {r}");
Source§

impl Random for u32

Source§

fn random() -> Self

Will generate a random u32

§Example
use hel_random::Random;

let r = u32::random();
println!("r = {r}");
Source§

impl Random for u64

Source§

fn random() -> Self

Will generate a random u64

§Example
use hel_random::Random;

let r = u64::random();
println!("r = {r}");
Source§

impl Random for u128

Source§

fn random() -> Self

Will generate a random u128

§Example
use hel_random::Random;

let r = u128::random();
println!("r = {r}");

Implementors§