From 8cbfef4a1cd38da7103e3e7f850d67be224d1f8d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 10 Oct 2023 10:00:14 +0200 Subject: [PATCH] clippy fix --- src/lib.rs | 2 +- src/time/mod.rs | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index ec2bcd1..2b422bd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -206,7 +206,7 @@ impl PartialEq for PacketId { impl PartialOrd for PacketId { fn partial_cmp(&self, other: &Self) -> Option { - self.raw().partial_cmp(&other.raw()) + Some(self.cmp(other)) } } diff --git a/src/time/mod.rs b/src/time/mod.rs index ba7aee2..5dedf99 100644 --- a/src/time/mod.rs +++ b/src/time/mod.rs @@ -307,12 +307,18 @@ impl From> for UnixTimestamp { impl PartialOrd for UnixTimestamp { fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for UnixTimestamp { + fn cmp(&self, other: &Self) -> Ordering { if self == other { - return Some(Ordering::Equal); + return Ordering::Equal; } match self.unix_seconds.cmp(&other.unix_seconds) { - Ordering::Less => return Some(Ordering::Less), - Ordering::Greater => return Some(Ordering::Greater), + Ordering::Less => return Ordering::Less, + Ordering::Greater => return Ordering::Greater, _ => (), } @@ -323,27 +329,21 @@ impl PartialOrd for UnixTimestamp { { Ordering::Less => { return if self.unix_seconds < 0 { - Some(Ordering::Greater) + Ordering::Greater } else { - Some(Ordering::Less) + Ordering::Less } } Ordering::Greater => { return if self.unix_seconds < 0 { - Some(Ordering::Less) + Ordering::Less } else { - Some(Ordering::Greater) + Ordering::Greater } } Ordering::Equal => (), } - Some(Ordering::Equal) - } -} - -impl Ord for UnixTimestamp { - fn cmp(&self, other: &Self) -> Ordering { - PartialOrd::partial_cmp(self, other).unwrap() + Ordering::Equal } }