Skip to content

Commit

Permalink
Avoid wrapping in ext when using --release
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpratt committed Sep 25, 2023
1 parent c96bb1a commit 75e255d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions time/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,31 @@ impl NumericalStdDuration for u64 {
}

fn std_minutes(self) -> StdDuration {
StdDuration::from_secs(self * Second::per(Minute) as Self)
StdDuration::from_secs(
self.checked_mul(Second::per(Minute) as Self)
.expect("overflow constructing `time::Duration`"),
)
}

fn std_hours(self) -> StdDuration {
StdDuration::from_secs(self * Second::per(Hour) as Self)
StdDuration::from_secs(
self.checked_mul(Second::per(Hour) as Self)
.expect("overflow constructing `time::Duration`"),
)
}

fn std_days(self) -> StdDuration {
StdDuration::from_secs(self * Second::per(Day) as Self)
StdDuration::from_secs(
self.checked_mul(Second::per(Day) as Self)
.expect("overflow constructing `time::Duration`"),
)
}

fn std_weeks(self) -> StdDuration {
StdDuration::from_secs(self * Second::per(Week) as Self)
StdDuration::from_secs(
self.checked_mul(Second::per(Week) as Self)
.expect("overflow constructing `time::Duration`"),
)
}
}

Expand Down

0 comments on commit 75e255d

Please sign in to comment.