Split content into lines, preserving line endings. Returns slices into the original content.
(content: &[u8])
| 1185 | /// Split content into lines, preserving line endings. |
| 1186 | /// Returns slices into the original content. |
| 1187 | fn split_content_lines(content: &[u8]) -> Vec<&[u8]> { |
| 1188 | if content.is_empty() { |
| 1189 | return Vec::new(); |
| 1190 | } |
| 1191 | let mut lines = Vec::new(); |
| 1192 | let mut start = 0; |
| 1193 | for (i, &byte) in content.iter().enumerate() { |
| 1194 | if byte == b'\n' { |
| 1195 | lines.push(&content[start..=i]); |
| 1196 | start = i + 1; |
| 1197 | } |
| 1198 | } |
| 1199 | if start < content.len() { |
| 1200 | lines.push(&content[start..]); |
| 1201 | } |
| 1202 | lines |
| 1203 | } |
| 1204 | |
| 1205 | /// Calculate byte offsets for each line in content. |
| 1206 | /// |
no test coverage detected