mirror of
https://github.com/htrefil/rkvm.git
synced 2025-01-19 10:26:13 +01:00
Fix clippy warnings
This commit is contained in:
parent
bc6e35bdcf
commit
ea401ba998
5 changed files with 31 additions and 14 deletions
5
Cargo.lock
generated
5
Cargo.lock
generated
|
@ -375,8 +375,9 @@ checksum = "3c1ad908cc71012b7bea4d0c53ba96a8cba9962f048fa68d143376143d863b7a"
|
|||
|
||||
[[package]]
|
||||
name = "inotify"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/htrefil/inotify/#3838a9f0d080a6e0d41ad5dc1bcaa90a8828232b"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04c6848dfb1580647ab039713282cdd1ab2bfb47b60ecfb598e22e60e3baf3f8"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"futures-core",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Serialize, Deserialize, Hash)]
|
||||
#[derive(Clone, Copy, Debug, Eq, Serialize, Deserialize)]
|
||||
pub enum Button {
|
||||
A,
|
||||
B,
|
||||
|
@ -254,7 +255,7 @@ impl Button {
|
|||
use Button::*;
|
||||
|
||||
// This is generated from linux headers, some patterns are unreachable, and we don't care.
|
||||
#[allow(unreachable_patterns)]
|
||||
#[allow(unreachable_patterns, clippy::match_overlapping_arm)]
|
||||
let button = match code {
|
||||
0x0130 => A,
|
||||
0x0131 => B,
|
||||
|
@ -385,3 +386,12 @@ impl PartialEq for Button {
|
|||
self.to_raw() == other.to_raw()
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for Button {
|
||||
fn hash<H>(&self, state: &mut H)
|
||||
where
|
||||
H: Hasher,
|
||||
{
|
||||
self.to_raw().hash(state)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Serialize, Deserialize, Hash)]
|
||||
#[derive(Clone, Copy, Debug, Eq, Serialize, Deserialize)]
|
||||
pub enum Key {
|
||||
A,
|
||||
Ab,
|
||||
|
@ -1487,3 +1488,12 @@ impl PartialEq for Key {
|
|||
self.to_raw() == other.to_raw()
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for Key {
|
||||
fn hash<H>(&self, state: &mut H)
|
||||
where
|
||||
H: Hasher,
|
||||
{
|
||||
self.to_raw().hash(state)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ pub struct EventWriter {
|
|||
|
||||
impl EventWriter {
|
||||
pub async fn new() -> Result<Self, Error> {
|
||||
tokio::task::spawn_blocking(|| Self::new_sync()).await?
|
||||
tokio::task::spawn_blocking(Self::new_sync).await?
|
||||
}
|
||||
|
||||
fn new_sync() -> Result<Self, Error> {
|
||||
|
@ -109,7 +109,7 @@ unsafe fn setup_evdev(evdev: *mut libevdev) -> Result<(), Error> {
|
|||
return Err(Error::from_raw_os_error(-ret));
|
||||
}
|
||||
|
||||
for code in codes.iter().cloned().flat_map(|code| code) {
|
||||
for code in codes.iter().cloned().flatten() {
|
||||
let ret = glue::libevdev_enable_event_code(evdev, r#type, code, std::ptr::null_mut());
|
||||
if ret < 0 {
|
||||
return Err(Error::from_raw_os_error(-ret));
|
||||
|
|
|
@ -101,7 +101,7 @@ async fn run(
|
|||
.await
|
||||
.err()
|
||||
.map(|err| format!(" ({})", err))
|
||||
.unwrap_or(String::new());
|
||||
.unwrap_or_else(String::new);
|
||||
log::info!("{}: disconnected{}", address, message);
|
||||
});
|
||||
}
|
||||
|
@ -121,17 +121,13 @@ async fn run(
|
|||
let event = event?;
|
||||
if let Event::Key { direction, kind: KeyKind::Key(key) } = event {
|
||||
if let Some(state) = key_states.get_mut(&key) {
|
||||
*state = if direction == Direction::Down {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
};
|
||||
*state = direction == Direction::Down;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: This won't work with multiple keys.
|
||||
if key_states.iter().filter(|(_, state)| **state).count() == key_states.len() {
|
||||
for (_, state) in &mut key_states {
|
||||
for state in key_states.values_mut() {
|
||||
*state = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue