diff options
| author | Arne Dußin | 2020-11-10 19:14:53 +0100 |
|---|---|---|
| committer | Arne Dußin | 2020-11-10 19:14:53 +0100 |
| commit | 94b9d39bd32ced4435951dc7a61612c3ea826b87 (patch) | |
| tree | 17a948c8127bfd5a36e9768ffc947b5f08356f4d /src/math | |
| parent | 2315064b28627b1490016f3b45e8dee187ed9e05 (diff) | |
| download | graf_karto-94b9d39bd32ced4435951dc7a61612c3ea826b87.tar.gz graf_karto-94b9d39bd32ced4435951dc7a61612c3ea826b87.zip | |
Fix some style errors
Fixed the last warnings and ran clippy on the project. Fixed where
appropriate and taught clippy otherwise. Now runs through clean.
Diffstat (limited to 'src/math')
| -rw-r--r-- | src/math/vec2.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/math/vec2.rs b/src/math/vec2.rs index 7834ffc..2b33f7b 100644 --- a/src/math/vec2.rs +++ b/src/math/vec2.rs @@ -8,7 +8,7 @@ use std::convert::{From, Into}; use std::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Sub, SubAssign}; use std::{fmt, mem}; -#[derive(Clone, Copy, Debug, Default, PartialEq, PartialOrd, Serialize, Deserialize, Eq)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Eq)] pub struct Vec2<T: Scalar + Copy> { pub x: T, pub y: T, @@ -19,7 +19,7 @@ impl<T: Scalar + Copy> Vec2<T> { Self { x, y } } - pub fn len(&self) -> T + pub fn length(&self) -> T where T: RealField, { @@ -202,6 +202,18 @@ impl<T: Scalar + Div<Output = T> + Copy> Div<T> for Vec2<T> { // By default, the coordinates are first compared by their y-coordinates, then // their x-coordinates +impl<T: fmt::Debug> PartialOrd for Vec2<T> +where + T: PartialOrd + Copy + 'static, +{ + fn partial_cmp(&self, other: &Self) -> Option<Ordering> { + match self.y.partial_cmp(&other.y) { + Some(Ordering::Equal) | None => self.x.partial_cmp(&other.x), + y_order => y_order, + } + } +} + impl<T: fmt::Debug> Ord for Vec2<T> where T: Ord + Copy + 'static, |
