pub fn diff_unicode_words<'x, T: DiffableStrRef + ?Sized>(
    alg: Algorithm,
    old: &'x T,
    new: &'x T
) -> Vec<(ChangeTag, &'x T::Output)>
Expand description

Shortcut for making a unicode word level diff.

This function produces the diff of two strings and returns a vector with the changes. It returns connected slices into the original string rather than word level slices.

use similar::{Algorithm, ChangeTag};
use similar::utils::diff_unicode_words;

let old = "The quick (\"brown\") fox can't jump 32.3 feet, right?";
let new = "The quick (\"brown\") fox can't jump 9.84 meters, right?";
assert_eq!(diff_unicode_words(Algorithm::Myers, old, new), vec![
    (ChangeTag::Equal, "The quick (\"brown\") fox can\'t jump "),
    (ChangeTag::Delete, "32.3"),
    (ChangeTag::Insert, "9.84"),
    (ChangeTag::Equal, " "),
    (ChangeTag::Delete, "feet"),
    (ChangeTag::Insert, "meters"),
    (ChangeTag::Equal, ", right?")
]);

This requires the unicode feature.