[librsvg] util.rs: Move double_equals() and the renamed DBL_EPSILON here



commit c9f2b2965951f08171be89ae6c12c8d4939236e0
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Jan 27 18:43:42 2017 -0600

    util.rs: Move double_equals() and the renamed DBL_EPSILON here

 rust/src/marker.rs |   10 +++-------
 rust/src/util.rs   |    6 ++++++
 2 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/rust/src/marker.rs b/rust/src/marker.rs
index 7f17c42..a4808a8 100644
--- a/rust/src/marker.rs
+++ b/rust/src/marker.rs
@@ -5,6 +5,7 @@ extern crate cairo_sys;
 use std::f64::consts::*;
 use path_builder::*;
 use drawing_ctx::RsvgDrawingCtx;
+use util::*;
 
 #[derive(Debug, PartialEq)]
 pub enum Segment {
@@ -45,12 +46,6 @@ enum SegmentState {
  *    The tangents also work if the segment refers to a lineto (they will both just point in the same 
direction).
  */
 
-const EPSILON: f64 = 1e-10;
-
-fn double_equals (a: f64, b: f64) -> bool {
-    (a - b).abs () < EPSILON
-}
-
 fn make_degenerate (x: f64, y: f64) -> Segment {
     Segment::Degenerate { x: x, y: y }
 }
@@ -517,6 +512,7 @@ mod tests {
     use std::f64::consts::*;
     use super::*;
     use path_builder::*;
+    use util::*;
     extern crate cairo;
 
     fn test_bisection_angle (expected: f64,
@@ -526,7 +522,7 @@ mod tests {
                              outgoing_vy: f64) {
         let bisected = super::bisect_angles (super::angle_from_vector (incoming_vx, incoming_vy),
                                              super::angle_from_vector (outgoing_vx, outgoing_vy));
-        assert! (super::double_equals (expected, bisected));
+        assert! (double_equals (expected, bisected));
     }
 
     #[test]
diff --git a/rust/src/util.rs b/rust/src/util.rs
new file mode 100644
index 0000000..b3f09e7
--- /dev/null
+++ b/rust/src/util.rs
@@ -0,0 +1,6 @@
+const DBL_EPSILON: f64 = 1e-10;
+pub const DBL_EPSILON: f64 = 1e-10;
+
+pub fn double_equals (a: f64, b: f64) -> bool {
+    (a - b).abs () < DBL_EPSILON
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]