Skip to content

Commit

Permalink
properly use safe-string's lines() method now that is available
Browse files Browse the repository at this point in the history
  • Loading branch information
sam0x17 committed Jun 21, 2024
1 parent 352cbcf commit a02709e
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,17 @@ impl Span {
}

/// Returns an iterator over the lines of the [`Source`] that this [`Span`] is associated with,
pub fn source_lines(&self) -> impl Iterator<Item = (IndexedString, Range<usize>)> + '_ {
// TODO: re-write entirely using `IndexedString` and `IndexedSlice`
pub fn source_lines(&self) -> impl Iterator<Item = (IndexedSlice, Range<usize>)> + '_ {
let start_line_col = self.start();
let end_line_col = self.end();
let start_col = start_line_col.col;
let start_line = start_line_col.line;
let end_line = end_line_col.line;
let end_col = end_line_col.col;
self.source
.as_str()
.lines()
.enumerate()
.filter_map(move |(i, line)| {
let line = IndexedString::from(line);
let len = line.len();
if start_line == end_line && end_line == i {
Some((line, start_col..end_col))
Expand Down

0 comments on commit a02709e

Please sign in to comment.