Skip to content

Commit

Permalink
feat(SourceSpan): add impl From<Range> (#78)
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
  • Loading branch information
bnjjj committed Oct 1, 2021
1 parent 50e8219 commit 0169fe2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/protocol.rs
Expand Up @@ -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].
*/
Expand Down

0 comments on commit 0169fe2

Please sign in to comment.