Function std::rand::randomExperimental
[-]
[+]
[src]
pub fn random<T: Rand>() -> T
Generates a random value using the thread-local random number generator.
random()
can generate various types of random things, and so may require
type hinting to generate the specific type you want.
Examples
fn main() { use std::rand; let x = rand::random(); println!("{}", 2u * x); let y = rand::random::<f64>(); println!("{}", y); if rand::random() { // generates a boolean println!("Better lucky than good!"); } }use std::rand; let x = rand::random(); println!("{}", 2u * x); let y = rand::random::<f64>(); println!("{}", y); if rand::random() { // generates a boolean println!("Better lucky than good!"); }