diff --git a/src/main.rs b/src/main.rs index 4a55224..f39af0a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -104,7 +104,7 @@ fn main() { let mut typed_hint: String = "".to_owned(); let matches = state.matches(reverse, unique); - let longest_hint = matches.last().unwrap().hint.clone().unwrap().len(); + let longest_hint = matches.iter().filter(|&m| m.hint.clone().is_some()).last().unwrap().hint.clone().expect("Unknown hint").len(); loop { let mut selected = matches.last(); diff --git a/src/state.rs b/src/state.rs index b75ff46..d9c3e86 100644 --- a/src/state.rs +++ b/src/state.rs @@ -57,7 +57,7 @@ impl<'a> State<'a> { hint: None }); - chunk = chunk.get(first_match.end()..).unwrap(); + chunk = chunk.get(first_match.end()..).expect("Unknown chunk"); offset = offset + first_match.end() as i32; } else { break;