https://github.com/cad97/colored-diff
https://github.com/cad97/colored-diff
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/cad97/colored-diff
- Owner: CAD97
- License: mit
- Created: 2018-06-03T02:49:23.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-10-20T22:58:19.000Z (over 4 years ago)
- Last Synced: 2025-02-27T18:14:02.481Z (over 1 year ago)
- Language: Rust
- Size: 84 KB
- Stars: 17
- Watchers: 3
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# colored-diff
Show colored differences between source strings!
Inspired by / extracted from [pretty-assertions](https://github.com/colin-kiegel/rust-pretty-assertions)
and [difference's github-style example](https://github.com/johannhof/difference.rs/blob/master/examples/github-style.rs)
Powershell:

Command Prompt:

(Now accepting PRs for a macOS Terminal and/or Ubuntu (whatever console window) examples!)
[Poem Example](examples/poem.rs):
```rust
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](examples/pretty_assertions.rs):
```rust
#[derive(Debug, PartialEq)]
struct Foo {
lorem: &'static str,
ipsum: u32,
dolor: Result,
}
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 })
```