Chore: Apply latest nightly clippy lints
This commit is contained in:
@@ -109,8 +109,8 @@ impl fmt::Display for Error {
|
||||
Self::IllegalIp => write!(f, "IP discovery/NAT punching response had bad IP value"),
|
||||
Self::Io(e) => e.fmt(f),
|
||||
Self::Json(e) => e.fmt(f),
|
||||
Self::InterconnectFailure(e) => write!(f, "failed to contact other task ({:?})", e),
|
||||
Self::Ws(e) => write!(f, "websocket issue ({:?}).", e),
|
||||
Self::InterconnectFailure(e) => write!(f, "failed to contact other task ({e:?})"),
|
||||
Self::Ws(e) => write!(f, "websocket issue ({e:?})."),
|
||||
Self::TimedOut => write!(f, "connection attempt timed out"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ impl Connection {
|
||||
.map_err(|_| Error::IllegalIp)?;
|
||||
|
||||
let address = IpAddr::from_str(address_str).map_err(|e| {
|
||||
println!("{:?}", e);
|
||||
println!("{e:?}");
|
||||
Error::IllegalIp
|
||||
})?;
|
||||
|
||||
@@ -335,8 +335,7 @@ fn generate_url(endpoint: &mut String) -> Result<Url> {
|
||||
endpoint.truncate(len - 3);
|
||||
}
|
||||
|
||||
Url::parse(&format!("wss://{}/?v={}", endpoint, VOICE_GATEWAY_VERSION))
|
||||
.or(Err(Error::EndpointUrl))
|
||||
Url::parse(&format!("wss://{endpoint}/?v={VOICE_GATEWAY_VERSION}")).or(Err(Error::EndpointUrl))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
@@ -59,9 +59,7 @@ impl Default for ExponentialBackoff {
|
||||
impl ExponentialBackoff {
|
||||
pub(crate) fn retry_in(&self, last_wait: Option<Duration>) -> Duration {
|
||||
let attempt = last_wait.map_or(self.min, |t| 2 * t);
|
||||
let perturb = (1.0 - (self.jitter * 2.0 * (random::<f32>() - 1.0)))
|
||||
.max(0.0)
|
||||
.min(2.0);
|
||||
let perturb = (1.0 - (self.jitter * 2.0 * (random::<f32>() - 1.0))).clamp(0.0, 2.0);
|
||||
let mut target_time = attempt.mul_f32(perturb);
|
||||
|
||||
// Now clamp target time into given range.
|
||||
@@ -71,13 +69,7 @@ impl ExponentialBackoff {
|
||||
self.max
|
||||
};
|
||||
|
||||
if target_time > safe_max {
|
||||
target_time = safe_max;
|
||||
}
|
||||
|
||||
if target_time < self.min {
|
||||
target_time = self.min;
|
||||
}
|
||||
target_time = target_time.clamp(self.min, safe_max);
|
||||
|
||||
target_time
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user