From fd6873b6e0d1dcca6e8fd739a9dc7844e7963e5d Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 25 Sep 2023 12:40:17 -0500 Subject: [PATCH] refactor(cli): Make room for ident correction --- crates/typos-cli/src/dict.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/typos-cli/src/dict.rs b/crates/typos-cli/src/dict.rs index f69abe0..8a2c0fe 100644 --- a/crates/typos-cli/src/dict.rs +++ b/crates/typos-cli/src/dict.rs @@ -32,7 +32,7 @@ impl BuiltIn { let word = word_token.token(); let word_case = unicase::UniCase::new(word); - let mut corrections = if let Some(corrections) = self.correct_with_dict(word_case) { + let mut corrections = if let Some(corrections) = self.correct_word_with_dict(word_case) { if corrections.is_empty() { Status::Invalid } else { @@ -51,14 +51,20 @@ impl BuiltIn { #[cfg(feature = "dict")] impl BuiltIn { // Not using `Status` to avoid the allocations - fn correct_with_dict(&self, word: unicase::UniCase<&str>) -> Option<&'static [&'static str]> { + fn correct_word_with_dict( + &self, + word: unicase::UniCase<&str>, + ) -> Option<&'static [&'static str]> { typos_dict::WORD_TRIE.find(&word).copied() } } #[cfg(not(feature = "dict"))] impl BuiltIn { - fn correct_with_dict(&self, _word: unicase::UniCase<&str>) -> Option<&'static [&'static str]> { + fn correct_word_with_dict( + &self, + _word: unicase::UniCase<&str>, + ) -> Option<&'static [&'static str]> { None } }