diff --git a/benches/image_compression.rs b/benches/image_compression.rs index d025caf0..c59173e4 100644 --- a/benches/image_compression.rs +++ b/benches/image_compression.rs @@ -232,7 +232,7 @@ fn compression_benchmark(c: &mut Criterion) { let files = fs::read_dir("/home/rasputin/qoi_benchmark_images/screenshot_web/") .unwrap() .map(|dirent| dirent.unwrap().path()) - .filter(|path| path.extension().map_or(false, |ext| ext == "png")); + .filter(|path| path.extension().is_some_and(|ext| ext == "png")); let mut compression_ratios = Vec::new(); let mut filter_compression_ratios = Vec::new(); for file in files { diff --git a/src/args.rs b/src/args.rs index c66e7676..b986c7d7 100644 --- a/src/args.rs +++ b/src/args.rs @@ -65,8 +65,9 @@ pub trait OptionalConfig: return None; } - let config_str = fs::read_to_string(&config_file) - .expect("config file at path {config_file} exists but there was an error reading it"); + let config_str = fs::read_to_string(&config_file).unwrap_or_else(|_| { + panic!("config file at path {config_file:?} exists but there was an error reading it") + }); let config: Self = Options::default() .with_default_extension(Extensions::IMPLICIT_SOME) .from_str(&config_str) diff --git a/src/client/smithay_handlers.rs b/src/client/smithay_handlers.rs index 5773318a..203a71e3 100644 --- a/src/client/smithay_handlers.rs +++ b/src/client/smithay_handlers.rs @@ -381,7 +381,9 @@ impl SeatHandler for WprsClientState { if let Some(seat_obj) = self.seat_objects.iter_mut().find(|s| s.seat == seat) { match capability { Capability::Keyboard => { - seat_obj.keyboard.take().map(|k| k.release()); + if let Some(k) = seat_obj.keyboard.take() { + k.release() + } }, Capability::Pointer => { seat_obj.pointer.take(); diff --git a/src/xwayland_xdg_shell/client.rs b/src/xwayland_xdg_shell/client.rs index 37aa3160..b39ff84a 100644 --- a/src/xwayland_xdg_shell/client.rs +++ b/src/xwayland_xdg_shell/client.rs @@ -538,10 +538,14 @@ impl SeatHandler for WprsState { { match capability { Capability::Keyboard => { - seat_obj.keyboard.take().map(|k| k.release()); + if let Some(k) = seat_obj.keyboard.take() { + k.release() + } }, Capability::Pointer => { - seat_obj.pointer.take().map(|p| p.pointer().release()); + if let Some(p) = seat_obj.pointer.take() { + p.pointer().release() + } }, _ => {}, } diff --git a/src/xwayland_xdg_shell/compositor.rs b/src/xwayland_xdg_shell/compositor.rs index 67ab26b7..bfd152e0 100644 --- a/src/xwayland_xdg_shell/compositor.rs +++ b/src/xwayland_xdg_shell/compositor.rs @@ -415,7 +415,7 @@ pub(crate) fn find_x11_parent( .find(|(_, xwls)| { xwls.x11_surface .as_ref() - .map_or(false, |s| s.window_id() == parent_id) + .is_some_and(|s| s.window_id() == parent_id) }) .unwrap(); diff --git a/src/xwayland_xdg_shell/xwayland.rs b/src/xwayland_xdg_shell/xwayland.rs index d21cc165..5351958e 100644 --- a/src/xwayland_xdg_shell/xwayland.rs +++ b/src/xwayland_xdg_shell/xwayland.rs @@ -64,12 +64,11 @@ impl XwmHandler for WprsState { // Without this, xwayland still thinks the key that triggered the // window close is still held down and sends key repeat events. if let Some(keyboard) = self.compositor_state.seat.get_keyboard() { - if keyboard - .current_focus() - .map_or(false, |focus| focus == window) - { - let serial = SERIAL_COUNTER.next_serial(); - keyboard.set_focus(self, None, serial); + if let Some(focus) = keyboard.current_focus() { + if focus == window { + let serial = SERIAL_COUNTER.next_serial(); + keyboard.set_focus(self, None, serial); + } } } }