diff options
| author | bluebear94 <uruwi@protonmail.com> | 2023-10-06 04:24:29 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-06 10:24:29 +0200 |
| commit | bced71b250225e30efa2fd0341bf825bf685a376 (patch) | |
| tree | dc1f81c7b45a3867c322b11dfa45dd788f3f8364 | |
| parent | df4beb6e15b40d22807e25e41546da698038fed9 (diff) | |
Fix Clippy lints (#2320)
| -rw-r--r-- | crates/typst/src/geom/scalar.rs | 20 | ||||
| -rw-r--r-- | crates/typst/src/geom/smart.rs | 2 | ||||
| -rw-r--r-- | crates/typst/src/geom/stroke.rs | 2 |
3 files changed, 6 insertions, 18 deletions
diff --git a/crates/typst/src/geom/scalar.rs b/crates/typst/src/geom/scalar.rs index 3fbf03ba..45e00f5c 100644 --- a/crates/typst/src/geom/scalar.rs +++ b/crates/typst/src/geom/scalar.rs @@ -84,29 +84,13 @@ impl PartialEq<f64> for Scalar { impl Ord for Scalar { fn cmp(&self, other: &Self) -> Ordering { - self.partial_cmp(other).expect("float is NaN") + self.0.partial_cmp(&other.0).expect("float is NaN") } } impl PartialOrd for Scalar { fn partial_cmp(&self, other: &Self) -> Option<Ordering> { - self.0.partial_cmp(&other.0) - } - - fn lt(&self, other: &Self) -> bool { - self.0 < other.0 - } - - fn le(&self, other: &Self) -> bool { - self.0 <= other.0 - } - - fn gt(&self, other: &Self) -> bool { - self.0 > other.0 - } - - fn ge(&self, other: &Self) -> bool { - self.0 >= other.0 + Some(self.cmp(other)) } } diff --git a/crates/typst/src/geom/smart.rs b/crates/typst/src/geom/smart.rs index 6f6dcb49..bbd9b52a 100644 --- a/crates/typst/src/geom/smart.rs +++ b/crates/typst/src/geom/smart.rs @@ -105,6 +105,8 @@ impl<T> Smart<T> { where T: Default, { + // we want to do this; the Clippy lint is not type-aware + #[allow(clippy::unwrap_or_default)] self.unwrap_or_else(T::default) } } diff --git a/crates/typst/src/geom/stroke.rs b/crates/typst/src/geom/stroke.rs index 1896bbf2..2b1bb876 100644 --- a/crates/typst/src/geom/stroke.rs +++ b/crates/typst/src/geom/stroke.rs @@ -141,6 +141,8 @@ impl Stroke<Abs> { /// Unpack the stroke, filling missing fields with the default values. pub fn unwrap_or_default(self) -> FixedStroke { + // we want to do this; the Clippy lint is not type-aware + #[allow(clippy::unwrap_or_default)] self.unwrap_or(FixedStroke::default()) } } |
