Skip to content

Commit 396ce31

Browse files
committed
make clippy happy
1 parent bad4098 commit 396ce31

14 files changed

+92
-115
lines changed

entity/src/artist.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,17 @@ impl PartialEq for Model {
119119
}
120120
impl Eq for Model {}
121121

122+
impl Ord for Model {
123+
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
124+
self.id.cmp(&other.id)
125+
}
126+
}
127+
122128
impl PartialOrd for Model {
123129
fn lt(&self, other: &Self) -> bool {
124130
self.id.lt(&other.id)
125131
}
126132
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
127-
self.id.partial_cmp(&other.id)
128-
}
129-
}
130-
131-
impl Ord for Model {
132-
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
133-
self.id.cmp(&other.id)
133+
Some(self.cmp(other))
134134
}
135135
}

entity/src/artist_credit.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@ impl PartialEq for Model {
8181
}
8282
impl Eq for Model {}
8383

84+
impl Ord for Model {
85+
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
86+
self.id.cmp(&other.id)
87+
}
88+
}
89+
8490
impl PartialOrd for Model {
8591
fn lt(&self, other: &Self) -> bool {
8692
self.id.lt(&other.id)
8793
}
8894
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
89-
self.id.partial_cmp(&other.id)
90-
}
91-
}
92-
93-
impl Ord for Model {
94-
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
95-
self.id.cmp(&other.id)
95+
Some(self.cmp(other))
9696
}
9797
}

entity/src/artist_credit_release.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,6 @@ impl PartialEq for Model {
4848
}
4949
impl Eq for Model {}
5050

51-
impl PartialOrd for Model {
52-
fn lt(&self, other: &Self) -> bool {
53-
self.artist_credit_id.lt(&other.artist_credit_id) && self.release_id.lt(&other.release_id)
54-
}
55-
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
56-
self.artist_credit_id
57-
.partial_cmp(&other.artist_credit_id)
58-
.and(self.release_id.partial_cmp(&other.release_id))
59-
}
60-
}
61-
6251
impl Ord for Model {
6352
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
6453
if self.eq(other) {
@@ -68,3 +57,12 @@ impl Ord for Model {
6857
}
6958
}
7059
}
60+
61+
impl PartialOrd for Model {
62+
fn lt(&self, other: &Self) -> bool {
63+
self.artist_credit_id.lt(&other.artist_credit_id) && self.release_id.lt(&other.release_id)
64+
}
65+
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
66+
Some(self.cmp(other))
67+
}
68+
}

entity/src/artist_credit_track.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,6 @@ impl PartialEq for Model {
4848
}
4949
impl Eq for Model {}
5050

51-
impl PartialOrd for Model {
52-
fn lt(&self, other: &Self) -> bool {
53-
self.artist_credit_id.lt(&other.artist_credit_id) && self.track_id.lt(&other.track_id)
54-
}
55-
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
56-
self.artist_credit_id
57-
.partial_cmp(&other.artist_credit_id)
58-
.and(self.track_id.partial_cmp(&other.track_id))
59-
}
60-
}
61-
6251
impl Ord for Model {
6352
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
6453
if self.eq(other) {
@@ -68,3 +57,12 @@ impl Ord for Model {
6857
}
6958
}
7059
}
60+
61+
impl PartialOrd for Model {
62+
fn lt(&self, other: &Self) -> bool {
63+
self.artist_credit_id.lt(&other.artist_credit_id) && self.track_id.lt(&other.track_id)
64+
}
65+
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
66+
Some(self.cmp(other))
67+
}
68+
}

entity/src/artist_track_relation.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ impl PartialEq for Model {
131131
}
132132
impl Eq for Model {}
133133

134+
impl Ord for Model {
135+
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
136+
if self.eq(other) {
137+
std::cmp::Ordering::Equal
138+
} else {
139+
self.artist_id.cmp(&other.artist_id)
140+
}
141+
}
142+
}
143+
134144
impl PartialOrd for Model {
135145
fn lt(&self, other: &Self) -> bool {
136146
self.artist_id.lt(&other.artist_id)
@@ -139,20 +149,6 @@ impl PartialOrd for Model {
139149
&& self.relation_value.lt(&other.relation_value)
140150
}
141151
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
142-
self.artist_id
143-
.partial_cmp(&other.artist_id)
144-
.and(self.track_id.partial_cmp(&other.track_id))
145-
.and(self.relation_type.partial_cmp(&other.relation_type))
146-
.and(self.relation_value.partial_cmp(&other.relation_value))
147-
}
148-
}
149-
150-
impl Ord for Model {
151-
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
152-
if self.eq(other) {
153-
std::cmp::Ordering::Equal
154-
} else {
155-
self.artist_id.cmp(&other.artist_id)
156-
}
152+
Some(self.cmp(other))
157153
}
158154
}

entity/src/genre.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,17 @@ impl PartialEq for Model {
8787
}
8888
impl Eq for Model {}
8989

90+
impl Ord for Model {
91+
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
92+
self.id.cmp(&other.id)
93+
}
94+
}
95+
9096
impl PartialOrd for Model {
9197
fn lt(&self, other: &Self) -> bool {
9298
self.id.lt(&other.id)
9399
}
94100
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
95-
self.id.partial_cmp(&other.id)
96-
}
97-
}
98-
99-
impl Ord for Model {
100-
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
101-
self.id.cmp(&other.id)
101+
Some(self.cmp(other))
102102
}
103103
}

