From 9865539d1a490ed403e8daff8c670d9a45673468 Mon Sep 17 00:00:00 2001 From: tcmal Date: Tue, 6 Aug 2024 14:23:03 +0100 Subject: Fix some clippy lints --- src/clients/mod.rs | 24 ++++++++++++++---------- 1 file 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 => (), } } -- cgit v1.2.3