Merge pull request 'clippy fix' (#37) from clippy-fix into main
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good

Reviewed-on: #37
This commit is contained in:
Robin Müller 2023-10-10 10:03:17 +02:00
commit 016e0d8673
2 changed files with 15 additions and 15 deletions

View File

@ -206,7 +206,7 @@ impl PartialEq for PacketId {
impl PartialOrd for PacketId { impl PartialOrd for PacketId {
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> { fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
self.raw().partial_cmp(&other.raw()) Some(self.cmp(other))
} }
} }

View File

@ -307,12 +307,18 @@ impl From<DateTime<Utc>> for UnixTimestamp {
impl PartialOrd for UnixTimestamp { impl PartialOrd for UnixTimestamp {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for UnixTimestamp {
fn cmp(&self, other: &Self) -> Ordering {
if self == other { if self == other {
return Some(Ordering::Equal); return Ordering::Equal;
} }
match self.unix_seconds.cmp(&other.unix_seconds) { match self.unix_seconds.cmp(&other.unix_seconds) {
Ordering::Less => return Some(Ordering::Less), Ordering::Less => return Ordering::Less,
Ordering::Greater => return Some(Ordering::Greater), Ordering::Greater => return Ordering::Greater,
_ => (), _ => (),
} }
@ -323,27 +329,21 @@ impl PartialOrd for UnixTimestamp {
{ {
Ordering::Less => { Ordering::Less => {
return if self.unix_seconds < 0 { return if self.unix_seconds < 0 {
Some(Ordering::Greater) Ordering::Greater
} else { } else {
Some(Ordering::Less) Ordering::Less
} }
} }
Ordering::Greater => { Ordering::Greater => {
return if self.unix_seconds < 0 { return if self.unix_seconds < 0 {
Some(Ordering::Less) Ordering::Less
} else { } else {
Some(Ordering::Greater) Ordering::Greater
} }
} }
Ordering::Equal => (), Ordering::Equal => (),
} }
Some(Ordering::Equal) Ordering::Equal
}
}
impl Ord for UnixTimestamp {
fn cmp(&self, other: &Self) -> Ordering {
PartialOrd::partial_cmp(self, other).unwrap()
} }
} }