Fix new Clippy warnings
Browse files at this commit623687e59baa21c23c2c854b1815cb29e9c5917eParent: 5958d3b8 changed files +21 -21
- src/backend/tty.rs +1 -1
- src/handlers/mod.rs +1 -1
- src/input/mod.rs +3 -3
- src/ipc/server.rs +2 -2
- src/layout/mod.rs +8 -8
- src/layout/monitor.rs +3 -3
- src/layout/scrolling.rs +2 -2
- src/niri.rs +1 -1
src/backend/tty.rsmodified+1 -1
| @@ -1658,7 +1658,7 @@ impl Tty { | |||
| 1658 | .unwrap_or_else(|| { | 1658 | .unwrap_or_else(|| { |
| 1659 | is_vrr_capable(&device.drm, connector.handle()) == Some(true) | 1659 | is_vrr_capable(&device.drm, connector.handle()) == Some(true) |
| 1660 | }); | 1660 | }); |
| 1661 | - let vrr_enabled = surface.map_or(false, |surface| surface.compositor.vrr_enabled()); | 1661 | + let vrr_enabled = surface.is_some_and(|surface| surface.compositor.vrr_enabled()); |
| 1662 | 1662 | ||
| 1663 | let logical = niri | 1663 | let logical = niri |
| 1664 | .global_space | 1664 | .global_space |
src/handlers/mod.rsmodified+1 -1
| @@ -155,7 +155,7 @@ impl PointerConstraintsHandler for State { | |||
| 155 | location: Point<f64, Logical>, | 155 | location: Point<f64, Logical>, |
| 156 | ) { | 156 | ) { |
| 157 | let is_constraint_active = with_pointer_constraint(surface, pointer, |constraint| { | 157 | let is_constraint_active = with_pointer_constraint(surface, pointer, |constraint| { |
| 158 | - constraint.map_or(false, |c| c.is_active()) | 158 | + constraint.is_some_and(|c| c.is_active()) |
| 159 | }); | 159 | }); |
| 160 | 160 | ||
| 161 | if !is_constraint_active { | 161 | if !is_constraint_active { |
src/input/mod.rsmodified+3 -3
| @@ -119,7 +119,7 @@ impl State { | |||
| 119 | .niri | 119 | .niri |
| 120 | .exit_confirm_dialog | 120 | .exit_confirm_dialog |
| 121 | .as_ref() | 121 | .as_ref() |
| 122 | - .map_or(false, |d| d.is_open()) | 122 | + .is_some_and(|d| d.is_open()) |
| 123 | && should_hide_exit_confirm_dialog(&event); | 123 | && should_hide_exit_confirm_dialog(&event); |
| 124 | 124 | ||
| 125 | use InputEvent::*; | 125 | use InputEvent::*; |
| @@ -989,7 +989,7 @@ impl State { | |||
| 989 | .niri | 989 | .niri |
| 990 | .layout | 990 | .layout |
| 991 | .active_output() | 991 | .active_output() |
| 992 | - .map_or(false, |active| output.as_ref() == Some(active)); | 992 | + .is_some_and(|active| output.as_ref() == Some(active)); |
| 993 | 993 | ||
| 994 | if let Some(output) = output { | 994 | if let Some(output) = output { |
| 995 | self.niri | 995 | self.niri |
| @@ -1010,7 +1010,7 @@ impl State { | |||
| 1010 | 1010 | ||
| 1011 | // If we focused the target window. | 1011 | // If we focused the target window. |
| 1012 | let new_focus = self.niri.layout.focus(); | 1012 | let new_focus = self.niri.layout.focus(); |
| 1013 | - if new_focus.map_or(false, |win| win.window == window) { | 1013 | + if new_focus.is_some_and(|win| win.window == window) { |
| 1014 | self.maybe_warp_cursor_to_focus(); | 1014 | self.maybe_warp_cursor_to_focus(); |
| 1015 | } | 1015 | } |
| 1016 | } | 1016 | } |
src/ipc/server.rsmodified+2 -2
| @@ -523,7 +523,7 @@ impl State { | |||
| 523 | } | 523 | } |
| 524 | 524 | ||
| 525 | // Check if this workspace became active. | 525 | // Check if this workspace became active. |
| 526 | - let is_active = mon.map_or(false, |mon| mon.active_workspace_idx() == ws_idx); | 526 | + let is_active = mon.is_some_and(|mon| mon.active_workspace_idx() == ws_idx); |
| 527 | if is_active && !ipc_ws.is_active { | 527 | if is_active && !ipc_ws.is_active { |
| 528 | events.push(Event::WorkspaceActivated { id, focused: false }); | 528 | events.push(Event::WorkspaceActivated { id, focused: false }); |
| 529 | } | 529 | } |
| @@ -546,7 +546,7 @@ impl State { | |||
| 546 | idx: u8::try_from(ws_idx + 1).unwrap_or(u8::MAX), | 546 | idx: u8::try_from(ws_idx + 1).unwrap_or(u8::MAX), |
| 547 | name: ws.name().cloned(), | 547 | name: ws.name().cloned(), |
| 548 | output: mon.map(|mon| mon.output_name().clone()), | 548 | output: mon.map(|mon| mon.output_name().clone()), |
| 549 | - is_active: mon.map_or(false, |mon| mon.active_workspace_idx() == ws_idx), | 549 | + is_active: mon.is_some_and(|mon| mon.active_workspace_idx() == ws_idx), |
| 550 | is_focused: Some(id) == focused_ws_id, | 550 | is_focused: Some(id) == focused_ws_id, |
| 551 | active_window_id: ws.active_window().map(|win| win.id().get()), | 551 | active_window_id: ws.active_window().map(|win| win.id().get()), |
| 552 | } | 552 | } |
src/layout/mod.rsmodified+8 -8
| @@ -1194,7 +1194,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 1194 | mon.workspaces.iter().enumerate().find(|(_, w)| { | 1194 | mon.workspaces.iter().enumerate().find(|(_, w)| { |
| 1195 | w.name | 1195 | w.name |
| 1196 | .as_ref() | 1196 | .as_ref() |
| 1197 | - .map_or(false, |name| name.eq_ignore_ascii_case(workspace_name)) | 1197 | + .is_some_and(|name| name.eq_ignore_ascii_case(workspace_name)) |
| 1198 | }) | 1198 | }) |
| 1199 | { | 1199 | { |
| 1200 | return Some((index, workspace)); | 1200 | return Some((index, workspace)); |
| @@ -1205,7 +1205,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 1205 | if let Some((index, workspace)) = workspaces.iter().enumerate().find(|(_, w)| { | 1205 | if let Some((index, workspace)) = workspaces.iter().enumerate().find(|(_, w)| { |
| 1206 | w.name | 1206 | w.name |
| 1207 | .as_ref() | 1207 | .as_ref() |
| 1208 | - .map_or(false, |name| name.eq_ignore_ascii_case(workspace_name)) | 1208 | + .is_some_and(|name| name.eq_ignore_ascii_case(workspace_name)) |
| 1209 | }) { | 1209 | }) { |
| 1210 | return Some((index, workspace)); | 1210 | return Some((index, workspace)); |
| 1211 | } | 1211 | } |
| @@ -1229,7 +1229,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 1229 | WorkspaceReference::Name(ref_name) => ws | 1229 | WorkspaceReference::Name(ref_name) => ws |
| 1230 | .name | 1230 | .name |
| 1231 | .as_ref() | 1231 | .as_ref() |
| 1232 | - .map_or(false, |name| name.eq_ignore_ascii_case(ref_name)), | 1232 | + .is_some_and(|name| name.eq_ignore_ascii_case(ref_name)), |
| 1233 | WorkspaceReference::Id(id) => ws.id().get() == *id, | 1233 | WorkspaceReference::Id(id) => ws.id().get() == *id, |
| 1234 | WorkspaceReference::Index(_) => unreachable!(), | 1234 | WorkspaceReference::Index(_) => unreachable!(), |
| 1235 | }) | 1235 | }) |
| @@ -1657,7 +1657,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 1657 | monitor.workspaces.iter().any(|ws| { | 1657 | monitor.workspaces.iter().any(|ws| { |
| 1658 | ws.name | 1658 | ws.name |
| 1659 | .as_ref() | 1659 | .as_ref() |
| 1660 | - .map_or(false, |name| name.eq_ignore_ascii_case(workspace_name)) | 1660 | + .is_some_and(|name| name.eq_ignore_ascii_case(workspace_name)) |
| 1661 | }) | 1661 | }) |
| 1662 | }) | 1662 | }) |
| 1663 | } | 1663 | } |
| @@ -2427,7 +2427,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 2427 | }; | 2427 | }; |
| 2428 | 2428 | ||
| 2429 | for mon in monitors { | 2429 | for mon in monitors { |
| 2430 | - if output.map_or(false, |output| mon.output != *output) { | 2430 | + if output.is_some_and(|output| mon.output != *output) { |
| 2431 | continue; | 2431 | continue; |
| 2432 | } | 2432 | } |
| 2433 | 2433 | ||
| @@ -2510,7 +2510,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 2510 | let Some(InteractiveMoveState::Moving(move_)) = self.interactive_move.take() else { | 2510 | let Some(InteractiveMoveState::Moving(move_)) = self.interactive_move.take() else { |
| 2511 | unreachable!() | 2511 | unreachable!() |
| 2512 | }; | 2512 | }; |
| 2513 | - if output.map_or(false, |out| &move_.output != out) { | 2513 | + if output.is_some_and(|out| &move_.output != out) { |
| 2514 | self.interactive_move = Some(InteractiveMoveState::Moving(move_)); | 2514 | self.interactive_move = Some(InteractiveMoveState::Moving(move_)); |
| 2515 | return; | 2515 | return; |
| 2516 | } | 2516 | } |
| @@ -4980,7 +4980,7 @@ mod tests { | |||
| 4980 | if ws | 4980 | if ws |
| 4981 | .name | 4981 | .name |
| 4982 | .as_ref() | 4982 | .as_ref() |
| 4983 | - .map_or(false, |name| name.eq_ignore_ascii_case(&ws_name)) | 4983 | + .is_some_and(|name| name.eq_ignore_ascii_case(&ws_name)) |
| 4984 | { | 4984 | { |
| 4985 | ws_id = Some(ws.id()); | 4985 | ws_id = Some(ws.id()); |
| 4986 | } | 4986 | } |
| @@ -4998,7 +4998,7 @@ mod tests { | |||
| 4998 | if ws | 4998 | if ws |
| 4999 | .name | 4999 | .name |
| 5000 | .as_ref() | 5000 | .as_ref() |
| 5001 | - .map_or(false, |name| name.eq_ignore_ascii_case(&ws_name)) | 5001 | + .is_some_and(|name| name.eq_ignore_ascii_case(&ws_name)) |
| 5002 | { | 5002 | { |
| 5003 | ws_id = Some(ws.id()); | 5003 | ws_id = Some(ws.id()); |
| 5004 | } | 5004 | } |
src/layout/monitor.rsmodified+3 -3
| @@ -165,7 +165,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 165 | self.workspaces.iter().find(|ws| { | 165 | self.workspaces.iter().find(|ws| { |
| 166 | ws.name | 166 | ws.name |
| 167 | .as_ref() | 167 | .as_ref() |
| 168 | - .map_or(false, |name| name.eq_ignore_ascii_case(workspace_name)) | 168 | + .is_some_and(|name| name.eq_ignore_ascii_case(workspace_name)) |
| 169 | }) | 169 | }) |
| 170 | } | 170 | } |
| 171 | 171 | ||
| @@ -173,7 +173,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 173 | self.workspaces.iter().position(|ws| { | 173 | self.workspaces.iter().position(|ws| { |
| 174 | ws.name | 174 | ws.name |
| 175 | .as_ref() | 175 | .as_ref() |
| 176 | - .map_or(false, |name| name.eq_ignore_ascii_case(workspace_name)) | 176 | + .is_some_and(|name| name.eq_ignore_ascii_case(workspace_name)) |
| 177 | }) | 177 | }) |
| 178 | } | 178 | } |
| 179 | 179 | ||
| @@ -1074,7 +1074,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 1074 | return false; | 1074 | return false; |
| 1075 | }; | 1075 | }; |
| 1076 | 1076 | ||
| 1077 | - if is_touchpad.map_or(false, |x| gesture.is_touchpad != x) { | 1077 | + if is_touchpad.is_some_and(|x| gesture.is_touchpad != x) { |
| 1078 | return false; | 1078 | return false; |
| 1079 | } | 1079 | } |
| 1080 | 1080 | ||
src/layout/scrolling.rsmodified+2 -2
| @@ -2469,7 +2469,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 2469 | return false; | 2469 | return false; |
| 2470 | }; | 2470 | }; |
| 2471 | 2471 | ||
| 2472 | - if is_touchpad.map_or(false, |x| gesture.is_touchpad != x) { | 2472 | + if is_touchpad.is_some_and(|x| gesture.is_touchpad != x) { |
| 2473 | return false; | 2473 | return false; |
| 2474 | } | 2474 | } |
| 2475 | 2475 | ||
| @@ -3034,7 +3034,7 @@ impl TileData { | |||
| 3034 | self.interactively_resizing_by_left_edge = tile | 3034 | self.interactively_resizing_by_left_edge = tile |
| 3035 | .window() | 3035 | .window() |
| 3036 | .interactive_resize_data() | 3036 | .interactive_resize_data() |
| 3037 | - .map_or(false, |data| data.edges.contains(ResizeEdge::LEFT)); | 3037 | + .is_some_and(|data| data.edges.contains(ResizeEdge::LEFT)); |
| 3038 | } | 3038 | } |
| 3039 | } | 3039 | } |
| 3040 | 3040 | ||
src/niri.rsmodified+1 -1
| @@ -3556,7 +3556,7 @@ impl Niri { | |||
| 3556 | .borrow() | 3556 | .borrow() |
| 3557 | .outputs | 3557 | .outputs |
| 3558 | .find(name) | 3558 | .find(name) |
| 3559 | - .map_or(false, |output| output.is_vrr_on_demand()); | 3559 | + .is_some_and(|output| output.is_vrr_on_demand()); |
| 3560 | if !on_demand { | 3560 | if !on_demand { |
| 3561 | return; | 3561 | return; |
| 3562 | } | 3562 | } |