From af61cb0bc23dbf6200349391bd384cd9b7c3ab5b Mon Sep 17 00:00:00 2001 From: Talison Fabio <54823205+talis-fb@users.noreply.github.com> Date: Sun, 23 Mar 2025 11:33:45 -0300 Subject: [PATCH] fix: out of bound when type answer bigger than some choice --- src/utils/question.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/question.rs b/src/utils/question.rs index bf8bc7e..781c868 100644 --- a/src/utils/question.rs +++ b/src/utils/question.rs @@ -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);