diff options
| author | Michael Wright <mikerite@lavabit.com> | 2021-10-30 06:22:19 +0200 |
|---|---|---|
| committer | Michael Wright <mikerite@lavabit.com> | 2021-10-30 06:22:19 +0200 |
| commit | 665ff57fde7630474b59fc3f292f2b01a26a3493 (patch) | |
| tree | 1380eb56988bbf2eccc69ad3d88a9d8c2946dfc4 | |
| parent | 4c70c182c092c4b12c6bc737b808d024ffea6165 (diff) | |
| download | rust-665ff57fde7630474b59fc3f292f2b01a26a3493.tar.gz rust-665ff57fde7630474b59fc3f292f2b01a26a3493.zip | |
Remove expects from FullInt Partial{Ord,Eq}
| -rw-r--r-- | clippy_utils/src/consts.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/clippy_utils/src/consts.rs b/clippy_utils/src/consts.rs index 3e5d74a66f4..3b718d64ce6 100644 --- a/clippy_utils/src/consts.rs +++ b/clippy_utils/src/consts.rs @@ -246,27 +246,26 @@ impl FullInt { impl PartialEq for FullInt { #[must_use] fn eq(&self, other: &Self) -> bool { - self.partial_cmp(other).expect("`partial_cmp` only returns `Some(_)`") == Ordering::Equal + self.cmp(other) == Ordering::Equal } } impl PartialOrd for FullInt { #[must_use] fn partial_cmp(&self, other: &Self) -> Option<Ordering> { - Some(match (self, other) { - (&Self::S(s), &Self::S(o)) => s.cmp(&o), - (&Self::U(s), &Self::U(o)) => s.cmp(&o), - (&Self::S(s), &Self::U(o)) => Self::cmp_s_u(s, o), - (&Self::U(s), &Self::S(o)) => Self::cmp_s_u(o, s).reverse(), - }) + Some(self.cmp(other)) } } impl Ord for FullInt { #[must_use] fn cmp(&self, other: &Self) -> Ordering { - self.partial_cmp(other) - .expect("`partial_cmp` for FullInt can never return `None`") + match (self, other) { + (&Self::S(s), &Self::S(o)) => s.cmp(&o), + (&Self::U(s), &Self::U(o)) => s.cmp(&o), + (&Self::S(s), &Self::U(o)) => Self::cmp_s_u(s, o), + (&Self::U(s), &Self::S(o)) => Self::cmp_s_u(o, s).reverse(), + } } } |
