#diff #difference #pretty-assertions

colored-diff

Format the difference between two strings with ANSI colors

7 releases

Uses old Rust 2015

new 0.2.3 Oct 20, 2021
0.2.2 May 17, 2019
0.2.1 Sep 24, 2018
0.2.0 Jun 5, 2018
0.1.2 Jun 3, 2018

#38 in Testing

Download history 1998/week @ 2021-07-01 2096/week @ 2021-07-08 2699/week @ 2021-07-15 3356/week @ 2021-07-22 2109/week @ 2021-07-29 2776/week @ 2021-08-05 1524/week @ 2021-08-12 1399/week @ 2021-08-19 1370/week @ 2021-08-26 1436/week @ 2021-09-02 2421/week @ 2021-09-09 2541/week @ 2021-09-16 2418/week @ 2021-09-23 2219/week @ 2021-09-30 3008/week @ 2021-10-07 2474/week @ 2021-10-14

9,541 downloads per month
Used in less than 8 crates

MIT OR Unlicense

8KB
170 lines

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 })

Dependencies

~500KB