diff options
| author | David Lönnhager <david.l@mullvad.net> | 2021-12-14 14:27:50 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2021-12-15 09:43:13 +0100 |
| commit | 0b5c22239ecc1d0b2c18e7bd96fde6dec8e2b741 (patch) | |
| tree | e4569a1a6b098c2e32a14ff29b1e28108503140f | |
| parent | 4dfe45db089d6b5039f412b6eaf58abff3e6b75a (diff) | |
| download | mullvadvpn-0b5c22239ecc1d0b2c18e7bd96fde6dec8e2b741.tar.xz mullvadvpn-0b5c22239ecc1d0b2c18e7bd96fde6dec8e2b741.zip | |
Use Duration::MAX where applicable
| -rw-r--r-- | talpid-core/src/future_retry.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/talpid-core/src/future_retry.rs b/talpid-core/src/future_retry.rs index 3c640a9037..641babac33 100644 --- a/talpid-core/src/future_retry.rs +++ b/talpid-core/src/future_retry.rs @@ -81,8 +81,8 @@ impl ExponentialBackoff { } } - /// Set the maximum delay. By default, there is no maximum value set, but the practical limit - /// is `std::u64::MAX`. + /// Set the maximum delay. By default, there is no maximum value set. The limit is + /// `Duration::MAX`. pub fn max_delay(mut self, duration: Duration) -> ExponentialBackoff { self.max_delay = Some(duration); self @@ -98,10 +98,7 @@ impl ExponentialBackoff { } } - // TODO: Use Duration::MAX when it is available - self.next = next - .checked_mul(self.factor) - .unwrap_or(Duration::from_secs(u64::MAX)); + self.next = next.saturating_mul(self.factor); next } @@ -161,7 +158,7 @@ mod test { #[test] fn test_at_maximum_value() { - let max = Duration::from_secs(u64::MAX); + let max = Duration::MAX; let mu = Duration::from_micros(1); let mut backoff = ExponentialBackoff::new(max - mu, 2); |
