Function xmt::pick

source · []
pub fn pick<'a, E: Display>(msg: &str, items: &'a [E]) -> Result<&'a E>
Expand description

Prompt the user to select an item from a list.

Errors

Returns an io::Error error if stdout is not a TTY or if reading from stdin failed.

Example


xmt::init_default();
let choices = vec!["foo", "bar", "baz"];
let pick = xmt::pick("Pick one", &choices)?;
println!("You picked: {}", pick);

Returns

A reference to the item selected by the user.