From e59d7817b46798b5e3a680e1834e7afe817ad288 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 22 Jan 2019 16:59:49 -0700 Subject: [PATCH] fix(api): Clarify lifetimes --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f72ff50..59d3726 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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()) } }