Read user input in Rust by importing std::io and using stdin().read_line() to capture text into a mutable String.
Use std::io to read user input by importing the module, creating a mutable String, and calling stdin().read_line() on it.
use std::io;
fn main() {
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}");
}
std::io lets your program pause and wait for the user to type something on their keyboard. It captures what they typed and stores it in a variable so your program can use it later. Think of it like a waiter taking an order: the program asks, waits for the answer, and then writes it down.