From 0169fe20e7868cfee594b26b063267d17be0a84e Mon Sep 17 00:00:00 2001 From: Coenen Benjamin Date: Fri, 1 Oct 2021 21:02:39 +0200 Subject: [PATCH] feat(SourceSpan): add impl From (#78) Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- src/protocol.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/protocol.rs b/src/protocol.rs index 0358bec..ae2f014 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -397,6 +397,15 @@ impl From<(SourceOffset, SourceOffset)> for SourceSpan { } } +impl From> for SourceSpan { + fn from(range: std::ops::Range) -> Self { + Self { + offset: range.start.into(), + length: range.len().into(), + } + } +} + /** "Raw" type for the byte offset from the beginning of a [SourceCode]. */