mirror of
https://github.com/JockeTF/fimfareader.git
synced 2024-11-27 07:28:00 +01:00
Fix linter warnings from Clippy
This commit is contained in:
parent
d1f9f588d5
commit
21088cb539
3 changed files with 8 additions and 7 deletions
|
@ -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<Vec<u8>> {
|
||||
pub fn read(&self, path: &str) -> Result<Vec<u8>> {
|
||||
use Error::*;
|
||||
use ZipError::*;
|
||||
|
||||
|
@ -96,7 +96,7 @@ where
|
|||
Ok(buf)
|
||||
}
|
||||
|
||||
pub fn iter<'a>(&'a self) -> impl Iterator<Item = &'a Story> {
|
||||
pub fn iter(&self) -> impl Iterator<Item = &Story> {
|
||||
self.index.iter()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Vec<Story>> {
|
||||
use Error::*;
|
||||
|
|
|
@ -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."),
|
||||
|
|
Loading…
Reference in a new issue