use std::ops::Range;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct Span {
pub start: usize,
pub end: usize,
}
impl Span {
pub fn new(start: usize, end: usize) -> Self {
Self { start, end }
}
pub fn dummy() -> Self {
Self { start: 0, end: 0 }
}
pub fn join(self, other: Self) -> Self {
Self {
start: self.start.min(other.start),
end: self.end.max(other.end),
}
}
}
impl From<Span> for Range<usize> {
fn from(s: Span) -> Self {
s.start..s.end
}
}
impl From<Range<usize>> for Span {
fn from(r: Range<usize>) -> Self {
Self {
start: r.start,
end: r.end,
}
}
}