Rust Programming Tutorial #32 - Random Numbers (and Booleans)

preview_player
Показать описание

From there, you can use a random number generator in order to gain access to many provided methods including ones that can give you a random number within a range and also random boolean values.

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
Рекомендации по теме
Комментарии
Автор

nice tutorials, just want to mention, that you don't need to write `extern crate rand;` since rust edition 2018

twt
Автор

Hello! This code needs a small update. Here's a working version which still uses rand = "0.8.5" in cargo.toml dependencies.
Updated Code:
use rand::Rng;
fn main()
{
let random_number =
println!("Random Number: {}", random_number);

//random bool
let random_bool =
println!("Random Boolean: {}", random_bool);
}

Ryan-xqkl
Автор

Even tho i have rand crate in the dependencies it is still saying that it cannot find the crate

yesyesman
Автор

Hi all, Deprecated since 0.5.0: use gen_bool instead - / 3.0);

skyseg
Автор

thank you for this but my eyes no longer work can you make a video about that

waffley
Автор

how to use magic_number() function to generate unsigned values (0 or 1)

Footballistaas
Автор

how to make matrix with random numbers?

marioalbornoz
welcome to shbcf.ru