Function read_string

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

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 != "");
}