tabled/settings/height/
height_list.rs1use std::iter::FromIterator;
2
3use crate::{
4 grid::dimension::CompleteDimension,
5 grid::records::{ExactRecords, Records},
6 settings::TableOption,
7};
8
9#[derive(Debug)]
13pub struct HeightList {
14 list: Vec<usize>,
15}
16
17impl HeightList {
18 pub fn new(list: Vec<usize>) -> Self {
20 Self { list }
21 }
22}
23
24impl From<Vec<usize>> for HeightList {
25 fn from(list: Vec<usize>) -> Self {
26 Self::new(list)
27 }
28}
29
30impl FromIterator<usize> for HeightList {
31 fn from_iter<T: IntoIterator<Item = usize>>(iter: T) -> Self {
32 Self::new(iter.into_iter().collect())
33 }
34}
35
36impl<R, C> TableOption<R, C, CompleteDimension> for HeightList
37where
38 R: ExactRecords + Records,
39{
40 fn change(self, records: &mut R, _: &mut C, dims: &mut CompleteDimension) {
41 if self.list.len() < records.count_rows() {
42 return;
43 }
44
45 dims.set_heights(self.list);
46 }
47
48 fn hint_change(&self) -> Option<papergrid::config::Entity> {
49 None
51 }
52}