Skip to content

Commit

Permalink
style: do clippy changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrielFR committed Apr 2, 2022
1 parent 3c72242 commit 9f1c9ef
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// Copyright (c) 2022 Andriel Ferreira <https://github.com/AndrielFR>

// #![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;
Expand Down
19 changes: 6 additions & 13 deletions src/models/anime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
})
}
Expand Down
19 changes: 6 additions & 13 deletions src/models/manga.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
})
}
Expand Down

0 comments on commit 9f1c9ef

Please sign in to comment.