Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
runtime-shady-backroom committed Jul 2, 2024
1 parent 8353c7b commit c6ac306
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/app/webserver/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand All @@ -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));
}
Expand All @@ -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));
}
Expand Down
7 changes: 2 additions & 5 deletions src/gui/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
Expand Down
1 change: 1 addition & 0 deletions src/util/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/util/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -126,7 +124,7 @@ pub fn partition_dedup_by<T, F>(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;
}
Expand Down

0 comments on commit c6ac306

Please sign in to comment.