apply some codegolfing for dubious reasons
authoralfadur
Thu, 18 Oct 2018 23:59:23 +0300
changeset 13945 2354264ab0b0
parent 13944 4162ea9ae333
child 13946 54e2a3698425
apply some codegolfing for dubious reasons
rust/land2d/src/lib.rs
--- a/rust/land2d/src/lib.rs	Thu Oct 18 22:45:14 2018 +0200
+++ b/rust/land2d/src/lib.rs	Thu Oct 18 23:59:23 2018 +0300
@@ -1,8 +1,7 @@
 extern crate integral_geometry;
 extern crate vec2d;
 
-use std::cmp;
-use std::ops;
+use std::{cmp, mem::replace};
 
 use integral_geometry::{ArcPoints, EquidistantPoints, LinePoints, Point};
 
@@ -214,12 +213,8 @@
         for point in LinePoints::new(from, to) {
             for vector in ArcPoints::new(radius) {
                 for delta in EquidistantPoints::new(vector) {
-                    self.map_point(point + delta, |p| {
-                        if *p != value {
-                            *p = value;
-                            result += 1;
-                        }
-                    })
+                    self.map_point(point + delta, |p|
+                        result += (replace(p, value) != value) as usize)
                 }
             }
         }