1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use std::ops::Range;
use super::SourceId;
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Span {
pub start: usize,
pub end: usize,
pub source_id: SourceId,
}
impl Span {
pub fn is_adjacent_to(&self, other: &Self) -> bool {
self.source_id == other.source_id && self.end == other.start
}
pub fn union(&self, other: &Self) -> Span {
Span {
start: self.start,
end: other.end,
source_id: self.source_id,
}
}
}
impl Into<Range<usize>> for Span {
fn into(self) -> Range<usize> {
Range {
start: self.start,
end: self.end,
}
}
}