From f2f81b90436a662890dedf8d6537d26e57b94c7d Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 22 Aug 2024 18:30:59 -0400 Subject: [PATCH] HashBag: Rename `get_all` to `get` --- src/checker.rs | 28 ++++++++++++++-------------- src/hash_bag.rs | 12 ++++++------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/checker.rs b/src/checker.rs index 9a8437b..e0b183b 100644 --- a/src/checker.rs +++ b/src/checker.rs @@ -304,7 +304,7 @@ impl<'a, S: BuildHasher> Checker<'a, S> { } fn check_simple_word(&self, word: &str, hidden_homonym: HiddenHomonym) -> Option<&FlagSet> { - for (_stem, flags) in self.aff.words.get_all(word) { + for (_stem, flags) in self.aff.words.get(word) { if has_flag!(flags, self.aff.options.need_affix_flag) { continue; } @@ -391,7 +391,7 @@ impl<'a, S: BuildHasher> Checker<'a, S> { continue; } - for (stem, flags) in self.aff.words.get_all(stem.as_ref()) { + for (stem, flags) in self.aff.words.get(stem.as_ref()) { // Nuspell: // if (!cross_valid_inner_outer(word_flags, e)) // continue; @@ -454,7 +454,7 @@ impl<'a, S: BuildHasher> Checker<'a, S> { continue; } - for (stem, flags) in self.aff.words.get_all(stem.as_ref()) { + for (stem, flags) in self.aff.words.get(stem.as_ref()) { // Nuspell: // if (!cross_valid_inner_outer(word_flags, e)) // continue; @@ -583,7 +583,7 @@ impl<'a, S: BuildHasher> Checker<'a, S> { continue; } - for (stem, flags) in self.aff.words.get_all(stem_without_suffix.as_ref()) { + for (stem, flags) in self.aff.words.get(stem_without_suffix.as_ref()) { let valid_cross_prefix_outer = !has_needaffix_prefix && flags.contains(&suffix.flag) && (suffix.flags.contains(&prefix.flag) || flags.contains(&prefix.flag)); @@ -677,7 +677,7 @@ impl<'a, S: BuildHasher> Checker<'a, S> { continue; } - for (stem, flags) in self.aff.words.get_all(stem2.as_ref()) { + for (stem, flags) in self.aff.words.get(stem2.as_ref()) { if !flags.contains(&inner_suffix.flag) { continue; } @@ -752,7 +752,7 @@ impl<'a, S: BuildHasher> Checker<'a, S> { continue; } - for (stem, flags) in self.aff.words.get_all(stem2.as_ref()) { + for (stem, flags) in self.aff.words.get(stem2.as_ref()) { if !flags.contains(&inner_prefix.flag) { continue; } @@ -851,7 +851,7 @@ impl<'a, S: BuildHasher> Checker<'a, S> { } // Check that the fully stripped word is a stem in the dictionary. - for (stem, flags) in self.aff.words.get_all(stem3.as_ref()) { + for (stem, flags) in self.aff.words.get(stem3.as_ref()) { if !outer_suffix.flags.contains(&prefix.flag) && !flags.contains(&prefix.flag) { @@ -988,7 +988,7 @@ impl<'a, S: BuildHasher> Checker<'a, S> { continue; } - for (stem, flags) in self.aff.words.get_all(stem3.as_ref()) { + for (stem, flags) in self.aff.words.get(stem3.as_ref()) { if !inner_suffix.flags.contains(&prefix.flag) && !flags.contains(&prefix.flag) { @@ -1094,7 +1094,7 @@ impl<'a, S: BuildHasher> Checker<'a, S> { } // Check that the fully stripped word is a stem in the dictionary. - for (stem, flags) in self.aff.words.get_all(stem3.as_ref()) { + for (stem, flags) in self.aff.words.get(stem3.as_ref()) { if !outer_prefix.flags.contains(&suffix.flag) && !flags.contains(&suffix.flag) { @@ -1231,7 +1231,7 @@ impl<'a, S: BuildHasher> Checker<'a, S> { continue; } - for (stem, flags) in self.aff.words.get_all(stem3.as_ref()) { + for (stem, flags) in self.aff.words.get(stem3.as_ref()) { if !inner_prefix.flags.contains(&suffix.flag) && !flags.contains(&suffix.flag) { @@ -1380,7 +1380,7 @@ impl<'a, S: BuildHasher> Checker<'a, S> { _ => None, }; - for (stem, flags) in self.aff.words.get_all(word) { + for (stem, flags) in self.aff.words.get(word) { if has_flag!(flags, self.aff.options.need_affix_flag) { continue; } @@ -1549,7 +1549,7 @@ impl<'a, S: BuildHasher> Checker<'a, S> { // It passes basically a `&mut String` with this function which is used with C++'s // `basic_string::assign` to hold a substring and that is used to look up in the word // list. We can avoid that by subslicing the `word: &str` with the same indices. See - // where we call `WordList::get_all` below. + // where we call `WordList::get` below. // // There's a `try_recursive` label that Nuspell jumps to in order to recurse or continue // to the next iteration of the loop. We just do the recursion/continuing instead of @@ -1581,7 +1581,7 @@ impl<'a, S: BuildHasher> Checker<'a, S> { let Some((part1_stem, part1_flags)) = self.aff .words - .get_all(&word[start_pos..i]) + .get(&word[start_pos..i]) .find(|(_stem, flags)| { !has_flag!(flags, self.aff.options.need_affix_flag) && self.aff.compound_rules.has_any_flags(flags) @@ -1592,7 +1592,7 @@ impl<'a, S: BuildHasher> Checker<'a, S> { words_data.push(part1_flags); let Some((_part2_stem, part2_flags)) = - self.aff.words.get_all(&word[i..]).find(|(_stem, flags)| { + self.aff.words.get(&word[i..]).find(|(_stem, flags)| { !has_flag!(flags, self.aff.options.need_affix_flag) && self.aff.compound_rules.has_any_flags(flags) }) diff --git a/src/hash_bag.rs b/src/hash_bag.rs index a34d885..3806674 100644 --- a/src/hash_bag.rs +++ b/src/hash_bag.rs @@ -70,7 +70,7 @@ where self.table.len() } - pub fn get_all<'map, 'key, Q>(&'map self, k: &'key Q) -> GetAllIter<'map, 'key, Q, K, V> + pub fn get<'map, 'key, Q>(&'map self, k: &'key Q) -> GetAllIter<'map, 'key, Q, K, V> where K: Borrow, Q: Hash + Eq + ?Sized, @@ -198,7 +198,7 @@ where loop { match self.inner.next() { Some(bucket) => { - // SAFETY: the creator of the iterator (`get_all`) ensures that the reference + // SAFETY: the creator of the iterator (`get`) ensures that the reference // to the value outlives the RawTable. It also prevents concurrent // modifications to the table. let element = unsafe { bucket.as_ref() }; @@ -228,10 +228,10 @@ mod test { map.insert(1, 2); assert!(map.len() == 3); - let mut vals: Vec<_> = map.get_all(&1).map(|kv| kv.1).copied().collect(); + let mut vals: Vec<_> = map.get(&1).map(|kv| kv.1).copied().collect(); vals.sort_unstable(); assert_eq!(&[1, 2], vals.as_slice()); - let vals = map.get_all(&5).map(|kv| kv.1).copied().collect::>(); + let vals = map.get(&5).map(|kv| kv.1).copied().collect::>(); assert_eq!(&[5], vals.as_slice()); } @@ -242,11 +242,11 @@ mod test { map.insert("hello".to_string(), "world"); map.insert("bye".to_string(), "bob"); - let mut hellos: Vec<_> = map.get_all("hello").map(|kv| kv.1).copied().collect(); + let mut hellos: Vec<_> = map.get("hello").map(|kv| kv.1).copied().collect(); hellos.sort_unstable(); assert_eq!(&["bob", "world"], hellos.as_slice()); - let vals: Vec<_> = map.get_all("bye").map(|kv| kv.1).copied().collect(); + let vals: Vec<_> = map.get("bye").map(|kv| kv.1).copied().collect(); assert_eq!(&["bob"], vals.as_slice()); }