Fix clippy warnings

pull/140/head
Frederick Zhang 2 years ago
parent d2f6a9c73f
commit 8770711b17
No known key found for this signature in database
GPG Key ID: 980A192C361BE1AE

@ -31,10 +31,10 @@ where
D: Deserializer<'de>,
{
let action = RemapActions::deserialize(deserializer)?;
return Ok(Remap {
Ok(Remap {
remap: action.remap.into_iter().map(|(k, v)| (k, v.into_vec())).collect(),
timeout: action.timeout_millis.map(|ms| Duration::from_millis(ms)),
});
timeout: action.timeout_millis.map(Duration::from_millis),
})
}
fn deserialize_launch<'de, D>(deserializer: D) -> Result<Vec<String>, D::Error>

@ -178,6 +178,6 @@ fn test_keymap_mark() {
fn assert_parse(yaml: &str) {
let result: Result<Config, Error> = serde_yaml::from_str(yaml);
if let Err(e) = result {
assert!(false, "{}", e)
panic!("{}", e)
}
}

@ -145,7 +145,7 @@ impl EventHandler {
self.pressed_keys.insert(key, event.0);
} else {
if let Some(original_key) = self.pressed_keys.get(&key) {
events[0].0 = original_key.clone();
events[0].0 = *original_key;
}
if value == RELEASE {
self.pressed_keys.remove(&key);
@ -268,7 +268,7 @@ impl EventHandler {
let expiration = Expiration::OneShot(TimeSpec::from_duration(timeout));
self.override_timer.unset()?;
self.override_timer.set(expiration, TimerSetTimeFlags::empty())?;
self.override_timeout_key = Some(key.clone());
self.override_timeout_key = Some(*key);
}
}
Action::Launch(command) => self.run_command(command.clone()),

@ -15,7 +15,7 @@ use nix::sys::timerfd::{ClockId, TimerFd, TimerFlags};
use std::collections::HashMap;
use std::io::stdout;
use std::os::unix::io::{AsRawFd, RawFd};
use std::path::PathBuf;
use std::path::{Path, PathBuf};
mod client;
mod config;
@ -130,11 +130,11 @@ fn main() -> anyhow::Result<()> {
}
for input_device in input_devices.values_mut() {
if readable_fds.contains(input_device.as_raw_fd()) {
if !handle_input_events(input_device, &mut handler, &mut config)? {
println!("Found a removed device. Reselecting devices.");
break 'event_loop Event::ReloadDevices;
}
if readable_fds.contains(input_device.as_raw_fd())
&& !handle_input_events(input_device, &mut handler, &mut config)?
{
println!("Found a removed device. Reselecting devices.");
break 'event_loop Event::ReloadDevices;
}
}
@ -203,21 +203,19 @@ fn handle_input_events(
config: &mut Config,
) -> anyhow::Result<bool> {
match input_device.fetch_events().map_err(|e| (e.raw_os_error(), e)) {
Err((Some(ENODEV), _)) => {
return Ok(false);
}
Err((_, error)) => return Err(error).context("Error fetching input events"),
Err((Some(ENODEV), _)) => Ok(false),
Err((_, error)) => Err(error).context("Error fetching input events"),
Ok(events) => {
for event in events {
if event.event_type() == EventType::KEY {
handler
.on_event(event, &config)
.on_event(event, config)
.map_err(|e| anyhow!("Failed handling {event:?}:\n {e:?}"))?;
} else {
handler.send_event(event)?;
}
}
return Ok(true);
Ok(true)
}
}
}
@ -233,7 +231,7 @@ fn handle_device_changes(
event.name.and_then(|name| {
let path = PathBuf::from("/dev/input/").join(name);
let mut device = InputDevice::try_from(path).ok()?;
if device.is_input_device(device_filter, &ignore_filter, mouse) && device.grab() {
if device.is_input_device(device_filter, ignore_filter, mouse) && device.grab() {
device.print();
Some(device.into())
} else {
@ -250,7 +248,7 @@ fn handle_config_changes(
device_filter: &[String],
ignore_filter: &[String],
mouse: bool,
config_path: &PathBuf,
config_path: &Path,
) -> anyhow::Result<bool> {
for event in &events {
match (event.mask, &event.name) {
@ -268,7 +266,7 @@ fn handle_config_changes(
event.name.and_then(|name| {
let path = PathBuf::from("/dev/input/").join(name);
let mut device = InputDevice::try_from(path).ok()?;
if device.is_input_device(&device_filter, &ignore_filter, mouse) && device.grab() {
if device.is_input_device(device_filter, ignore_filter, mouse) && device.grab() {
device.print();
Some(device.into())
} else {

Loading…
Cancel
Save