pr 02
This commit is contained in:
@@ -6,3 +6,20 @@ pub struct Span {
|
||||
pub start: u32, // byte offset
|
||||
pub end: u32, // byte offset, exclusive
|
||||
}
|
||||
|
||||
impl Span {
|
||||
#[inline]
|
||||
pub fn new(file: FileId, start: u32, end: u32) -> Self {
|
||||
Self { file, start, end }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn len(&self) -> u32 {
|
||||
self.end.saturating_sub(self.start)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn contains(&self, byte: u32) -> bool {
|
||||
self.start <= byte && byte < self.end
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user