Skip to content

Commit 665ff57

Browse files
author
Michael Wright
committed
Remove expects from FullInt Partial{Ord,Eq}
1 parent 4c70c18 commit 665ff57

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

clippy_utils/src/consts.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,27 +246,26 @@ impl FullInt {
246246
impl PartialEq for FullInt {
247247
#[must_use]
248248
fn eq(&self, other: &Self) -> bool {
249-
self.partial_cmp(other).expect("`partial_cmp` only returns `Some(_)`") == Ordering::Equal
249+
self.cmp(other) == Ordering::Equal
250250
}
251251
}
252252

253253
impl PartialOrd for FullInt {
254254
#[must_use]
255255
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
256-
Some(match (self, other) {
257-
(&Self::S(s), &Self::S(o)) => s.cmp(&o),
258-
(&Self::U(s), &Self::U(o)) => s.cmp(&o),
259-
(&Self::S(s), &Self::U(o)) => Self::cmp_s_u(s, o),
260-
(&Self::U(s), &Self::S(o)) => Self::cmp_s_u(o, s).reverse(),
261-
})
256+
Some(self.cmp(other))
262257
}
263258
}
264259

265260
impl Ord for FullInt {
266261
#[must_use]
267262
fn cmp(&self, other: &Self) -> Ordering {
268-
self.partial_cmp(other)
269-
.expect("`partial_cmp` for FullInt can never return `None`")
263+
match (self, other) {
264+
(&Self::S(s), &Self::S(o)) => s.cmp(&o),
265+
(&Self::U(s), &Self::U(o)) => s.cmp(&o),
266+
(&Self::S(s), &Self::U(o)) => Self::cmp_s_u(s, o),
267+
(&Self::U(s), &Self::S(o)) => Self::cmp_s_u(o, s).reverse(),
268+
}
270269
}
271270
}
272271

0 commit comments

Comments
 (0)