[][src]Function read_human::read_string_nonempty

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

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