aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyose <ayosec@gmail.com>2022-07-15 13:46:27 +0100
committerAyose <ayosec@gmail.com>2022-07-15 13:54:06 +0100
commitbf743df94214c90708d008debbc66ea36c771c47 (patch)
treecda3d2bdf70cd3a72488654a75595d78c579dbe8
parente521d6e13576ab2c445c14a8a78a00d09a5a87fa (diff)
downloadr-alacritty-bf743df94214c90708d008debbc66ea36c771c47.tar.gz
r-alacritty-bf743df94214c90708d008debbc66ea36c771c47.tar.bz2
r-alacritty-bf743df94214c90708d008debbc66ea36c771c47.zip
Changes in sixel module to be compatible with oldstable.
- Reimplement abs_diff(). - Use positional arguments to format the error message in assert_color!().
-rw-r--r--alacritty_terminal/src/graphics/sixel.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/alacritty_terminal/src/graphics/sixel.rs b/alacritty_terminal/src/graphics/sixel.rs
index acad29c8..b3953a93 100644
--- a/alacritty_terminal/src/graphics/sixel.rs
+++ b/alacritty_terminal/src/graphics/sixel.rs
@@ -643,16 +643,27 @@ mod tests {
// We allow some difference between each component to ignore rounding
// errors.
+ // Reimplement abs_diff to be compatible with rustc before 1.60.
+ fn abs_diff(x: u8, y: u8) -> u8 {
+ if x > y {
+ x - y
+ } else {
+ y - x
+ }
+ }
+
macro_rules! assert_color {
($h:expr, $l:expr, $s:expr => $r:expr, $g:expr, $b:expr) => {
let left = hls_to_rgb($h, $l, $s);
let right = rgb($r, $g, $b, 255);
assert!(
- left.r.abs_diff(right.r) < 4
- && left.g.abs_diff(right.g) < 4
- && left.b.abs_diff(right.b) < 4,
- "Expected {right:?} Found {left:?}"
+ abs_diff(left.r, right.r) < 4
+ && abs_diff(left.g, right.g) < 4
+ && abs_diff(left.b, right.b) < 4,
+ "Expected {:?} Found {:?}",
+ right,
+ left,
);
};
}