Read user input with io::stdin().read_line() and display output with println! in Rust.
Use std::io to read from standard input and println! to write to standard output.
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}");
}
Standard input is how your program receives text typed by the user, while standard output is how your program displays text back to them. Think of it like a conversation where stdin is listening to what the user says and stdout is your program speaking back. You use this pattern whenever you need a command-line tool to interact with a human.