return optional exact words

This commit is contained in:
ad hoc 2022-05-24 09:15:49 +02:00
parent 19dac01c5c
commit 8993fec8a3
No known key found for this signature in database
GPG key ID: 4F00A782990CC643
3 changed files with 11 additions and 11 deletions

View file

@ -1041,10 +1041,10 @@ impl Index {
}
/// List the words on which typo are not allowed
pub fn exact_words<'t>(&self, txn: &'t RoTxn) -> Result<fst::Set<Cow<'t, [u8]>>> {
pub fn exact_words<'t>(&self, txn: &'t RoTxn) -> Result<Option<fst::Set<Cow<'t, [u8]>>>> {
match self.main.get::<_, Str, ByteSlice>(txn, main_key::EXACT_WORDS)? {
Some(bytes) => Ok(fst::Set::new(bytes)?.map_data(Cow::Borrowed)?),
None => Ok(fst::Set::default().map_data(Cow::Owned)?),
Some(bytes) => Ok(Some(fst::Set::new(bytes)?.map_data(Cow::Borrowed)?)),
None => Ok(None),
}
}