entity/src/genre_release.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,6 @@ impl PartialEq for Model {
4848
}
4949
impl Eq for Model {}
5050

51-
impl PartialOrd for Model {
52-
fn lt(&self, other: &Self) -> bool {
53-
self.genre_id.lt(&other.genre_id) && self.release_id.lt(&other.release_id)
54-
}
55-
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
56-
self.genre_id
57-
.partial_cmp(&other.genre_id)
58-
.and(self.release_id.partial_cmp(&other.release_id))
59-
}
60-
}
61-
6251
impl Ord for Model {
6352
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
6453
if self.eq(other) {
@@ -68,3 +57,12 @@ impl Ord for Model {
6857
}
6958
}
7059
}
60+
61+
impl PartialOrd for Model {
62+
fn lt(&self, other: &Self) -> bool {
63+
self.genre_id.lt(&other.genre_id) && self.release_id.lt(&other.release_id)
64+
}
65+
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
66+
Some(self.cmp(other))
67+
}
68+
}

entity/src/genre_track.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,6 @@ impl PartialEq for Model {
4949
}
5050
impl Eq for Model {}
5151

52-
impl PartialOrd for Model {
53-
fn lt(&self, other: &Self) -> bool {
54-
self.genre_id.lt(&other.genre_id) && self.track_id.lt(&other.track_id)
55-
}
56-
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
57-
self.genre_id
58-
.partial_cmp(&other.genre_id)
59-
.and(self.track_id.partial_cmp(&other.track_id))
60-
}
61-
}
62-
6352
impl Ord for Model {
6453
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
6554
if self.eq(other) {
@@ -69,3 +58,12 @@ impl Ord for Model {
6958
}
7059
}
7160
}
61+
62+
impl PartialOrd for Model {
63+
fn lt(&self, other: &Self) -> bool {
64+
self.genre_id.lt(&other.genre_id) && self.track_id.lt(&other.track_id)
65+
}
66+
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
67+
Some(self.cmp(other))
68+
}
69+
}

entity/src/medium.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,17 @@ impl PartialEq for Model {
8080
}
8181
impl Eq for Model {}
8282

83+
impl Ord for Model {
84+
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
85+
self.id.cmp(&other.id)
86+
}
87+
}
88+
8389
impl PartialOrd for Model {
8490
fn lt(&self, other: &Self) -> bool {
8591
self.id.lt(&other.id)
8692
}
8793
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
88-
self.id.partial_cmp(&other.id)
89-
}
90-
}
91-
92-
impl Ord for Model {
93-
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
94-
self.id.cmp(&other.id)
94+
Some(self.cmp(other))
9595
}
9696
}

entity/src/release.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,17 @@ impl PartialEq for Model {
136136
}
137137
impl Eq for Model {}
138138

139+
impl Ord for Model {
140+
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
141+
self.id.cmp(&other.id)
142+
}
143+
}
144+
139145
impl PartialOrd for Model {
140146
fn lt(&self, other: &Self) -> bool {
141147
self.id.lt(&other.id)
142148
}
143149
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
144-
self.id.partial_cmp(&other.id)
145-
}
146-
}
147-
148-
impl Ord for Model {
149-
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
150-
self.id.cmp(&other.id)
150+
Some(self.cmp(other))
151151
}
152152
}

entity/src/track.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,17 @@ impl PartialEq for Model {
161161
}
162162
impl Eq for Model {}
163163

164+
impl Ord for Model {
165+
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
166+
self.id.cmp(&other.id)
167+
}
168+
}
169+
164170
impl PartialOrd for Model {
165171
fn lt(&self, other: &Self) -> bool {
166172
self.id.lt(&other.id)
167173
}
168174
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
169-
self.id.partial_cmp(&other.id)
170-
}
171-
}
172-
173-
impl Ord for Model {
174-
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
175-
self.id.cmp(&other.id)
175+
Some(self.cmp(other))
176176
}
177177
}

server/src/api/documents.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,7 @@ impl Eq for Included {}
7878

7979
impl std::cmp::PartialOrd for Included {
8080
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
81-
match (self, other) {
82-
(Included::Image(a), Included::Image(b)) => a.id.partial_cmp(&b.id),
83-
(Included::Artist(a), Included::Artist(b)) => a.id.partial_cmp(&b.id),
84-
(Included::Track(a), Included::Track(b)) => a.id.partial_cmp(&b.id),
85-
(Included::Medium(a), Included::Medium(b)) => a.id.partial_cmp(&b.id),
86-
(Included::Release(a), Included::Release(b)) => a.id.partial_cmp(&b.id),
87-
(_, _) => None,
88-
}
81+
Some(self.cmp(other))
8982
}
9083
}
9184

server/src/api/internal/documents.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,7 @@ impl Eq for Included {}
137137

138138
impl std::cmp::PartialOrd for Included {
139139
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
140-
match (self, other) {
141-
(Included::Directory(a), Included::Directory(b)) => a.id.partial_cmp(&b.id),
142-
(Included::Import(a), Included::Import(b)) => a.id.partial_cmp(&b.id),
143-
(_, _) => None,
144-
}
140+
Some(self.cmp(other))
145141
}
146142
}
147143

server/src/api/jsonapi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ where
274274
})
275275
.collect()
276276
})
277-
.unwrap_or(HashMap::new()),
277+
.unwrap_or_default(),
278278
page: raw_opts.page.unwrap_or_else(default_page),
279279
};
280280
Ok(Query(opts))

0 commit comments

Comments
 (0)