From: Tomas Wenström Date: Sun, 14 Feb 2021 10:30:45 +0000 (+0100) Subject: Use .signum() instead of if-else X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=bb3eb700e040846ca793832da4adc133218f2954;p=kaka%2Frust-sdl-test.git Use .signum() instead of if-else --- 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));