feat(SourceSpan): add impl From<Range> (#78)

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This commit is contained in:
Coenen Benjamin 2021-10-01 21:02:39 +02:00 committed by GitHub
parent 50e82199e6
commit 0169fe20e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

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