How to Use std

:io for Input/Output in Rust

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}");
}