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
#[derive(Debug, Clone, Default)]
pub struct TxtPos<'a> {
  pub txt_li: Vec<&'a str>,
  pub pos_li: Vec<usize>,
}

impl<'a> TxtPos<'a> {
  pub fn with_capacity(capacity: usize) -> Self {
    Self {
      txt_li: Vec::with_capacity(capacity),
      pos_li: Vec::with_capacity(capacity),
    }
  }

  pub fn push(&mut self, txt: &'a str) {
    if !txt.is_empty() {
      self.txt_li.push(txt);
    }
  }

  pub fn push_pos(&mut self, txt: &'a str) {
    if !txt.is_empty() {
      self.pos_li.push(self.txt_li.len());
      self.txt_li.push(txt);
    }
  }

  pub fn push_trim(&mut self, txt: &'a str) {
    crate::trim::push(txt, &mut self.txt_li, &mut self.pos_li);
  }

  pub fn push_trim_line(&mut self, txt: &'a str) {
    crate::trim::push_line(txt, &mut self.txt_li, &mut self.pos_li);
  }
}