diff --git a/src/fetcher.rs b/src/fetcher.rs index ce73b3b..1ddbdd4 100644 --- a/src/fetcher.rs +++ b/src/fetcher.rs @@ -67,14 +67,14 @@ where parse(BufReader::with_capacity(8_000_000, file)) } - pub fn fetch<'a>(&'a self, key: i64) -> Option<&'a Story> { + pub fn fetch(&self, key: i64) -> Option<&Story> { match self.index.binary_search_by_key(&key, |story| story.id) { Ok(i) => self.index.get(i), Err(_) => None, } } - pub fn read<'a>(&self, path: &str) -> Result> { + pub fn read(&self, path: &str) -> Result> { use Error::*; use ZipError::*; @@ -96,7 +96,7 @@ where Ok(buf) } - pub fn iter<'a>(&'a self) -> impl Iterator { + pub fn iter(&self) -> impl Iterator { self.index.iter() } } diff --git a/src/parser.rs b/src/parser.rs index fbefcea..d403d2a 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -9,7 +9,7 @@ use serde_json::from_str; use crate::error::{Error, Result}; use crate::story::Story; -const TRIM: &'static [char] = &['"', ',', ' ', '\t', '\n', '\r']; +const TRIM: &[char] = &['"', ',', ' ', '\t', '\n', '\r']; pub fn parse(reader: impl BufRead) -> Result> { use Error::*; diff --git a/src/story.rs b/src/story.rs index 61169be..e5bdb7f 100644 --- a/src/story.rs +++ b/src/story.rs @@ -170,9 +170,10 @@ impl<'de> Deserialize<'de> for Color { { let object = Value::deserialize(d)?; - let text = object["hex"] - .as_str() - .ok_or(Error::custom("Color is missing hex value."))?; + let text = object + .get("hex") + .and_then(|value| value.as_str()) + .ok_or_else(|| Error::custom("Color is missing hex value."))?; let array = hex::decode(text).map_err(|e| match e { _ => Error::custom("Color hex has invalid value."),