Skip to main content

mysz_core/utils/
location.rs

1use std::rc::Rc;
2
3#[derive(Clone, Debug)]
4pub struct Location {
5    pub line: usize,
6    pub col: usize,
7    pub file: Rc<str>,
8}
9impl Location {
10    pub fn new_with_file(line: usize, col: usize, file: Rc<str>) -> Self {
11        Self { line, col, file }
12    }
13}
14impl std::fmt::Display for Location {
15    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16        write!(f, "li = {}, co = {}", self.line, self.col)
17    }
18}