7 releases

Uses old Rust 2015

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

#323 in Testing

Download history 6286/week @ 2024-07-04 7567/week @ 2024-07-11 6537/week @ 2024-07-18 6728/week @ 2024-07-25 4108/week @ 2024-08-01 5139/week @ 2024-08-08 6338/week @ 2024-08-15 3690/week @ 2024-08-22 2103/week @ 2024-08-29 1907/week @ 2024-09-05 1221/week @ 2024-09-12 781/week @ 2024-09-19 977/week @ 2024-09-26 636/week @ 2024-10-03 723/week @ 2024-10-10 1167/week @ 2024-10-17

3,631 downloads per month
Used in 23 crates

MIT OR Unlicense

9KB
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

~520–730KB
~11K SLoC