diff --git a/src/lib.rs b/src/lib.rs index dcf2492..6ded0bb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,11 @@ // Copyright (c) 2022 Andriel Ferreira // #![deny(missing_docs)] +#![allow(clippy::field_reassign_with_default)] +#![allow(clippy::let_and_return)] +#![allow(dead_code)] // TODO: Remove this +#![allow(unused_mut)] // TODO: Remove this +#![allow(unused_variables)] // TODO: Remove this #[macro_use] pub mod models; diff --git a/src/models/anime.rs b/src/models/anime.rs index 5065d0f..f53d79a 100644 --- a/src/models/anime.rs +++ b/src/models/anime.rs @@ -77,10 +77,7 @@ impl Anime { let title = data["title"].as_object().unwrap(); anime.title = Title { romaji: Some(title["romaji"].as_str().unwrap().to_string()), - english: match title["english"].as_str() { - Some(title) => Some(title.to_string()), - None => None, - }, + english: title["english"].as_str().map(|title| title.to_string()), native: title["native"].as_str().unwrap().to_string(), user_preferred: Some(title["userPreferred"].as_str().unwrap().to_string()), }; @@ -299,7 +296,7 @@ impl Anime { _ => MediaType::default(), }; relations.push(Relation { - media_type: media_type, + media_type, anime: match media_type { MediaType::Anime => Some(Anime::parse(node)), _ => None, @@ -414,14 +411,10 @@ impl Anime { } None => None, }, - color: match external_link["color"].as_str() { - Some(hex) => Some(Color::Hex(hex.to_string())), - None => None, - }, - icon: match external_link["icon"].as_str() { - Some(url) => Some(url.to_string()), - None => None, - }, + color: external_link["color"] + .as_str() + .map(|hex| Color::Hex(hex.to_string())), + icon: external_link["icon"].as_str().map(|url| url.to_string()), ..Default::default() }) } diff --git a/src/models/manga.rs b/src/models/manga.rs index 123536d..4ed43e4 100644 --- a/src/models/manga.rs +++ b/src/models/manga.rs @@ -71,10 +71,7 @@ impl Manga { let title = data["title"].as_object().unwrap(); manga.title = Title { romaji: Some(title["romaji"].as_str().unwrap().to_string()), - english: match title["english"].as_str() { - Some(title) => Some(title.to_string()), - None => None, - }, + english: title["english"].as_str().map(|title| title.to_string()), native: title["native"].as_str().unwrap().to_string(), user_preferred: Some(title["userPreferred"].as_str().unwrap().to_string()), }; @@ -276,7 +273,7 @@ impl Manga { _ => MediaType::default(), }; relations.push(Relation { - media_type: media_type, + media_type, anime: match media_type { MediaType::Anime => Some(Anime::parse(node)), _ => None, @@ -382,14 +379,10 @@ impl Manga { } None => None, }, - color: match external_link["color"].as_str() { - Some(hex) => Some(Color::Hex(hex.to_string())), - None => None, - }, - icon: match external_link["icon"].as_str() { - Some(url) => Some(url.to_string()), - None => None, - }, + color: external_link["color"] + .as_str() + .map(|hex| Color::Hex(hex.to_string())), + icon: external_link["icon"].as_str().map(|url| url.to_string()), ..Default::default() }) }