From 482d3204072f365ec0c5c3e48cfdd3e27d3b3fa2 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 11 Nov 2020 12:22:23 -0600 Subject: [PATCH] fix(dict): Ensure we fall through to built-in dict --- src/dict.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/dict.rs b/src/dict.rs index d0e0aa9..a6993d6 100644 --- a/src/dict.rs +++ b/src/dict.rs @@ -212,16 +212,14 @@ impl<'i, 'w, D: typos::Dictionary> typos::Dictionary for Override<'i, 'w, D> { fn correct_word<'s, 't>(&'s self, word: typos::tokens::Word<'t>) -> Option> { // Skip hashing if we can - if !self.words.is_empty() { + let custom = if !self.words.is_empty() { let w = UniCase::new(word.token()); // HACK: couldn't figure out the lifetime issue with replacing `cloned` with `borrow` - self.words - .get(&w) - .cloned() - .or_else(|| self.inner.correct_word(word)) + self.words.get(&w).cloned() } else { None - } + }; + custom.or_else(|| self.inner.correct_word(word)) } }