From fad0e76ad2e19d5cac13cf8324338aca0d623d93 Mon Sep 17 00:00:00 2001 From: Gavrilikhin Daniil Date: Sun, 4 Feb 2024 06:38:00 +0300 Subject: [PATCH] feat(source): use `usize` for length (#265) BREAKING CHANGE: This changes `SourceSpan`'s length type to `usize`. --- src/protocol.rs | 8 ++++---- tests/derive.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/protocol.rs b/src/protocol.rs index 4a6012c..b403494 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -526,10 +526,10 @@ pub struct SourceSpan { impl SourceSpan { /// Create a new [`SourceSpan`]. - pub const fn new(start: SourceOffset, length: SourceOffset) -> Self { + pub const fn new(start: SourceOffset, length: usize) -> Self { Self { offset: start, - length: length.offset(), + length, } } @@ -559,8 +559,8 @@ impl From<(ByteOffset, usize)> for SourceSpan { } } -impl From<(SourceOffset, SourceOffset)> for SourceSpan { - fn from((start, len): (SourceOffset, SourceOffset)) -> Self { +impl From<(SourceOffset, usize)> for SourceSpan { + fn from((start, len): (SourceOffset, usize)) -> Self { Self::new(start, len) } } diff --git a/tests/derive.rs b/tests/derive.rs index d1da1bb..ac29eee 100644 --- a/tests/derive.rs +++ b/tests/derive.rs @@ -406,7 +406,7 @@ impl ForwardsTo { fn new() -> Self { ForwardsTo { src: SNIPPET_TEXT.into(), - label: SourceSpan::new(11.into(), 6.into()), + label: SourceSpan::new(11.into(), 6), } } }