Reading User Input in Rust

Learn how to read and display user input in Rust using standard input/output.

Reading User Input in Rust
Photo by Denis Pavlovic / Unsplash

Learn how to read and display user input in Rust using standard input/output.

use std::io;

fn main() {
    let mut input = String::new();
    println!("Enter something:");
    io::stdin().read_line(&mut input).expect("Failed to read line");
    println!("You entered: {}", input);
}