Skip to content

Commit

Permalink
feat(source): use usize for length (#265)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This changes `SourceSpan`'s length type to `usize`.
  • Loading branch information
gavrilikhin-d committed Feb 4, 2024
1 parent 0d5c2ce commit fad0e76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
}
Expand Down

0 comments on commit fad0e76

Please sign in to comment.