RustでいわゆるPythonのrandintを実装したい
[dependencies] rand = "0.8"
use rand::Rng; fn main() { let num = rand::thread_rng().gen_range(0..1000000); println!("{}", num); }
$ cargo run
Compiling crypt v0.1.0 (/home/vagrant/dev/rust/crypt)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.28s
Running `target/debug/crypt`
759081
うん、ここまでは簡単