Chore: Apply latest nightly clippy lints

This commit is contained in:
Kyle Simpson
2023-01-09 00:43:53 +00:00
parent c60c454cf5
commit 125c803fa7
9 changed files with 21 additions and 31 deletions

View File

@@ -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"),
}
}

View File

@@ -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]

View File

@@ -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
}

View File

@@ -234,7 +234,7 @@ impl Read for AsyncAdapterStream {
std::thread::yield_now();
},
a => {
println!("Misc err {:?}", a);
println!("Misc err {a:?}");
return a;
},
}

View File

@@ -27,10 +27,10 @@ pub enum Error {
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
match self {
Self::Create(c) => f.write_fmt(format_args!("failed to create audio stream: {}", c)),
Self::Create(c) => f.write_fmt(format_args!("failed to create audio stream: {c}")),
Self::CreatePanicked => f.write_str("sync thread panicked while creating stream"),
Self::Streamcatcher(s) =>
f.write_fmt(format_args!("illegal streamcatcher config: {}", s)),
f.write_fmt(format_args!("illegal streamcatcher config: {s}")),
Self::StreamNotAtStart =>
f.write_str("stream cannot have been pre-read/parsed, missing headers"),
}
@@ -87,9 +87,9 @@ pub enum CodecCacheError {
impl Display for CodecCacheError {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
match self {
Self::Create(c) => f.write_fmt(format_args!("failed to create audio stream: {}", c)),
Self::Parse(p) => f.write_fmt(format_args!("failed to parse audio format: {}", p)),
Self::Opus(o) => f.write_fmt(format_args!("failed to create Opus encoder: {}", o)),
Self::Create(c) => f.write_fmt(format_args!("failed to create audio stream: {c}")),
Self::Parse(p) => f.write_fmt(format_args!("failed to parse audio format: {p}")),
Self::Opus(o) => f.write_fmt(format_args!("failed to create Opus encoder: {o}")),
Self::MetadataEncoding(m) => f.write_fmt(format_args!(
"failed to convert track metadata to JSON: {}",
m
@@ -99,7 +99,7 @@ impl Display for CodecCacheError {
Self::UnknownChannelCount =>
f.write_str("audio stream's channel count could not be determined"),
Self::Streamcatcher(s) =>
f.write_fmt(format_args!("illegal streamcatcher config: {}", s)),
f.write_fmt(format_args!("illegal streamcatcher config: {s}")),
Self::StreamNotAtStart =>
f.write_str("stream cannot have been pre-read/parsed, missing headers"),
}

View File

@@ -25,7 +25,7 @@ impl Display for AudioStreamError {
f.write_str("failed to create audio: ")?;
match self {
Self::RetryIn(t) => f.write_fmt(format_args!("retry in {:.2}s", t.as_secs_f32())),
Self::Fail(why) => f.write_fmt(format_args!("{}", why)),
Self::Fail(why) => f.write_fmt(format_args!("{why}")),
Self::Unsupported => f.write_str("operation was not supported"),
}
}
@@ -150,8 +150,7 @@ impl Display for AuxMetadataError {
f.write_str("failed to get aux_metadata: ")?;
match self {
Self::NoCompose => f.write_str("the input has no Compose object"),
Self::Retrieve(e) =>
f.write_fmt(format_args!("aux_metadata error from Compose: {}", e)),
Self::Retrieve(e) => f.write_fmt(format_args!("aux_metadata error from Compose: {e}")),
}
}
}

View File

@@ -66,7 +66,7 @@ impl HttpRequest {
match (offset, self.content_length) {
(Some(offset), None) => {
resp = resp.header(RANGE, format!("bytes={}-", offset));
resp = resp.header(RANGE, format!("bytes={offset}-"));
},
(offset, Some(max)) => {
resp = resp.header(

View File

@@ -46,12 +46,12 @@ impl Debug for TrackCommand {
Self::Play => "Play".to_string(),
Self::Pause => "Pause".to_string(),
Self::Stop => "Stop".to_string(),
Self::Volume(vol) => format!("Volume({})", vol),
Self::Volume(vol) => format!("Volume({vol})"),
Self::Seek(s) => format!("Seek({:?})", s.time),
Self::AddEvent(evt) => format!("AddEvent({:?})", evt),
Self::AddEvent(evt) => format!("AddEvent({evt:?})"),
Self::Do(_f) => "Do([function])".to_string(),
Self::Request(tx) => format!("Request({:?})", tx),
Self::Loop(loops) => format!("Loop({:?})", loops),
Self::Request(tx) => format!("Request({tx:?})"),
Self::Loop(loops) => format!("Loop({loops:?})"),
Self::MakePlayable(_) => "MakePlayable".to_string(),
}
)

View File

@@ -37,7 +37,7 @@ impl Display for ControlError {
write!(f, "given event listener can't be fired on a track")
},
ControlError::Play(p) => {
write!(f, "i/o request on track failed: {}", p)
write!(f, "i/o request on track failed: {p}")
},
ControlError::Dropped => write!(f, "request was replaced by another of same type"),
}