Skip to content

Commit

Permalink
make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
lucat1 committed Dec 9, 2023
1 parent bad4098 commit 396ce31
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 115 deletions.
14 changes: 7 additions & 7 deletions entity/src/artist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,17 @@ impl PartialEq for Model {
}
impl Eq for Model {}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.id.cmp(&other.id)
}
}

impl PartialOrd for Model {
fn lt(&self, other: &Self) -> bool {
self.id.lt(&other.id)
}
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.id.partial_cmp(&other.id)
}
}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.id.cmp(&other.id)
Some(self.cmp(other))
}
}
14 changes: 7 additions & 7 deletions entity/src/artist_credit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,17 @@ impl PartialEq for Model {
}
impl Eq for Model {}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.id.cmp(&other.id)
}
}

impl PartialOrd for Model {
fn lt(&self, other: &Self) -> bool {
self.id.lt(&other.id)
}
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.id.partial_cmp(&other.id)
}
}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.id.cmp(&other.id)
Some(self.cmp(other))
}
}
20 changes: 9 additions & 11 deletions entity/src/artist_credit_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ impl PartialEq for Model {
}
impl Eq for Model {}

impl PartialOrd for Model {
fn lt(&self, other: &Self) -> bool {
self.artist_credit_id.lt(&other.artist_credit_id) && self.release_id.lt(&other.release_id)
}
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.artist_credit_id
.partial_cmp(&other.artist_credit_id)
.and(self.release_id.partial_cmp(&other.release_id))
}
}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
if self.eq(other) {
Expand All @@ -68,3 +57,12 @@ impl Ord for Model {
}
}
}

impl PartialOrd for Model {
fn lt(&self, other: &Self) -> bool {
self.artist_credit_id.lt(&other.artist_credit_id) && self.release_id.lt(&other.release_id)
}
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
20 changes: 9 additions & 11 deletions entity/src/artist_credit_track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ impl PartialEq for Model {
}
impl Eq for Model {}

impl PartialOrd for Model {
fn lt(&self, other: &Self) -> bool {
self.artist_credit_id.lt(&other.artist_credit_id) && self.track_id.lt(&other.track_id)
}
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.artist_credit_id
.partial_cmp(&other.artist_credit_id)
.and(self.track_id.partial_cmp(&other.track_id))
}
}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
if self.eq(other) {
Expand All @@ -68,3 +57,12 @@ impl Ord for Model {
}
}
}

impl PartialOrd for Model {
fn lt(&self, other: &Self) -> bool {
self.artist_credit_id.lt(&other.artist_credit_id) && self.track_id.lt(&other.track_id)
}
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
26 changes: 11 additions & 15 deletions entity/src/artist_track_relation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ impl PartialEq for Model {
}
impl Eq for Model {}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
if self.eq(other) {
std::cmp::Ordering::Equal
} else {
self.artist_id.cmp(&other.artist_id)
}
}
}

impl PartialOrd for Model {
fn lt(&self, other: &Self) -> bool {
self.artist_id.lt(&other.artist_id)
Expand All @@ -139,20 +149,6 @@ impl PartialOrd for Model {
&& self.relation_value.lt(&other.relation_value)
}
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.artist_id
.partial_cmp(&other.artist_id)
.and(self.track_id.partial_cmp(&other.track_id))
.and(self.relation_type.partial_cmp(&other.relation_type))
.and(self.relation_value.partial_cmp(&other.relation_value))
}
}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
if self.eq(other) {
std::cmp::Ordering::Equal
} else {
self.artist_id.cmp(&other.artist_id)
}
Some(self.cmp(other))
}
}
14 changes: 7 additions & 7 deletions entity/src/genre.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ impl PartialEq for Model {
}
impl Eq for Model {}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.id.cmp(&other.id)
}
}

impl PartialOrd for Model {
fn lt(&self, other: &Self) -> bool {
self.id.lt(&other.id)
}
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.id.partial_cmp(&other.id)
}
}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.id.cmp(&other.id)
Some(self.cmp(other))
}
}
20 changes: 9 additions & 11 deletions entity/src/genre_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ impl PartialEq for Model {
}
impl Eq for Model {}

