Function similar::utils::diff_lines
source ยท pub fn diff_lines<'x, T: DiffableStrRef + ?Sized>(
alg: Algorithm,
old: &'x T,
new: &'x T,
) -> Vec<(ChangeTag, &'x T::Output)>
Expand description
Shortcut for making a line diff.
This function produces the diff of two slices and returns a vector
with the changes. Unlike diff_chars
or diff_slices
it returns a
change tag for each line.
use similar::{Algorithm, ChangeTag};
use similar::utils::diff_lines;
assert_eq!(diff_lines(Algorithm::Myers, "foo\nbar\nbaz\nblah", "foo\nbar\nbaz\nblurgh"), vec![
(ChangeTag::Equal, "foo\n"),
(ChangeTag::Equal, "bar\n"),
(ChangeTag::Equal, "baz\n"),
(ChangeTag::Delete, "blah"),
(ChangeTag::Insert, "blurgh"),
]);