diff options
author | Joe Wilm <joe@jwilm.com> | 2017-04-03 20:21:55 -0700 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-04-03 20:44:23 -0700 |
commit | 79576b6c0b45868caeef36c5255720a7de6e57de (patch) | |
tree | 4edf7dc740601c75bf83dabeb0247c5145753d45 /src/util.rs | |
parent | a66d19f6337e1dfc756680b8fcb960f84453e783 (diff) | |
download | alacritty-79576b6c0b45868caeef36c5255720a7de6e57de.tar.gz alacritty-79576b6c0b45868caeef36c5255720a7de6e57de.zip |
Add better printing for ref test failure
The previous format was extremely difficult for a human to parse.
Diffstat (limited to 'src/util.rs')
-rw-r--r-- | src/util.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/util.rs b/src/util.rs index 3452e5b2..7227f1a0 100644 --- a/src/util.rs +++ b/src/util.rs @@ -77,6 +77,21 @@ pub mod fmt { /// Write a `Display` or `Debug` escaped with Yellow pub struct Yellow => "33"; } + + /// Write a `Display` or `Debug` escaped with Red + pub struct Green<T>(pub T); + + impl<T: fmt::Display> fmt::Display for Green<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "\x1b[32m{}\x1b[0m", self.0) + } + } + + impl<T: fmt::Debug> fmt::Debug for Green<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "\x1b[32m{:?}\x1b[0m", self.0) + } + } } #[cfg(test)] |