Dolda2000 GitWeb
/
kaka
/
rust-sdl-test.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5433a77
)
Use .signum() instead of if-else
author
Tomas Wenström
<tomas.wenstrom@gmail.com>
Sun, 14 Feb 2021 10:30:45 +0000
(11:30 +0100)
committer
Tomas Wenström
<tomas.wenstrom@gmail.com>
Sun, 14 Feb 2021 10:30:45 +0000
(11:30 +0100)
src/geometry.rs
patch
|
blob
|
blame
|
history
diff --git
a/src/geometry.rs
b/src/geometry.rs
index
540db53
..
2d5a70c
100644
(file)
--- a/
src/geometry.rs
+++ b/
src/geometry.rs
@@
-330,10
+330,7
@@
impl<T> From<Dimension<T>> for (T, T) {
pub fn supercover_line_int(p1: Point<isize>, p2: Point<isize>) -> Vec<Point<isize>> {
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));