Skip to content

Commit fad0e76

Browse files
authoredFeb 4, 2024··
feat(source): use usize for length (#265)
BREAKING CHANGE: This changes `SourceSpan`'s length type to `usize`.
1 parent 0d5c2ce commit fad0e76

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed
 

‎src/protocol.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,10 @@ pub struct SourceSpan {
526526

527527
impl SourceSpan {
528528
/// Create a new [`SourceSpan`].
529-
pub const fn new(start: SourceOffset, length: SourceOffset) -> Self {
529+
pub const fn new(start: SourceOffset, length: usize) -> Self {
530530
Self {
531531
offset: start,
532-
length: length.offset(),
532+
length,
533533
}
534534
}
535535

@@ -559,8 +559,8 @@ impl From<(ByteOffset, usize)> for SourceSpan {
559559
}
560560
}
561561

562-
impl From<(SourceOffset, SourceOffset)> for SourceSpan {
563-
fn from((start, len): (SourceOffset, SourceOffset)) -> Self {
562+
impl From<(SourceOffset, usize)> for SourceSpan {
563+
fn from((start, len): (SourceOffset, usize)) -> Self {
564564
Self::new(start, len)
565565
}
566566
}

‎tests/derive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ impl ForwardsTo {
406406
fn new() -> Self {
407407
ForwardsTo {
408408
src: SNIPPET_TEXT.into(),
409-
label: SourceSpan::new(11.into(), 6.into()),
409+
label: SourceSpan::new(11.into(), 6),
410410
}
411411
}
412412
}

0 commit comments

Comments
 (0)
Please sign in to comment.