From 781b3670a08d5c979c69e70b1eb17346eef15054 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Mon, 7 Oct 2024 11:50:02 +0800 Subject: [PATCH] chore: Polish impl of saturating_mul (#151) Signed-off-by: Xuanwo --- backon/src/backoff/exponential.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/backon/src/backoff/exponential.rs b/backon/src/backoff/exponential.rs index 780289b..cee9932 100644 --- a/backon/src/backoff/exponential.rs +++ b/backon/src/backoff/exponential.rs @@ -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)]