Given a string `source`, establish the line number and column number that this span would reside in.
(self, source: &'_ str)
| 69 | |
| 70 | /// Given a string `source`, establish the line number and column number that this span would reside in. |
| 71 | pub fn line_and_column(self, source: &'_ str) -> (u32, u32) { |
| 72 | let mut line = 0; |
| 73 | let mut column = 0; |
| 74 | let mut offset = self.start.0; |
| 75 | for char in source.chars() { |
| 76 | if offset == 0 { |
| 77 | break; |
| 78 | } |
| 79 | if char == '\n' { |
| 80 | column = 0; |
| 81 | line += 1; |
| 82 | } else { |
| 83 | column += 1; |
| 84 | } |
| 85 | offset -= char.len_utf8() as u32; |
| 86 | } |
| 87 | (line, column) |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | /// Extends this [Span], ensuring that the resulting new [Span] is broader than both this and the given [Span]. |
no outgoing calls
no test coverage detected