diff_with_algorithm

Function diff_with_algorithm 

Source
pub fn diff_with_algorithm(
    w: &mut dyn Write,
    old: &str,
    new: &str,
    theme: &dyn Theme,
    algorithm: Algorithm,
) -> Result<()>
Expand description

Print a diff to a writer using a specific algorithm

§Examples

Using the Myers algorithm

use termdiff::{diff_with_algorithm, Algorithm, ArrowsTheme};
let old = "a\nb\nc";
let new = "a\nc\n";
let mut buffer: Vec<u8> = Vec::new();
let theme = ArrowsTheme::default();
diff_with_algorithm(&mut buffer, old, new, &theme, Algorithm::Myers).unwrap();
let actual: String = String::from_utf8(buffer).expect("Not valid UTF-8");

assert_eq!(
    actual,
    "< left / > right
 a
<b
<c
>c␊
"
);

§Errors

Errors on failing to write to the writer.