Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion regex-automata/src/util/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -843,9 +843,20 @@ impl Span {

/// Returns a new span with `offset` added to this span's `start` and `end`
/// values.
///
/// # Panics
///
/// This panics if adding `offset` to either part of this `Span` would
/// result in overflow.
#[inline]
pub fn offset(&self, offset: usize) -> Span {
Span { start: self.start + offset, end: self.end + offset }
Span {
Comment on lines 852 to +853
start: self
.start
.checked_add(offset)
.expect("invalid start+offset"),
end: self.end.checked_add(offset).expect("invalid end+offset"),
}
}
}

Expand Down