#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct Span {
pub start: u32,
pub end: u32,
}
impl Span {
#[inline]
pub const fn new(start: u32, end: u32) -> Self {
Self { start, end }
}
#[inline]
pub const fn len(&self) -> u32 {
self.end.saturating_sub(self.start)
}
#[inline]
pub const fn is_empty(&self) -> bool {
self.start >= self.end
}
#[inline]
pub const fn contains(&self, offset: u32) -> bool {
offset >= self.start && offset < self.end
}
#[inline]
pub fn merge(self, other: Span) -> Span {
Span {
start: self.start.min(other.start),
end: self.end.max(other.end),
}
}
}