chore: clippy

This commit is contained in:
Edward Langley
2026-04-07 00:16:25 -07:00
parent 386b9f6b27
commit 6f3af34056
3 changed files with 9 additions and 14 deletions

View File

@ -263,10 +263,6 @@ impl Model {
self.data.get(key).cloned()
}
/// Evaluate a key as a numeric value, returning 0.0 for empty/non-numeric cells.
pub fn evaluate_f64(&self, key: &CellKey) -> f64 {
self.evaluate(key).and_then(|v| v.as_f64()).unwrap_or(0.0)
}
/// Evaluate a cell, aggregating over any hidden (None-axis) categories.
/// When `none_cats` is empty, delegates to `evaluate`.

View File

@ -82,7 +82,7 @@ impl<'a> GridWidget<'a> {
.map(|s| s.width() as u16)
.max()
.unwrap_or(0);
(max_label + 1).max(MIN_ROW_HEADER_W).min(MAX_ROW_HEADER_W)
(max_label + 1).clamp(MIN_ROW_HEADER_W, MAX_ROW_HEADER_W)
})
.collect();
let row_header_width: u16 = sub_widths.iter().sum();
@ -587,7 +587,7 @@ pub fn compute_col_widths(
}
widths
.into_iter()
.map(|w| (w + 1).max(MIN_COL_WIDTH).min(MAX_COL_WIDTH))
.map(|w| (w + 1).clamp(MIN_COL_WIDTH, MAX_COL_WIDTH))
.collect()
}
@ -613,7 +613,7 @@ pub fn compute_row_header_width(layout: &GridLayout) -> u16 {
.map(|s| s.width() as u16)
.max()
.unwrap_or(0);
(max_label + 1).max(MIN_ROW_HEADER_W).min(MAX_ROW_HEADER_W)
(max_label + 1).clamp(MIN_ROW_HEADER_W, MAX_ROW_HEADER_W)
})
.collect();
sub_widths.iter().sum()
@ -632,8 +632,8 @@ pub fn compute_visible_cols(
.saturating_sub(row_header_width);
let mut acc = 0u16;
let mut count = 0usize;
for ci in col_offset..col_widths.len() {
let w = col_widths[ci];
for w in &col_widths[col_offset..] {
let w = *w;
if acc + w > data_area_width {
break;
}

View File

@ -227,9 +227,9 @@ impl GridLayout {
// Build a row×col grid of "has content?"
let mut has_value = vec![vec![false; cc]; rc];
for ri in 0..rc {
for ci in 0..cc {
has_value[ri][ci] = self
for (ri, row) in has_value.iter_mut().enumerate() {
for (ci, cell) in row.iter_mut().enumerate() {
*cell = self
.cell_key(ri, ci)
.and_then(|k| model.evaluate_aggregated(&k, &self.none_cats))
.is_some();
@ -395,8 +395,7 @@ impl GridLayout {
/// page-axis filter. Returns None if row or col is out of bounds.
/// In records mode: returns a synthetic `(_Index, _Dim)` key for every column.
pub fn cell_key(&self, row: usize, col: usize) -> Option<CellKey> {
if self.records.is_some() {
let records = self.records.as_ref().unwrap();
if let Some(records) = &self.records {
if row >= records.len() {
return None;
}