Skip to content

Commit

Permalink
chore: Polish impl of saturating_mul (#151)
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo authored Oct 7, 2024
1 parent ac84451 commit 781b367
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions backon/src/backoff/exponential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,7 @@ impl Iterator for ExponentialBackoff {

#[inline]
pub(crate) fn saturating_mul(d: Duration, rhs: f32) -> Duration {
match Duration::try_from_secs_f32(rhs * d.as_secs_f32()) {
Ok(v) => v,
Err(_) => Duration::MAX,
}
Duration::try_from_secs_f32(rhs * d.as_secs_f32()).unwrap_or(Duration::MAX)
}

#[cfg(test)]
Expand Down

0 comments on commit 781b367

Please sign in to comment.