ask_user

Function ask_user 

Source
pub fn ask_user<'a, 'b, S, T>(
    question: S,
    answers: &'a [Answer<'b, T>],
) -> Result<&'a Answer<'b, T>>
where S: AsRef<str>, T: Eq + PartialEq + Hash + Display,
Expand description

ยงAsks user some question

Notes:

  • The question will be printed first. Then one line break. Then each answer will be printed on each line.

  • The user can enter either:

    • An answer index.
    • Or some part of an answer.
  • The function will start again if:

    • The user enters a wrong index.
    • The phrase entered is presented in more than one answer.
  • The function returns an error if you provide duplicate answers, or no answers at all.