tattle 0.2.0

Error reporting for compilers
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct Loc {
    pub start: usize,
    pub end: usize,
    pub file: Option<usize>,
}

impl Loc {
    pub fn new(start: usize, end: usize, file: Option<usize>) -> Self {
        assert!(start <= end);
        Self { start, end, file }
    }

    pub fn slice<'a>(&self, source: &'a str) -> &'a str {
        &source[self.start..self.end]
    }
}