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))
|
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) {
|
match self.index.binary_search_by_key(&key, |story| story.id) {
|
||||||
Ok(i) => self.index.get(i),
|
Ok(i) => self.index.get(i),
|
||||||
Err(_) => None,
|
Err(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read<'a>(&self, path: &str) -> Result<Vec<u8>> {
|
pub fn read(&self, path: &str) -> Result<Vec<u8>> {
|
||||||
use Error::*;
|
use Error::*;
|
||||||
use ZipError::*;
|
use ZipError::*;
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ where
|
||||||
Ok(buf)
|
Ok(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter<'a>(&'a self) -> impl Iterator<Item = &'a Story> {
|
pub fn iter(&self) -> impl Iterator<Item = &Story> {
|
||||||
self.index.iter()
|
self.index.iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use serde_json::from_str;
|
||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
use crate::story::Story;
|
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>> {
|
pub fn parse(reader: impl BufRead) -> Result<Vec<Story>> {
|
||||||
use Error::*;
|
use Error::*;
|
||||||
|
|
|
@ -170,9 +170,10 @@ impl<'de> Deserialize<'de> for Color {
|
||||||
{
|
{
|
||||||
let object = Value::deserialize(d)?;
|
let object = Value::deserialize(d)?;
|
||||||
|
|
||||||
let text = object["hex"]
|
let text = object
|
||||||
.as_str()
|
.get("hex")
|
||||||
.ok_or(Error::custom("Color is missing hex value."))?;
|
.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 {
|
let array = hex::decode(text).map_err(|e| match e {
|
||||||
_ => Error::custom("Color hex has invalid value."),
|
_ => Error::custom("Color hex has invalid value."),
|
||||||
|
|
Loading…
Reference in a new issue