1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use crate::{bounds_to_usize, TableOption};
use papergrid::Grid;
use std::ops::RangeBounds;
#[derive(Debug)]
pub enum Disable<R: RangeBounds<usize>> {
Column(R),
Row(R),
}
impl<R: RangeBounds<usize>> TableOption for Disable<R> {
fn change(&self, grid: &mut Grid) {
match self {
Self::Column(range) => {
let (x, y) =
bounds_to_usize(range.start_bound(), range.end_bound(), grid.count_columns());
for (shifted, i) in (x..y).enumerate() {
grid.remove_column(i - shifted);
}
}
Self::Row(range) => {
let (x, y) =
bounds_to_usize(range.start_bound(), range.end_bound(), grid.count_rows());
for (shifted, i) in (x..y).enumerate() {
grid.remove_row(i - shifted);
}
}
}
}
}