pub fn get_text_input_as<Output: FromStr>(
    prompt: &str
) -> Result<Output, Output::Err>
Expand description

Get a standard text input from the user. Appears inline. Directly passes the result from str.parse(). If you want to keep prompting until the user submits a value that fits the chosen type

§Errors

Returns the result of a parse method, so the error will depend on what you want to parse to

Examples found in repository?
examples/text-input.rs (line 5)
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);
}