Type Definition inquire::formatter::OptionFormatter

source ·
pub type OptionFormatter<'a, T> = &'a dyn Fn(ListOption<&T>) -> 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::list_option::ListOption;
use inquire::formatter::OptionFormatter;

let formatter: OptionFormatter<str> = &|i| format!("Option {}: '{}'", i.index + 1, i.value);
assert_eq!(String::from("Option 1: 'a'"), formatter(ListOption::new(0, "a")));
assert_eq!(String::from("Option 2: 'b'"), formatter(ListOption::new(1, "b")));