From bb3eb700e040846ca793832da4adc133218f2954 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tomas=20Wenstr=C3=B6m?= Date: Sun, 14 Feb 2021 11:30:45 +0100 Subject: [PATCH] Use .signum() instead of if-else --- src/geometry.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/geometry.rs b/src/geometry.rs index 540db53..2d5a70c 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -330,10 +330,7 @@ impl From> for (T, T) { pub fn supercover_line_int(p1: Point, p2: Point) -> Vec> { let d = p2 - p1; let n = point!(d.x.abs(), d.y.abs()); - let step = point!( - if d.x > 0 { 1 } else { -1 }, - if d.y > 0 { 1 } else { -1 } - ); + let step = point!(d.x.signum(), d.y.signum()); let mut p = p1; let mut points = vec!(point!(p.x as isize, p.y as isize)); -- 2.11.0