Skip to content

Commit

Permalink
time partial ord
Browse files Browse the repository at this point in the history
  • Loading branch information
KG32 committed Nov 29, 2024
1 parent 6a33805 commit 4f09532
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/common/time.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::ops::{Add, AddAssign, Div, Mul, Sub};
use std::{
cmp::Ordering,
ops::{Add, AddAssign, Div, Mul, Sub},
};

#[derive(Clone, Copy, Debug, PartialEq, Default)]
pub struct Time {
Expand Down Expand Up @@ -43,6 +46,11 @@ impl Div<Self> for Time {
Self { s: self.s / rhs.s }
}
}
impl PartialOrd for Time {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.s.partial_cmp(&other.s)
}
}

impl Time {
pub fn from_seconds(val: f64) -> Self {
Expand Down

0 comments on commit 4f09532

Please sign in to comment.