Function difference::diff

source ·
pub fn diff(orig: &str, edit: &str, split: &str) -> (i32, Vec<Difference>)
👎Deprecated since 1.0.0: please use Changeset::new instead
Expand description

This function is deprecated, please use Changeset::new instead

Calculates the edit distance and the changeset for two given strings. The first string is assumed to be the “original”, the second to be an edited version of the first. The third parameter specifies how to split the input strings, leading to a more or less exact comparison.

Common splits are "" for char-level, " " for word-level and "\n" for line-level.

Outputs the edit distance (how much the two strings differ) and a “changeset”, that is a Vec containing Differences.


use difference::diff;
use difference::Difference;

let (dist, changeset) = diff("test", "tent", "");

assert_eq!(changeset, vec![