MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / total_lines

Method total_lines

atomic-core/src/diff/display.rs:315–328  ·  view source on GitHub ↗

Get the total number of lines that will be yielded. This equals: unchanged + removed + added

(&self)

Source from the content-addressed store, hash-verified

313 ///
314 /// This equals: unchanged + removed + added
315 pub fn total_lines(&self) -> usize {
316 let mut count = 0;
317 for op in self.diff_result.iter() {
318 match op {
319 DiffOp::Equal { len, .. } => count += len,
320 DiffOp::Insert { len, .. } => count += len,
321 DiffOp::Delete { len, .. } => count += len,
322 DiffOp::Replace {
323 old_len, new_len, ..
324 } => count += old_len + new_len,
325 }
326 }
327 count
328 }
329}
330
331/// Iterator over lines in a unified diff.

Callers 1

test_total_linesFunction · 0.45

Calls 1

iterMethod · 0.45

Tested by 1

test_total_linesFunction · 0.36