moxy_token/source/location.rs
1/// 0 indexed char based location
2/// A byte, line, and column location within a source file.
3#[derive(Debug, Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
4pub struct Location {
5 index: usize,
6 line: usize,
7 column: usize,
8}
9
10impl Location {
11 pub const fn new(index: usize, line: usize, column: usize) -> Self {
12 Self { index, line, column }
13 }
14
15 pub const fn index(&self) -> usize {
16 self.index
17 }
18
19 pub const fn line(&self) -> usize {
20 self.line
21 }
22
23 pub const fn column(&self) -> usize {
24 self.column
25 }
26}