impl PartialOrd for Model {
fn lt(&self, other: &Self) -> bool {
self.genre_id.lt(&other.genre_id) && self.release_id.lt(&other.release_id)
}
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.genre_id
.partial_cmp(&other.genre_id)
.and(self.release_id.partial_cmp(&other.release_id))
}
}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
if self.eq(other) {
Expand All @@ -68,3 +57,12 @@ impl Ord for Model {
}
}
}

impl PartialOrd for Model {
fn lt(&self, other: &Self) -> bool {
self.genre_id.lt(&other.genre_id) && self.release_id.lt(&other.release_id)
}
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
20 changes: 9 additions & 11 deletions entity/src/genre_track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,6 @@ impl PartialEq for Model {
}
impl Eq for Model {}

impl PartialOrd for Model {
fn lt(&self, other: &Self) -> bool {
self.genre_id.lt(&other.genre_id) && self.track_id.lt(&other.track_id)
}
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.genre_id
.partial_cmp(&other.genre_id)
.and(self.track_id.partial_cmp(&other.track_id))
}
}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
if self.eq(other) {
Expand All @@ -69,3 +58,12 @@ impl Ord for Model {
}
}
}

impl PartialOrd for Model {
fn lt(&self, other: &Self) -> bool {
self.genre_id.lt(&other.genre_id) && self.track_id.lt(&other.track_id)
}
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
14 changes: 7 additions & 7 deletions entity/src/medium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ impl PartialEq for Model {
}
impl Eq for Model {}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.id.cmp(&other.id)
}
}

impl PartialOrd for Model {
fn lt(&self, other: &Self) -> bool {
self.id.lt(&other.id)
}
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.id.partial_cmp(&other.id)
}
}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.id.cmp(&other.id)
Some(self.cmp(other))
}
}
14 changes: 7 additions & 7 deletions entity/src/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,17 @@ impl PartialEq for Model {
}
impl Eq for Model {}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.id.cmp(&other.id)
}
}

impl PartialOrd for Model {
fn lt(&self, other: &Self) -> bool {
self.id.lt(&other.id)
}
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.id.partial_cmp(&other.id)
}
}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.id.cmp(&other.id)
Some(self.cmp(other))
}
}
14 changes: 7 additions & 7 deletions entity/src/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,17 @@ impl PartialEq for Model {
}
impl Eq for Model {}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.id.cmp(&other.id)
}
}

impl PartialOrd for Model {
fn lt(&self, other: &Self) -> bool {
self.id.lt(&other.id)
}
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.id.partial_cmp(&other.id)
}
}

impl Ord for Model {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.id.cmp(&other.id)
Some(self.cmp(other))
}
}
9 changes: 1 addition & 8 deletions server/src/api/documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,7 @@ impl Eq for Included {}

impl std::cmp::PartialOrd for Included {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
match (self, other) {
(Included::Image(a), Included::Image(b)) => a.id.partial_cmp(&b.id),
(Included::Artist(a), Included::Artist(b)) => a.id.partial_cmp(&b.id),
(Included::Track(a), Included::Track(b)) => a.id.partial_cmp(&b.id),
(Included::Medium(a), Included::Medium(b)) => a.id.partial_cmp(&b.id),
(Included::Release(a), Included::Release(b)) => a.id.partial_cmp(&b.id),
(_, _) => None,
}
Some(self.cmp(other))
}
}

Expand Down
6 changes: 1 addition & 5 deletions server/src/api/internal/documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,7 @@ impl Eq for Included {}

impl std::cmp::PartialOrd for Included {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
match (self, other) {
(Included::Directory(a), Included::Directory(b)) => a.id.partial_cmp(&b.id),
(Included::Import(a), Included::Import(b)) => a.id.partial_cmp(&b.id),
(_, _) => None,
}
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/src/api/jsonapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ where
})
.collect()
})
.unwrap_or(HashMap::new()),
.unwrap_or_default(),
page: raw_opts.page.unwrap_or_else(default_page),
};
Ok(Query(opts))
Expand Down

0 comments on commit 396ce31

Please sign in to comment.