ebnf_parser/
span.rs

1use std::fmt::{Debug, Display};
2
3#[derive(Clone, Copy, PartialEq, Eq)]
4pub struct Span {
5    pub start: usize,
6    pub end: usize,
7}
8
9impl Span {
10    pub(crate) fn new(start: usize, end: usize) -> Self {
11        Self { start, end }
12    }
13}
14
15impl Display for Span {
16    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17        write!(f, "{}..{}", self.start, self.end)
18    }
19}
20
21impl Debug for Span {
22    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23        write!(f, "{}", self)
24    }
25}