pub fn diff_file<'a>(
left: &'a Vec<u8>,
right: &'a Vec<u8>,
settings: &'a Settings
) -> Vec<Batch<'a>>
Expand description
Calculates the difference between two byte vectors.
Finds differences between the two vectors and returns them with some context. Groups this information into lines
.
§Arguments
left
: The first vector to compare.right
: The second vector to compare.settings
: Additional parameters such as line length, lines to include before and after each difference (for context) and how to align bytes.
§Returns
A vector of batches, each corresponding to one or more adjacent changes.
§Example
let left = vec![1,2,3,4,5];
let right = vec![1,2,8,4,5];
let result = diff_file(&left, &right, &DEFAULT_SETTINGS);
assert_eq!(result[0].lines[0].content, vec![
(&1, Both),
(&2, Both),
(&3, Left),
(&8, Right),
(&4, Both),
(&5, Both)
]);