Read the next line, applying replacements and removing line terminators.
(&mut self, line: &mut String)
| 1183 | |
| 1184 | /// Read the next line, applying replacements and removing line terminators. |
| 1185 | fn read_line(&mut self, line: &mut String) -> Option<Result<()>> { |
| 1186 | match self.reader.read_line(line) { |
| 1187 | Ok(0) => None, |
| 1188 | Ok(_) => { |
| 1189 | self.line_nr += 1; |
| 1190 | |
| 1191 | // Trim newline and carriage return without changing other content. |
| 1192 | let trimmed_len = line.trim_end_matches(['\n', '\r']).len(); |
| 1193 | line.truncate(trimmed_len); |
| 1194 | |
| 1195 | match process_replacements(line, &self.replacements) { |
| 1196 | Ok(l) => { |
| 1197 | *line = l; |
| 1198 | Some(Ok(())) |
| 1199 | } |
| 1200 | Err(error) => Some(Err(error)), |
| 1201 | } |
| 1202 | } |
| 1203 | Err(e) => Some(Err(e.into())), |
| 1204 | } |
| 1205 | } |
| 1206 | |
| 1207 | fn format_exception(&self, msg: &str) -> String { |
| 1208 | format!("{}:{} - {}", self.path.display(), self.line_nr, msg) |
no test coverage detected