feat(source): use `usize` for length (#265)

BREAKING CHANGE: This changes `SourceSpan`'s length type to `usize`.
This commit is contained in:
Gavrilikhin Daniil 2024-02-04 06:38:00 +03:00 committed by GitHub
parent 0d5c2ce753
commit fad0e76ad2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -526,10 +526,10 @@ pub struct SourceSpan {
impl SourceSpan { impl SourceSpan {
/// Create a new [`SourceSpan`]. /// Create a new [`SourceSpan`].
pub const fn new(start: SourceOffset, length: SourceOffset) -> Self { pub const fn new(start: SourceOffset, length: usize) -> Self {
Self { Self {
offset: start, offset: start,
length: length.offset(), length,
} }
} }
@ -559,8 +559,8 @@ impl From<(ByteOffset, usize)> for SourceSpan {
} }
} }
impl From<(SourceOffset, SourceOffset)> for SourceSpan { impl From<(SourceOffset, usize)> for SourceSpan {
fn from((start, len): (SourceOffset, SourceOffset)) -> Self { fn from((start, len): (SourceOffset, usize)) -> Self {
Self::new(start, len) Self::new(start, len)
} }
} }

View File

@ -406,7 +406,7 @@ impl ForwardsTo {
fn new() -> Self { fn new() -> Self {
ForwardsTo { ForwardsTo {
src: SNIPPET_TEXT.into(), src: SNIPPET_TEXT.into(),
label: SourceSpan::new(11.into(), 6.into()), label: SourceSpan::new(11.into(), 6),
} }
} }
} }