Hello Folks, am very new to programming. I just started with the rust documentary "The Book" few days ago. My dream is to be on the rust core team someday. I've come across a problem. Whenever I run the guessing game code, I get an error. Below is the code with the error message.
use std::io;
use rand::Rng;
fn main() {
println!("Guess the number!");
let secret_number = rand::thread_rng().gen_range(1, 101);
println!("The secret number is: {}", secret_number);
println!("Please input your guess.");
let mut guess = String::new();
io::stdin()
.read_line(&mut guess)
.expect("Failed to read line");
println!("You guessed: {}", guess);
}
error[E0061]: this function takes 1 argument but 2 arguments were supplied
--> src\main.rs:7:44
|
7 | let secret_number = rand::thread_rng().gen_range(1, 101);
| ^^^^^^^^^ - --- supplied 2 arguments
| expected 1 argument
error: aborting due to previous error
For more information about this error, try `rustc --explain E0061`.
error: could not compile `guessing_game`
To learn more, run the command again with --verbose.
PS C:\Users\futur\rust_projects\guessing_game> cargo run
Compiling guessing_game v0.1.0 (C:\Users\futur\rust_projects\guessing_game)
error[E0061]: this function takes 1 argument but 2 arguments were supplied
--> src\main.rs:40:44
|
40 | let secret_number = rand::thread_rng().gen_range(1, 101);
| ^^^^^^^^^ - --- supplied 2 arguments
| |
| expected 1 argument
error: aborting due to previous error
For more information about this error, try `rustc --explain E0061`.
error: could not compile `guessing_game`
Please because am a newbie to programming, I kindly ask you to use simple English words to answer me. Explain it to me like you will do for a 5 year old. I use VS Code Editor. Thanks in advance for your help.