lib_tsshow 2.1.0

A visualiser for template-switch alignments
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
pub struct IndexedStr<'a> {
    index: Vec<usize>,
    string: &'a str,
}

impl<'a> IndexedStr<'a> {
    pub fn new(string: &'a str) -> Self {
        let index = string.char_indices().map(|(index, _)| index).collect();

        Self { index, string }
    }

    pub fn char_at(&self, index: usize) -> char {
        self.string[self.index[index]..].chars().next().unwrap()
    }
}