tabled/settings/peaker/
left.rs1use super::Peaker;
2
3#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord, Copy, Hash)]
5pub struct PriorityLeft {
6 i: usize,
7}
8
9impl PriorityLeft {
10 pub const fn new() -> Self {
12 Self { i: 0 }
13 }
14}
15
16impl Peaker for PriorityLeft {
17 fn peak(&mut self, min: &[usize], widths: &[usize]) -> Option<usize> {
18 let col = self.i;
19 if widths[col] > min[col] {
20 return Some(col);
21 }
22
23 if col + 1 == widths.len() {
24 return None;
25 }
26
27 let mut col = col + 1;
28 while widths[col] == min[col] {
29 if col + 1 == widths.len() {
30 return None;
31 }
32
33 col += 1;
34 }
35
36 Some(col)
37 }
38}