From 9fa063ff0edd0372f0e4d0f0269056b01321cb19 Mon Sep 17 00:00:00 2001 From: Kyle Simpson Date: Sun, 21 May 2023 14:25:13 +0100 Subject: [PATCH] Chore: Clippy fixes to match new MSRV. --- src/driver/connection/mod.rs | 15 +++------------ src/driver/scheduler/live.rs | 4 ++-- src/driver/tasks/mixer/mod.rs | 2 +- src/driver/tasks/udp_rx/mod.rs | 2 +- src/handler.rs | 2 +- src/input/adapters/async_adapter.rs | 8 ++++---- src/input/adapters/cached/compressed.rs | 4 +--- src/input/adapters/cached/decompressed.rs | 4 +--- src/input/codecs/opus.rs | 2 +- src/tracks/mode.rs | 8 ++------ 10 files changed, 17 insertions(+), 34 deletions(-) diff --git a/src/driver/connection/mod.rs b/src/driver/connection/mod.rs index 855f5e20e..b7b90fffd 100644 --- a/src/driver/connection/mod.rs +++ b/src/driver/connection/mod.rs @@ -75,10 +75,7 @@ impl Connection { .await?; loop { - let value = match client.recv_json().await? { - Some(value) => value, - None => continue, - }; + let Some(value) = client.recv_json().await? else { continue }; match value { GatewayEvent::Ready(r) => { @@ -282,10 +279,7 @@ impl Connection { let mut resumed = None; loop { - let value = match client.recv_json().await? { - Some(value) => value, - None => continue, - }; + let Some(value) = client.recv_json().await? else { continue }; match value { GatewayEvent::Resumed => { @@ -337,10 +331,7 @@ fn generate_url(endpoint: &mut String) -> Result { #[inline] async fn init_cipher(client: &mut WsStream, mode: CryptoMode) -> Result { loop { - let value = match client.recv_json().await? { - Some(value) => value, - None => continue, - }; + let Some(value) = client.recv_json().await? else { continue }; match value { GatewayEvent::SessionDescription(desc) => { diff --git a/src/driver/scheduler/live.rs b/src/driver/scheduler/live.rs index c6496716e..76b6fba1d 100644 --- a/src/driver/scheduler/live.rs +++ b/src/driver/scheduler/live.rs @@ -427,7 +427,7 @@ impl Live { if let Some((id, parked)) = self.remove_task(i) { self.global_stats.move_mixer_to_idle(); - let _ = self.tx.send(SchedulerMessage::Demote(id, parked)); + _ = self.tx.send(SchedulerMessage::Demote(id, parked)); } else { self.global_stats.remove_live_mixer(); } @@ -445,7 +445,7 @@ impl Live { if let Some((id, mut parked)) = self.remove_task(idx) { self.global_stats.move_mixer_to_idle(); parked.last_cost = Some(cost); - let _ = self + _ = self .tx .send(SchedulerMessage::Overspill(self.id, id, parked)); } else { diff --git a/src/driver/tasks/mixer/mod.rs b/src/driver/tasks/mixer/mod.rs index 6fc4e5112..f2e725ec0 100644 --- a/src/driver/tasks/mixer/mod.rs +++ b/src/driver/tasks/mixer/mod.rs @@ -821,7 +821,7 @@ impl Mixer { input, mix_state, vol, - do_passthrough.then(|| &mut *opus_frame), + do_passthrough.then_some(&mut *opus_frame), ); let return_here = if let MixType::MixedPcm(pcm_len) = mix_type { diff --git a/src/driver/tasks/udp_rx/mod.rs b/src/driver/tasks/udp_rx/mod.rs index fc97d48bb..593c0b209 100644 --- a/src/driver/tasks/udp_rx/mod.rs +++ b/src/driver/tasks/udp_rx/mod.rs @@ -114,7 +114,7 @@ impl UdpRx { } }; - let _ = self.ssrc_signalling.disconnected_users.remove(&id); + _ = self.ssrc_signalling.disconnected_users.remove(&id); if let Some((_, ssrc)) = self.ssrc_signalling.user_ssrc_map.remove(&id) { if let Some(state) = self.decoder_map.get_mut(&ssrc) { // don't cleanup immediately: leave for later cycle diff --git a/src/handler.rs b/src/handler.rs index 68bd2ab10..5b98d627e 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -141,7 +141,7 @@ impl Call { #[cfg(feature = "driver")] Some((ConnectionProgress::Complete(c), Return::Conn(first_tx, driver_tx))) => { // It's okay if the receiver hung up. - let _ = first_tx.send(()); + _ = first_tx.send(()); self.driver.raw_connect(c.clone(), driver_tx.clone()); }, diff --git a/src/input/adapters/async_adapter.rs b/src/input/adapters/async_adapter.rs index c6f119970..eb11aa495 100644 --- a/src/input/adapters/async_adapter.rs +++ b/src/input/adapters/async_adapter.rs @@ -191,7 +191,7 @@ impl AsyncAdapterStream { self.resp_rx.try_recv().ok() }; - let msg = if let Some(msg) = msg { msg } else { break None }; + let Some(msg) = msg else { break None }; // state changes match &msg { @@ -267,7 +267,7 @@ impl Seek for AsyncAdapterStream { self.check_dropped()?; - let _ = self.req_tx.send(AdapterRequest::Seek(pos)); + _ = self.req_tx.send(AdapterRequest::Seek(pos)); // wait for async to tell us that it has stopped writing, // then clear buf and allow async to write again. @@ -280,7 +280,7 @@ impl Seek for AsyncAdapterStream { self.bytes_out.skip(self.bytes_out.capacity()); - let _ = self.req_tx.send(AdapterRequest::SeekCleared); + _ = self.req_tx.send(AdapterRequest::SeekCleared); match self.handle_messages(Operation::Seek) { Some(AdapterResponse::SeekResult(a)) => a, @@ -298,7 +298,7 @@ impl MediaSource for AsyncAdapterStream { fn byte_len(&self) -> Option { self.check_dropped().ok()?; - let _ = self.req_tx.send(AdapterRequest::ByteLen); + _ = self.req_tx.send(AdapterRequest::ByteLen); match self.handle_messages(Operation::Len) { Some(AdapterResponse::ByteLen(a)) => a, diff --git a/src/input/adapters/cached/compressed.rs b/src/input/adapters/cached/compressed.rs index ac8b8996f..cb8c9447a 100644 --- a/src/input/adapters/cached/compressed.rs +++ b/src/input/adapters/cached/compressed.rs @@ -156,9 +156,7 @@ impl Compressed { .await??; // If success, guaranteed to be Parsed - let mut parsed = if let LiveInput::Parsed(parsed) = promoted { - parsed - } else { + let LiveInput::Parsed(mut parsed) = promoted else { unreachable!() }; diff --git a/src/input/adapters/cached/decompressed.rs b/src/input/adapters/cached/decompressed.rs index 5a9c14e57..224ed8a91 100644 --- a/src/input/adapters/cached/decompressed.rs +++ b/src/input/adapters/cached/decompressed.rs @@ -74,9 +74,7 @@ impl Decompressed { .await??; // If success, guaranteed to be Parsed - let parsed = if let LiveInput::Parsed(parsed) = promoted { - parsed - } else { + let LiveInput::Parsed(parsed) = promoted else { unreachable!() }; diff --git a/src/input/codecs/opus.rs b/src/input/codecs/opus.rs index 51efa6558..25cc05c28 100644 --- a/src/input/codecs/opus.rs +++ b/src/input/codecs/opus.rs @@ -126,7 +126,7 @@ impl Decoder for OpusDecoder { } fn reset(&mut self) { - let _ = self.inner.reset_state(); + _ = self.inner.reset_state(); } fn finalize(&mut self) -> FinalizeResult { diff --git a/src/tracks/mode.rs b/src/tracks/mode.rs index e7a21621b..52235a74f 100644 --- a/src/tracks/mode.rs +++ b/src/tracks/mode.rs @@ -4,8 +4,10 @@ use crate::events::TrackEvent; /// Playback status of a track. #[derive(Clone, Debug)] #[non_exhaustive] +#[derive(Default)] pub enum PlayMode { /// The track is currently playing. + #[default] Play, /// The track is currently paused, and may be resumed. Pause, @@ -67,12 +69,6 @@ impl PlayMode { } } -impl Default for PlayMode { - fn default() -> Self { - PlayMode::Play - } -} - impl PartialEq for PlayMode { fn eq(&self, other: &Self) -> bool { self.as_track_event() == other.as_track_event()