treewide: apply clippy lints
Browse files
skipped `window_manager.rs`
+3 −5 src/bar/bar.rs
| @@ -158,11 +158,9 @@ impl Bar { | ||
| 158 | 158 | for (i, block) in self.blocks.iter_mut().enumerate() { |
| 159 | 159 | let elapsed = now.duration_since(self.block_last_updates[i]); |
| 160 | 160 | |
| 161 | - if elapsed >= block.interval() { | |
| 162 | - if block.content().is_ok() { | |
| 163 | - self.block_last_updates[i] = now; | |
| 164 | - changed = true; | |
| 165 | - } | |
| 161 | + if elapsed >= block.interval() && block.content().is_ok() { | |
| 162 | + self.block_last_updates[i] = now; | |
| 163 | + changed = true; | |
| 166 | 164 | } |
| 167 | 165 | } |
| 168 | 166 |
+15 −16 src/keyboard/handlers.rs
| @@ -146,10 +146,10 @@ impl KeyboardMapping { | ||
| 146 | 146 | ) -> Option<Keycode> { |
| 147 | 147 | for keycode in min_keycode..=max_keycode { |
| 148 | 148 | let index = (keycode - self.min_keycode) as usize * self.keysyms_per_keycode as usize; |
| 149 | - if let Some(&sym) = self.syms.get(index) { | |
| 150 | - if sym == keysym { | |
| 151 | - return Some(keycode); | |
| 152 | - } | |
| 149 | + if let Some(&sym) = self.syms.get(index) | |
| 150 | + && sym == keysym | |
| 151 | + { | |
| 152 | + return Some(keycode); | |
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | None |
| @@ -218,19 +218,18 @@ pub fn grab_keys( | ||
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - if current_key > 0 { | |
| 222 | - if let Some(escape_keycode) = | |
| 221 | + if current_key > 0 | |
| 222 | + && let Some(escape_keycode) = | |
| 223 | 223 | mapping.find_keycode(keysyms::XK_ESCAPE, min_keycode, max_keycode) |
| 224 | - { | |
| 225 | - connection.grab_key( | |
| 226 | - true, | |
| 227 | - root, | |
| 228 | - ModMask::ANY, | |
| 229 | - escape_keycode, | |
| 230 | - GrabMode::ASYNC, | |
| 231 | - GrabMode::ASYNC, | |
| 232 | - )?; | |
| 233 | - } | |
| 224 | + { | |
| 225 | + connection.grab_key( | |
| 226 | + true, | |
| 227 | + root, | |
| 228 | + ModMask::ANY, | |
| 229 | + escape_keycode, | |
| 230 | + GrabMode::ASYNC, | |
| 231 | + GrabMode::ASYNC, | |
| 232 | + )?; | |
| 234 | 233 | } |
| 235 | 234 | |
| 236 | 235 | connection.flush()?; |
+3 −9 src/layout/tiling.rs
| @@ -54,10 +54,8 @@ impl TilingLayout { | ||
| 54 | 54 | for i in 0..window_count { |
| 55 | 55 | if i < num_master { |
| 56 | 56 | master_total += (master_size as f32 / master_facts) as i32; |
| 57 | - } else { | |
| 58 | - if stack_facts > 0.0 { | |
| 59 | - stack_total += (stack_size as f32 / stack_facts) as i32; | |
| 60 | - } | |
| 57 | + } else if stack_facts > 0.0 { | |
| 58 | + stack_total += (stack_size as f32 / stack_facts) as i32; | |
| 61 | 59 | } |
| 62 | 60 | } |
| 63 | 61 | |
| @@ -108,11 +106,7 @@ impl Layout for TilingLayout { | ||
| 108 | 106 | |
| 109 | 107 | let num_master_usize = num_master.max(0) as usize; |
| 110 | 108 | let master_count = window_count.min(num_master_usize); |
| 111 | - let stack_count = if window_count > num_master_usize { | |
| 112 | - window_count - num_master_usize | |
| 113 | - } else { | |
| 114 | - 0 | |
| 115 | - }; | |
| 109 | + let stack_count = window_count.saturating_sub(num_master_usize); | |
| 116 | 110 | |
| 117 | 111 | let master_height = (screen_height as i32) |
| 118 | 112 | - (2 * outer_gap_horizontal) as i32 |
+3 −3 src/lib.rs
| @@ -43,15 +43,15 @@ impl WindowRule { | ||
| 43 | 43 | let class_matches = self |
| 44 | 44 | .class |
| 45 | 45 | .as_ref() |
| 46 | - .map_or(true, |c| class.contains(c.as_str())); | |
| 46 | + .is_none_or(|c| class.contains(c.as_str())); | |
| 47 | 47 | let instance_matches = self |
| 48 | 48 | .instance |
| 49 | 49 | .as_ref() |
| 50 | - .map_or(true, |i| instance.contains(i.as_str())); | |
| 50 | + .is_none_or(|i| instance.contains(i.as_str())); | |
| 51 | 51 | let title_matches = self |
| 52 | 52 | .title |
| 53 | 53 | .as_ref() |
| 54 | - .map_or(true, |t| title.contains(t.as_str())); | |
| 54 | + .is_none_or(|t| title.contains(t.as_str())); | |
| 55 | 55 | class_matches && instance_matches && title_matches |
| 56 | 56 | } |
| 57 | 57 | } |
+1 −1 src/monitor.rs
| @@ -102,7 +102,7 @@ pub fn detect_monitors( | ||
| 102 | 102 | .xinerama_is_active() |
| 103 | 103 | .ok() |
| 104 | 104 | .and_then(|cookie| cookie.reply().ok()) |
| 105 | - .map_or(false, |reply| reply.state != 0); | |
| 105 | + .is_some_and(|reply| reply.state != 0); | |
| 106 | 106 | |
| 107 | 107 | if xinerama_active { |
| 108 | 108 | let Ok(xinerama_cookie) = connection.xinerama_query_screens() else { |
+6 −6 src/overlay/keybind.rs
| @@ -168,12 +168,12 @@ impl KeybindOverlay { | ||
| 168 | 168 | .filter(|kb| kb.func == action) |
| 169 | 169 | .min_by_key(|kb| kb.keys.len()); |
| 170 | 170 | |
| 171 | - if let Some(binding) = binding { | |
| 172 | - if !binding.keys.is_empty() { | |
| 173 | - let key_str = self.format_key_combo(&binding.keys[0]); | |
| 174 | - let action_str = self.action_description(binding); | |
| 175 | - result.push((key_str, action_str)); | |
| 176 | - } | |
| 171 | + if let Some(binding) = binding | |
| 172 | + && !binding.keys.is_empty() | |
| 173 | + { | |
| 174 | + let key_str = self.format_key_combo(&binding.keys[0]); | |
| 175 | + let action_str = self.action_description(binding); | |
| 176 | + result.push((key_str, action_str)); | |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 |