diff --git a/src/dictionary.rs b/src/dictionary.rs index e60318c..00febfd 100644 --- a/src/dictionary.rs +++ b/src/dictionary.rs @@ -150,8 +150,7 @@ impl NavigatedPage for DictionaryState { v = v[..v.len() - 2].to_string() } - while v.contains(",,") { - let index = v.find(",,").unwrap(); + while let Some(index) = v.find(",,") { v.remove(index); } @@ -211,14 +210,12 @@ impl NavigatedPage for DictionaryState { SaveGroup => { let state = &mut self.state.lock().unwrap(); let connection = &state.connection; - let group = &mut state - .word_groups - .get(self.selected_group_index) - .unwrap() + let mut group = state + .word_groups[self.selected_group_index] .clone(); - update_group(group, connection); - state.word_groups[self.selected_group_index] = group.clone(); + update_group(&mut group, connection); + state.word_groups[self.selected_group_index] = group; } SelectGroup(i) => { self.selected_group_index = i; @@ -316,7 +313,7 @@ impl DictionaryState { fn save_word(&mut self, i: usize) { let state = &mut self.state.lock().unwrap(); let connection = &state.connection; - let word = &mut state.dictionary.get(i).unwrap().clone(); + let word = &mut state.dictionary[i].clone(); update_word(word, connection); state.dictionary[i] = word.clone(); diff --git a/src/import.rs b/src/import.rs index e3cff93..78d051f 100644 --- a/src/import.rs +++ b/src/import.rs @@ -517,8 +517,7 @@ impl ImportState { .iter() .map(|name| (name.clone(), Vec::::with_capacity(1))) .collect::>(); - for key in group.mapping.keys() { - let endpoint = group.mapping.get(key).unwrap(); + for (key, endpoint) in &group.mapping { let property_index = group.fields.iter().position(|f| f == key).unwrap(); let group_index = result .iter() @@ -538,7 +537,7 @@ impl ImportState { ) -> String { let mut working_words = Vec::with_capacity(indices.len()); for index in indices { - let str = properties.get(*index).unwrap(); + let str = &properties[*index]; if skip_empty && str.is_empty() { continue; } diff --git a/src/lang.rs b/src/lang.rs index 836ac16..473b3cd 100644 --- a/src/lang.rs +++ b/src/lang.rs @@ -360,7 +360,7 @@ impl DeckData { let last_list: Vec<_> = settings .get_word_list(&state_locked) .iter() - .map(|w| state_locked.dictionary.get(*w).unwrap()) + .map(|w| &state_locked.dictionary[*w]) .cloned() .collect(); let word_ids = last_list.iter().map(|l| l.id).collect::>(); diff --git a/src/repetitions.rs b/src/repetitions.rs index 755acf4..6c0d639 100644 --- a/src/repetitions.rs +++ b/src/repetitions.rs @@ -581,7 +581,7 @@ impl RepetitionsState { let words = &state.dictionary; let stats = &mut indices .map(|i| { - let word = words.get(i).unwrap(); + let word = &words[i]; CardStatistics { id: 0.into(), word_id: word.id,