diff --git a/src/protocol.rs b/src/protocol.rs index 23a7af8..be4880b 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -252,6 +252,26 @@ impl> From<(T, ByteOffset, ByteOffset)> for SourceSpan { } } +impl From<(SourceOffset, SourceOffset)> for SourceSpan { + fn from((start, len): (SourceOffset, SourceOffset)) -> Self { + Self { + label: None, + offset: start, + length: len, + } + } +} + +impl> From<(T, SourceOffset, SourceOffset)> for SourceSpan { + fn from((label, start, len): (T, SourceOffset, SourceOffset)) -> Self { + Self { + label: Some(label.as_ref().into()), + offset: start, + length: len, + } + } +} + /** "Raw" type for the byte offset from the beginning of a [Source]. */