get_text_input_as

Function get_text_input_as 

Source
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)
1fn main() {
2    let name = console_input::standard::get_text_input("What's your name? ");
3    println!("Hello {name}!");
4    let number: u32 =
5        console_input::standard::get_text_input_as("Enter a number: ").expect("should be a number");
6
7    println!("Your number plus two is {}", number + 2);
8}