summaryrefslogtreecommitdiff
path: root/src/geom
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-06-06 22:06:24 +0200
committerLaurenz <laurmaedje@gmail.com>2023-06-06 22:25:55 +0200
commit6ea98dd940361ad9232ec86f33b29c6318009c20 (patch)
treea350e0380c7403969ced255e4e55c04d83bcaff8 /src/geom
parentfd417da04f7ca4b995de7f6510abafd3e9c31307 (diff)
Small refactorings
Diffstat (limited to 'src/geom')
-rw-r--r--src/geom/rounded.rs4
-rw-r--r--src/geom/scalar.rs30
2 files changed, 16 insertions, 18 deletions
diff --git a/src/geom/rounded.rs b/src/geom/rounded.rs
index 24b52448..f1a7ea08 100644
--- a/src/geom/rounded.rs
+++ b/src/geom/rounded.rs
@@ -1,7 +1,5 @@
use super::*;
-use std::mem;
-
/// Produce shapes that together make up a rounded rectangle.
pub fn rounded_rect(
size: Size,
@@ -69,7 +67,7 @@ fn stroke_segments(
);
if !continuous {
- res.push((mem::take(&mut path), stroke.get_ref(side).clone()));
+ res.push((std::mem::take(&mut path), stroke.get_ref(side).clone()));
}
}
diff --git a/src/geom/scalar.rs b/src/geom/scalar.rs
index b45ae60a..71fb1755 100644
--- a/src/geom/scalar.rs
+++ b/src/geom/scalar.rs
@@ -34,6 +34,21 @@ impl Debug for Scalar {
}
}
+impl Eq for Scalar {}
+
+impl PartialEq for Scalar {
+ fn eq(&self, other: &Self) -> bool {
+ assert!(!self.0.is_nan() && !other.0.is_nan(), "float is NaN");
+ self.0 == other.0
+ }
+}
+
+impl PartialEq<f64> for Scalar {
+ fn eq(&self, other: &f64) -> bool {
+ self == &Self(*other)
+ }
+}
+
impl Ord for Scalar {
fn cmp(&self, other: &Self) -> Ordering {
self.partial_cmp(other).expect("float is NaN")
@@ -62,21 +77,6 @@ impl PartialOrd for Scalar {
}
}
-impl Eq for Scalar {}
-
-impl PartialEq for Scalar {
- fn eq(&self, other: &Self) -> bool {
- assert!(!self.0.is_nan() && !other.0.is_nan(), "float is NaN");
- self.0 == other.0
- }
-}
-
-impl PartialEq<f64> for Scalar {
- fn eq(&self, other: &f64) -> bool {
- self == &Self(*other)
- }
-}
-
impl Hash for Scalar {
fn hash<H: Hasher>(&self, state: &mut H) {
debug_assert!(!self.0.is_nan(), "float is NaN");