Search
 
SCRIPT & CODE EXAMPLE
 

RUST

random number generator in rust

use rand::Rng;

fn main() {
    let mut rng = rand::thread_rng();

    let n1: u8 = rng.gen();
    println!("Random u8: {}", n1);
    println!("Random u32: {}", rng.gen::<u32>());
    //print with range[1 to 4]
 	let n2: u8 = rand::thread_rng().gen_range(1..5);

}
Comment

PREVIOUS NEXT
Code Example
Rust :: check if a file exists rust 
Rust :: rust create folder 
Rust :: rust random number in range 
Rust :: bevy bundles 
Rust :: read file buffer rust 
Rust :: rust sum vector 
Rust :: how to create a window in rust lang 
Rust :: linking with `link.exe` failed: exit code: 1189 
Rust :: create empty string rust 
Rust :: rust option get value 
Rust :: rust copy to clipboard 
Rust :: rust new vec 
Rust :: rust init vec with values 
Rust :: rust number squared 
Rust :: rust lang underscore 
Rust :: packet sniffing with rust 
Rust :: armanriazi•rust•collection•hashmap•avoid_of_duplicate 
Rust :: declare an array with signle value Rust 
Rust :: armanriazi•rust•thread 
Rust :: armanriazi•rust•error•[E0368]: binary assignment operation `+=` cannot be applied to type `T` 
Rust :: rust run tests without cargo 
Lua :: roblox how to make a rainbow part 
Lua :: how to make a part rotate roblox 
Lua :: roblox loop all players 
Lua :: rotate object roblox 
Lua :: repeat until lua 
Lua :: lua clear table 
Lua :: lua comments 
Lua :: svelte template 
Lua :: dubble and big comment 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =