Skip to content

Commit

Permalink
Impl Mul and Div
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernauer committed Sep 18, 2023
1 parent 6b882e6 commit 36e8035
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/duration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{
cmp::Ordering,
fmt::Display,
num::ParseIntError,
ops::{Add, AddAssign, Deref, DerefMut, Sub, SubAssign},
ops::{Add, AddAssign, Deref, DerefMut, Div, Mul, Sub, SubAssign},
str::FromStr,
};

Expand Down Expand Up @@ -201,6 +201,22 @@ impl Sub for Duration {
}
}

impl Mul<u32> for Duration {
type Output = Self;

fn mul(self, rhs: u32) -> Duration {
Self(self.0 * rhs)
}
}

impl Div<u32> for Duration {
type Output = Self;

fn div(self, rhs: u32) -> Duration {
Self(self.0 / rhs)
}
}

impl SubAssign for Duration {
fn sub_assign(&mut self, rhs: Self) {
self.0.sub_assign(rhs.0)
Expand Down

0 comments on commit 36e8035

Please sign in to comment.