resolve some clippy complaints
authoralfadur
Sun, 04 Nov 2018 04:39:21 +0300
changeset 14131 32383b888309
parent 14130 376a0551b00a
child 14132 0c5b9cfda9ab
resolve some clippy complaints
rust/integral-geometry/src/lib.rs
rust/landgen/src/outline.rs
rust/landgen/src/outline_template.rs
--- a/rust/integral-geometry/src/lib.rs	Sun Nov 04 00:20:27 2018 +0100
+++ b/rust/integral-geometry/src/lib.rs	Sun Nov 04 04:39:21 2018 +0300
@@ -65,7 +65,7 @@
     }
 
     #[inline]
-    pub fn fit(&self, rect: &Rect) -> Point {
+    pub fn fit(self, rect: &Rect) -> Point {
         let x = if self.x > rect.right() {
             rect.right()
         } else if self.x < rect.left() {
--- a/rust/landgen/src/outline.rs	Sun Nov 04 00:20:27 2018 +0100
+++ b/rust/landgen/src/outline.rs	Sun Nov 04 04:39:21 2018 +0300
@@ -73,9 +73,9 @@
         random_numbers: &mut I,
     ) -> Option<Point> {
         #[inline]
-        fn intersect(p: &Point, m: &Point, p1: &Point, p2: &Point) -> bool {
-            let t1 = (*m - *p1).cross(*p);
-            let t2 = (*m - *p2).cross(*p);
+        fn intersect(p: Point, m: Point, p1: Point, p2: Point) -> bool {
+            let t1 = (m - p1).cross(p);
+            let t2 = (m - p2).cross(p);
 
             (t1 > 0) != (t2 > 0)
         }
@@ -83,12 +83,12 @@
         #[inline]
         fn solve_intersection(
             intersections_box: &Rect,
-            p: &Point,
-            m: &Point,
-            s: &Point,
-            e: &Point,
+            p: Point,
+            m: Point,
+            s: Point,
+            e: Point,
         ) -> Option<(i32, u32)> {
-            let f = *e - *s;
+            let f = e - s;
             let aqpb = p.cross(f) as i64;
 
             if aqpb != 0 {
@@ -111,7 +111,7 @@
                 };
 
                 let intersection_point = Point::new(ix, iy);
-                let diff_point = *m - intersection_point;
+                let diff_point = m - intersection_point;
                 let t = p.dot(diff_point);
                 if diff_point.max_norm() >= std::i16::MAX as i32 {
                     Some((t, std::i32::MAX as u32))
@@ -188,13 +188,13 @@
         // now go through all other segments
         for s in self.segments_iter() {
             if s != segment {
-                if intersect(&p, &mid_point, &s.start, &s.end) {
+                if intersect(p, mid_point, s.start, s.end) {
                     if let Some((t, d)) = solve_intersection(
                         &self.intersections_box,
-                        &p,
-                        &mid_point,
-                        &s.start,
-                        &s.end,
+                        p,
+                        mid_point,
+                        s.start,
+                        s.end,
                     ) {
                         if t > 0 {
                             dist_right = min(dist_right, d);
@@ -207,16 +207,16 @@
         }
 
         // go through all points, including fill points
-        for pi in self.iter() {
-            if *pi != segment.start && *pi != segment.end {
-                if intersect(&p, &pi, &segment.start, &segment.end) {
+        for pi in self.iter().cloned() {
+            if pi != segment.start && pi != segment.end {
+                if intersect(p, pi, segment.start, segment.end) {
                     // ray from segment.start
                     if let Some((t, d)) = solve_intersection(
                         &self.intersections_box,
-                        &p,
-                        &mid_point,
-                        &segment.start,
-                        &pi,
+                        p,
+                        mid_point,
+                        segment.start,
+                        pi,
                     ) {
                         if t > 0 {
                             dist_right = min(dist_right, d);
@@ -228,10 +228,10 @@
                     // ray from segment.end
                     if let Some((t, d)) = solve_intersection(
                         &self.intersections_box,
-                        &p,
-                        &mid_point,
-                        &segment.end,
-                        &pi,
+                        p,
+                        mid_point,
+                        segment.end,
+                        pi,
                     ) {
                         if t > 0 {
                             dist_right = min(dist_right, d);
--- a/rust/landgen/src/outline_template.rs	Sun Nov 04 00:20:27 2018 +0100
+++ b/rust/landgen/src/outline_template.rs	Sun Nov 04 04:39:21 2018 +0300
@@ -1,5 +1,6 @@
 use integral_geometry::{Point, Rect, Size};
 
+#[derive(Debug)]
 pub struct OutlineTemplate {
     pub islands: Vec<Vec<Rect>>,
     pub fill_points: Vec<Point>,