chore: clippy
This commit is contained in:
@ -263,10 +263,6 @@ impl Model {
|
|||||||
self.data.get(key).cloned()
|
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.
|
/// Evaluate a cell, aggregating over any hidden (None-axis) categories.
|
||||||
/// When `none_cats` is empty, delegates to `evaluate`.
|
/// When `none_cats` is empty, delegates to `evaluate`.
|
||||||
|
|||||||
@ -82,7 +82,7 @@ impl<'a> GridWidget<'a> {
|
|||||||
.map(|s| s.width() as u16)
|
.map(|s| s.width() as u16)
|
||||||
.max()
|
.max()
|
||||||
.unwrap_or(0);
|
.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();
|
.collect();
|
||||||
let row_header_width: u16 = sub_widths.iter().sum();
|
let row_header_width: u16 = sub_widths.iter().sum();
|
||||||
@ -587,7 +587,7 @@ pub fn compute_col_widths(
|
|||||||
}
|
}
|
||||||
widths
|
widths
|
||||||
.into_iter()
|
.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()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,7 +613,7 @@ pub fn compute_row_header_width(layout: &GridLayout) -> u16 {
|
|||||||
.map(|s| s.width() as u16)
|
.map(|s| s.width() as u16)
|
||||||
.max()
|
.max()
|
||||||
.unwrap_or(0);
|
.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();
|
.collect();
|
||||||
sub_widths.iter().sum()
|
sub_widths.iter().sum()
|
||||||
@ -632,8 +632,8 @@ pub fn compute_visible_cols(
|
|||||||
.saturating_sub(row_header_width);
|
.saturating_sub(row_header_width);
|
||||||
let mut acc = 0u16;
|
let mut acc = 0u16;
|
||||||
let mut count = 0usize;
|
let mut count = 0usize;
|
||||||
for ci in col_offset..col_widths.len() {
|
for w in &col_widths[col_offset..] {
|
||||||
let w = col_widths[ci];
|
let w = *w;
|
||||||
if acc + w > data_area_width {
|
if acc + w > data_area_width {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -227,9 +227,9 @@ impl GridLayout {
|
|||||||
|
|
||||||
// Build a row×col grid of "has content?"
|
// Build a row×col grid of "has content?"
|
||||||
let mut has_value = vec![vec![false; cc]; rc];
|
let mut has_value = vec![vec![false; cc]; rc];
|
||||||
for ri in 0..rc {
|
for (ri, row) in has_value.iter_mut().enumerate() {
|
||||||
for ci in 0..cc {
|
for (ci, cell) in row.iter_mut().enumerate() {
|
||||||
has_value[ri][ci] = self
|
*cell = self
|
||||||
.cell_key(ri, ci)
|
.cell_key(ri, ci)
|
||||||
.and_then(|k| model.evaluate_aggregated(&k, &self.none_cats))
|
.and_then(|k| model.evaluate_aggregated(&k, &self.none_cats))
|
||||||
.is_some();
|
.is_some();
|
||||||
@ -395,8 +395,7 @@ impl GridLayout {
|
|||||||
/// page-axis filter. Returns None if row or col is out of bounds.
|
/// 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.
|
/// In records mode: returns a synthetic `(_Index, _Dim)` key for every column.
|
||||||
pub fn cell_key(&self, row: usize, col: usize) -> Option<CellKey> {
|
pub fn cell_key(&self, row: usize, col: usize) -> Option<CellKey> {
|
||||||
if self.records.is_some() {
|
if let Some(records) = &self.records {
|
||||||
let records = self.records.as_ref().unwrap();
|
|
||||||
if row >= records.len() {
|
if row >= records.len() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user