Type Definition inquire::formatter::OptionFormatter [−][src]
pub type OptionFormatter<'a> = &'a dyn Fn(&OptionAnswer) -> String;
Expand description
Type alias for formatters used in Select prompts.
Formatters receive the user input and return a String to be displayed to the user as the final answer.
Examples
use inquire::option_answer::OptionAnswer; use inquire::formatter::OptionFormatter; let formatter: OptionFormatter = &|i| format!("Option {}: '{}'", i.index + 1, i.value); assert_eq!(String::from("Option 1: 'a'"), formatter(&OptionAnswer::new(0, "a"))); assert_eq!(String::from("Option 2: 'b'"), formatter(&OptionAnswer::new(1, "b")));