From 5930d0e000d7446bea071db71a6b506d4bdf8eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Fri, 22 Apr 2022 16:48:48 -0700 Subject: [PATCH] feat(spans): add From shorthand for zero-length SourceSpans --- src/protocol.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/protocol.rs b/src/protocol.rs index e829f66..2a6545a 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -406,6 +406,24 @@ impl From> for SourceSpan { } } +impl From for SourceSpan { + fn from(offset: SourceOffset) -> Self { + Self { + offset, + length: 0.into(), + } + } +} + +impl From 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`]. */