Type Definition inquire::parser::BoolParser
source · [−]Expand description
Type alias for parsers used in Confirm prompts.
BoolParser
s receive the user input to a given prompt and return either
a successful result (Ok) containing the parsed bool
or an empty Err
if a value could not be parsed.
Examples
use inquire::parser::BoolParser;
let parser: BoolParser = &|ans| match ans {
"si" => Ok(true),
"no" => Ok(false),
_ => Err(()),
};
assert_eq!(Ok(true), parser("si"));
assert_eq!(Ok(false), parser("no"));
assert_eq!(Err(()), parser("yes"));
assert_eq!(Err(()), parser("não"));