rust/land2d/src/lib.rs
changeset 13966 2354264ab0b0
parent 13965 4162ea9ae333
child 13967 54e2a3698425
--- 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)
                 }
             }
         }