colored-diff

Crates.iocolored-diff
lib.rscolored-diff
version0.2.3
sourcesrc
created_at2018-06-03 03:10:51.462008
updated_at2021-10-20 22:56:18.16176
descriptionFormat the difference between two strings with ANSI colors
homepage
repositoryhttps://github.com/CAD97/colored-diff
max_upload_size
id68282
size16,476
Christopher Durham (CAD97)

documentation

README

colored-diff

Show colored differences between source strings!

Inspired by / extracted from pretty-assertions and difference's github-style example

Powershell:
Powershell Example

Command Prompt:
Command Prompt Example

(Now accepting PRs for a macOS Terminal and/or Ubuntu (whatever console window) examples!)

Poem Example:

let expected = "\
    Roses are red, violets are blue,\n\
    I wrote this library here,\n\
    just for you.\n\
    (It's true).\n\
";
let actual = "\
    Roses are red, violets are blue,\n\
    I wrote this documentation here,\n\
    just for you.\n\
    (It's quite true).\n\
";

println!("{}", colored_diff::PrettyDifference { expected, actual })

Pretty-Assertions Example:

#[derive(Debug, PartialEq)]
struct Foo {
    lorem: &'static str,
    ipsum: u32,
    dolor: Result<String, String>,
}

let x = Some(Foo { lorem: "Hello World!", ipsum: 42, dolor: Ok("hey".to_string())});
let y = Some(Foo { lorem: "Hello Wrold!", ipsum: 42, dolor: Ok("hey ho!".to_string())});

let x = format!("{:#?}", x);
let y = format!("{:#?}", y);

println!("{}", colored_diff::PrettyDifference { expected: &x, actual: &y })
Commit count: 29

cargo fmt