Function read_string_nonempty

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

Get a line of non-empty 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.

This function will keep asking for input until it gets a non-empty string.

ยงExamples

let name = read_human::read_string_nonempty("Please enter your name: ")?;
// The function will not return until we have a non-empty string
assert!(name != "");