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

Function diff_text

atomic-core/src/diff/mod.rs:544–548  ·  view source on GitHub ↗

Diff two byte slices as text, splitting on newlines. This is a convenience function that handles the common case of diffing two text files. It splits both inputs on newlines, diffs the resulting lines, and returns the operations. # Arguments `old` - The original text content `new` - The modified text content `algorithm` - Which diff algorithm to use # Returns A [`DiffResult`] containing the d

(old: &[u8], new: &[u8], algorithm: Algorithm)

Source from the content-addressed store, hash-verified

542/// assert!(!result.is_empty());
543/// ```
544pub fn diff_text(old: &[u8], new: &[u8], algorithm: Algorithm) -> DiffResult {
545 let old_lines: Vec<Line> = Line::from_bytes(old);
546 let new_lines: Vec<Line> = Line::from_bytes(new);
547 diff(&old_lines, &new_lines, algorithm)
548}
549
550/// Diff two byte slices as text using a custom separator pattern.
551///

Callers 13

runMethod · 0.85
analyzeMethod · 0.85
test_diff_identicalFunction · 0.85
test_diff_emptyFunction · 0.85
test_diff_insertFunction · 0.85
test_diff_deleteFunction · 0.85
test_diff_replaceFunction · 0.85

Calls 1

diffFunction · 0.70

Tested by 10

test_diff_identicalFunction · 0.68
test_diff_emptyFunction · 0.68
test_diff_insertFunction · 0.68
test_diff_deleteFunction · 0.68
test_diff_replaceFunction · 0.68