mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 20:15:27 +00:00
fix: out of bound when type answer bigger than some choice
This commit is contained in:
parent
2a0b70f2bd
commit
af61cb0bc2
@ -226,7 +226,7 @@ impl<'a, T: Default> ChoicePrompt<'a, T> {
|
|||||||
let chosen_index = self
|
let chosen_index = self
|
||||||
.choises
|
.choises
|
||||||
.iter()
|
.iter()
|
||||||
.position(|choise| answer == &choise.label[0..answer.len()]);
|
.position(|choise| choise.label.starts_with(answer));
|
||||||
|
|
||||||
if let Some(i) = chosen_index {
|
if let Some(i) = chosen_index {
|
||||||
return Ok(self.choises.remove(i).value);
|
return Ok(self.choises.remove(i).value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user