fix(api): Clarify lifetimes

This commit is contained in:
Ed Page 2019-01-22 16:59:49 -07:00
parent 0cdd64c038
commit e59d7817b4

View file

@ -46,11 +46,11 @@ impl Corrections {
Corrections { }
}
pub fn correct_str(&self, word: &str) -> Option<&str> {
pub fn correct_str<'s>(&'s self, word: &str) -> Option<&'s str> {
DICTIONARY.get(word).map(|s| *s)
}
pub fn correct_bytes(&self, word: &[u8]) -> Option<&[u8]> {
pub fn correct_bytes<'s>(&'s self, word: &[u8]) -> Option<&'s [u8]> {
std::str::from_utf8(word).ok().and_then(|word| DICTIONARY.get(word)).map(|s| s.as_bytes())
}
}