From c6ac3069444be5847ccc8efa7ae5807c504b6a5f Mon Sep 17 00:00:00 2001 From: Runtime's Shady Backroom <76618880+runtime-shady-backroom@users.noreply.github.com> Date: Tue, 2 Jul 2024 05:51:56 -0500 Subject: [PATCH] Fix clippy warnings --- src/app/webserver/routes.rs | 6 +++--- src/gui/subscription.rs | 7 ++----- src/gui/window.rs | 2 +- src/util/panic.rs | 1 + src/util/slice.rs | 4 +--- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/app/webserver/routes.rs b/src/app/webserver/routes.rs index 3febd7f..2bd8afe 100644 --- a/src/app/webserver/routes.rs +++ b/src/app/webserver/routes.rs @@ -338,7 +338,7 @@ fn build_vibration_map(configuration: &ConfigurationV3, command: &str) -> Result }; devices.entry(motor.into()) - .or_insert_with(MotorSettings::default) + .or_default() .scalar_map .insert(motor.feature_index, (intensity, actuator_type.to_buttplug())); } @@ -362,7 +362,7 @@ fn build_vibration_map(configuration: &ConfigurationV3, command: &str) -> Result }; devices.entry(motor.into()) - .or_insert_with(MotorSettings::default) + .or_default() .linear_map .insert(motor.feature_index, (duration, position)); } @@ -382,7 +382,7 @@ fn build_vibration_map(configuration: &ConfigurationV3, command: &str) -> Result } devices.entry(motor.into()) - .or_insert_with(MotorSettings::default) + .or_default() .rotate_map .insert(motor.feature_index, (speed, direction)); } diff --git a/src/gui/subscription.rs b/src/gui/subscription.rs index e7c5bbb..060afa1 100644 --- a/src/gui/subscription.rs +++ b/src/gui/subscription.rs @@ -3,7 +3,6 @@ // buttplug-lite is licensed under the AGPL-3.0 license (see LICENSE file for details). use std::cell::RefCell; -use std::sync::atomic::{AtomicU32, Ordering}; use futures::stream::{Fuse, StreamExt as _}; use iced::{Subscription, subscription}; @@ -19,14 +18,12 @@ struct Marker; pub enum ApplicationStatusEvent { DeviceAdded, DeviceRemoved, - Tick(u32), + Tick, } -static NEXT_TICK: AtomicU32 = AtomicU32::new(0); - impl ApplicationStatusEvent { pub fn next_tick() -> ApplicationStatusEvent { - ApplicationStatusEvent::Tick(NEXT_TICK.fetch_add(1, Ordering::Relaxed)) + ApplicationStatusEvent::Tick } } diff --git a/src/gui/window.rs b/src/gui/window.rs index c759f3b..3256e11 100644 --- a/src/gui/window.rs +++ b/src/gui/window.rs @@ -416,7 +416,7 @@ impl Application for Gui { .map(|event| match event { ApplicationStatusEvent::DeviceAdded => Message::RefreshDevices, ApplicationStatusEvent::DeviceRemoved => Message::RefreshDevices, - ApplicationStatusEvent::Tick(_) => Message::Tick + ApplicationStatusEvent::Tick => Message::Tick }); Subscription::batch(vec![application_events, native_events]) } diff --git a/src/util/panic.rs b/src/util/panic.rs index 3b67abf..43e426d 100644 --- a/src/util/panic.rs +++ b/src/util/panic.rs @@ -132,6 +132,7 @@ mod tests { logging::init_console(true); set_hook(); let empty: Option<&str> = None; + #[allow(clippy::unnecessary_literal_unwrap)] empty.unwrap(); // panics after core::panicking::panic_fmt diff --git a/src/util/slice.rs b/src/util/slice.rs index ff6af17..41382ae 100644 --- a/src/util/slice.rs +++ b/src/util/slice.rs @@ -3,8 +3,6 @@ //! backport partition_dedup_by and partition_dedup_by_key from rust nightly -use std::mem; - // source: https://doc.rust-lang.org/src/core/slice/mod.rs.html#2886-2888 // tracking issue: https://github.com/rust-lang/rust/issues/54279 /// Moves all but the first of consecutive elements to the end of the slice satisfying @@ -126,7 +124,7 @@ pub fn partition_dedup_by(slice: &mut [T], mut same_bucket: F) -> usize if !same_bucket(&mut *ptr_read, &mut *prev_ptr_write) { if next_read != next_write { let ptr_write = prev_ptr_write.add(1); - mem::swap(&mut *ptr_read, &mut *ptr_write); + core::ptr::swap(ptr_read, ptr_write); } next_write += 1; }