summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-06 14:23:03 +0100
committertcmal <me@aria.rip>2024-08-06 14:39:50 +0100
commit9865539d1a490ed403e8daff8c670d9a45673468 (patch)
treec2e10e50abe80ad4333c24532fd83a52f5b807b7
parenta441d50fe89b340f21c9a75313442286b952a329 (diff)
Fix some clippy lints
-rw-r--r--src/clients/mod.rs24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/clients/mod.rs b/src/clients/mod.rs
index 597a336..04355fd 100644
--- a/src/clients/mod.rs
+++ b/src/clients/mod.rs
@@ -1,6 +1,6 @@
//! Tracking and managing windows.
-use std::cmp::min;
+use std::cmp::{min, Ordering};
use crate::{
config::BORDER_WIDTH,
@@ -360,17 +360,21 @@ impl ClientState {
/// Set the new amount of screens, without unmanaging any clients.
fn truncate_screens(&mut self, new_size: usize) {
- // hack: working around double borrow stuff
- if new_size < self.mons.len() {
- let mut moved_clients = vec![];
- for old in self.mons.drain(new_size - self.mons.len()..self.mons.len()) {
- moved_clients.extend(old.clients.into_iter());
+ // HACK: working around double borrow stuff
+ match new_size.cmp(&self.mons.len()) {
+ Ordering::Greater => {
+ for _ in 0..new_size - self.mons.len() {
+ self.mons.push(MonitorInfo::default());
+ }
}
- self.mons[0].clients.extend(moved_clients);
- } else if new_size > self.mons.len() {
- for _ in 0..new_size - self.mons.len() {
- self.mons.push(MonitorInfo::default());
+ Ordering::Less => {
+ let mut moved_clients = vec![];
+ for old in self.mons.drain(new_size - self.mons.len()..self.mons.len()) {
+ moved_clients.extend(old.clients.into_iter());
+ }
+ self.mons[0].clients.extend(moved_clients);
}
+ Ordering::Equal => (),
}
}