pub fn patience_diff<'a, T>(a: &'a [T], b: &'a [T]) -> Vec<DiffComponent<&'a T>>
Expand description
Computes the patience diff betwen a
and b
. The DiffComponent
s hold references to the
elements in a
and b
they correspond to.
use patience_diff::DiffComponent;
let a: Vec<_> = "AaaxZ".chars().collect();
let b: Vec<_> = "AxaaZ".chars().collect();
let diff = patience_diff::patience_diff(&a, &b);
assert_eq!(diff, vec![
DiffComponent::Unchanged(&'A', &'A'),
DiffComponent::Deletion(&'a'),
DiffComponent::Deletion(&'a'),
DiffComponent::Unchanged(&'x', &'x'),
DiffComponent::Insertion(&'a'),
DiffComponent::Insertion(&'a'),
DiffComponent::Unchanged(&'Z', &'Z')
]);