Skip to content

Commit

Permalink
feat(spans): add From shorthand for zero-length SourceSpans
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Apr 23, 2022
1 parent e6f5cac commit 1e1d615
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
*/
Expand Down

0 comments on commit 1e1d615

Please sign in to comment.