feat(spans): add From shorthand for zero-length SourceSpans

This commit is contained in:
Kat Marchán 2022-04-22 16:48:48 -07:00
parent e6f5cacfa6
commit 5930d0e000
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
1 changed files with 18 additions and 0 deletions

View File

@ -406,6 +406,24 @@ impl From<std::ops::Range<ByteOffset>> for SourceSpan {
}
}
impl From<SourceOffset> for SourceSpan {
fn from(offset: SourceOffset) -> Self {
Self {
offset,
length: 0.into(),
}
}
}
impl From<ByteOffset> for SourceSpan {
fn from(offset: ByteOffset) -> Self {
Self {
offset: offset.into(),
length: 0.into(),
}
}
}
/**
"Raw" type for the byte offset from the beginning of a [`SourceCode`].
*/