pub fn get_text_input(prompt: &str) -> String
Expand description

Get a standard text input from the user. Appears inline, returns the trimmed user string

§Panics

This function panics if it fails to flush stdout or to read stdin

Examples found in repository?
examples/text-input.rs (line 2)
1
2
3
4
5
6
7
8
fn main() {
    let name = console_input::standard::get_text_input("What's your name? ");
    println!("Hello {name}!");
    let number: u32 =
        console_input::standard::get_text_input_as("Enter a number: ").expect("should be a number");

    println!("Your number plus two is {}", number + 2);
}