Skip to main content

openpql_pql_parser/
spanned.rs

1use crate::LocInfo;
2
3/// AST node carrying a source span.
4pub trait Spanned {
5    /// Returns the start and end byte offsets of the node.
6    fn loc(&self) -> LocInfo;
7}
8
9impl Spanned for LocInfo {
10    fn loc(&self) -> LocInfo {
11        *self
12    }
13}
14
15#[cfg(test)]
16mod tests {
17    use super::*;
18
19    #[test]
20    fn test_locinfo_loc() {
21        let li: LocInfo = (3, 7);
22        assert_eq!(li.loc(), (3, 7));
23    }
24}