redbear-power: fix clippy warnings in affinity.rs
Collapse nested if, replace map_or(false,...) with is_some_and, use div_ceil instead of manual ceiling division.
This commit is contained in:
@@ -114,10 +114,10 @@ impl AffinityEditor {
|
||||
}
|
||||
|
||||
pub fn should_auto_close(&self) -> bool {
|
||||
if let Some(at) = self.result_at {
|
||||
if self.result.as_ref().map_or(false, |r| r.is_ok()) {
|
||||
return at.elapsed().as_secs() >= 2;
|
||||
}
|
||||
if let Some(at) = self.result_at
|
||||
&& self.result.as_ref().is_some_and(|r| r.is_ok())
|
||||
{
|
||||
return at.elapsed().as_secs() >= 2;
|
||||
}
|
||||
false
|
||||
}
|
||||
@@ -127,7 +127,7 @@ impl Widget for &mut AffinityEditor {
|
||||
fn render(self, area: Rect, buf: &mut ratatui::buffer::Buffer) {
|
||||
Clear.render(area, buf);
|
||||
let cols = self.grid_cols();
|
||||
let rows = (self.num_cpus + cols - 1) / cols;
|
||||
let rows = self.num_cpus.div_ceil(cols);
|
||||
let dialog_h = (rows + 7).min(24) as u16;
|
||||
let dialog_w = ((cols * 6) + 4).min(80) as u16;
|
||||
let dx = area.x + (area.width.saturating_sub(dialog_w)) / 2;
|
||||
|
||||
Reference in New Issue
Block a user