Skip to main content

patch_formatter/
patch_formatter.rs

1use diffy::PatchFormatter;
2use diffy::create_patch;
3
4fn main() {
5    let original = "first line\nlast line";
6    let modified = "first line\nmodified last line";
7
8    let patch = create_patch(original, modified);
9
10    println!("PatchFormatter::Default");
11    println!("{patch}");
12
13    let formatter = PatchFormatter::new().missing_newline_message(false);
14    println!("{formatter:?}");
15    println!("{}", formatter.fmt_patch(&patch));
16
17    let formatter = PatchFormatter::new().with_color();
18    println!("{formatter:?}");
19    println!("{}", formatter.fmt_patch(&patch));
20
21    let formatter = PatchFormatter::new()
22        .with_color()
23        .missing_newline_message(false);
24    println!("{formatter:?}");
25    println!("{}", formatter.fmt_patch(&patch));
26}