pub fn choose<T>(prompt: &str, mut choices: HashMap<String, T>) -> io::Result<T> {
    let mut label = input!("{} [{}] ", prompt, choices.keys().join("/"))?;
    loop {
        if let Some(choice) = choices.remove(label.trim_end_matches('\n')) {
            return Ok(choice)
        }
        label = input!("unrecognized answer, type {}: ", choices.keys().join(" or "))?;
    }
}
/// Repeatedly prompts the user until they input a valid choice.
Repeatedly prompts the user until they input a valid choice.
Repeatedly prompts the user until they input a valid choice .
pub fn choose<T>(prompt: &str, mut choices: HashMap<String, T>) -> io::Result<T> {
    let mut label = input!("{} [{}] ", prompt, choices.keys().join("/"))?;
    loop {
        if let Some(choice) = choices.remove(label.trim_end_matches('\n')) {
            return Ok(choice)
        }
        label = input!("unrecognized answer, type {}: ", choices.keys().join(" or "))?;
    }
}
pub fn choose < T > ( prompt : & str , mut choices : HashMap < String , T > ) -> io :: Result < T > { let mut label = input ! ( " " prompt choices keys ( ) join ( " " ) ) ? ; loop { if let Some ( choice ) = choices . remove ( label . trim_end_matches ( '\n' ) ) { return Ok ( choice ) } label = input ! ( " " choices keys ( ) join ( " " ) ) ? ; } }
Repeatedly prompts the user until they input a valid choice.
Repeatedly prompts the user until they input a valid choice .
prompt
&str
choices
HashMap<String, T>