fix: out of bound when type answer bigger than some choice

This commit is contained in:
Talison Fabio 2025-03-23 11:33:45 -03:00
parent 2a0b70f2bd
commit af61cb0bc2

View File

@ -226,7 +226,7 @@ impl<'a, T: Default> ChoicePrompt<'a, T> {
let chosen_index = self
.choises
.iter()
.position(|choise| answer == &choise.label[0..answer.len()]);
.position(|choise| choise.label.starts_with(answer));
if let Some(i) = chosen_index {
return Ok(self.choises.remove(i).value);