[][src]Function read_human::read_string

pub fn read_string(question: &str) -> Result<Option<String>>

Get a line of text from the user.

The question is displayed first. This method converts empty text into None. Any whitespace around the input, including the line ending, will be trimmed.

Examples

let name = read_human::read_string("Please enter your name: ")?;
if let Some(name) = name {
    // An empty string would have been converted into `None`
    assert!(name != "");
}