diff --git a/src/daemon.rs b/src/daemon.rs index 7191070..bf13207 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -31,12 +31,12 @@ pub fn main() { log::trace!("Attempting to find all keyboard file descriptors."); let mut keyboard_devices: Vec = Vec::new(); for (_, device) in evdev::enumerate().enumerate() { - if check_keyboard(&device) == true { + if check_keyboard(&device) { keyboard_devices.push(device); } } - if keyboard_devices.len() == 0 { + if keyboard_devices.is_empty() { log::error!("No valid keyboard device was detected!"); exit(1); } @@ -44,7 +44,7 @@ pub fn main() { } pub fn permission_check() { - if unistd::Uid::current().is_root() == false { + if !unistd::Uid::current().is_root() { let groups = unistd::getgroups(); for (_, groups) in groups.iter().enumerate() { for group in groups { @@ -65,10 +65,10 @@ pub fn permission_check() { pub fn check_keyboard(device: &Device) -> bool { if device.supported_keys().map_or(false, |keys| keys.contains(Key::KEY_ENTER)) { log::debug!("{} is a keyboard.", device.name().unwrap(),); - return true; + true } else { log::trace!("{} is not a keyboard.", device.name().unwrap(),); - return false; + false } } @@ -83,7 +83,7 @@ pub fn set_flags() -> App<'static> { .help("Set a custom config file path"), ) .arg(arg!(-d - -debug).required(false).help("Enable debug mode")); - return app; + app } pub fn check_config_xdg() -> std::path::PathBuf { @@ -106,5 +106,5 @@ pub fn check_config_xdg() -> std::path::PathBuf { log::warn!("The following issue may be addressed in the future, but it is certainly not a priority right now."); } } - return config_file_path; + config_file_path }