From 94b9d39bd32ced4435951dc7a61612c3ea826b87 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Tue, 10 Nov 2020 19:14:53 +0100 Subject: 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. --- src/math/vec2.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/math') 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 { pub x: T, pub y: T, @@ -19,7 +19,7 @@ impl Vec2 { Self { x, y } } - pub fn len(&self) -> T + pub fn length(&self) -> T where T: RealField, { @@ -202,6 +202,18 @@ impl + Copy> Div for Vec2 { // By default, the coordinates are first compared by their y-coordinates, then // their x-coordinates +impl PartialOrd for Vec2 +where + T: PartialOrd + Copy + 'static, +{ + fn partial_cmp(&self, other: &Self) -> Option { + match self.y.partial_cmp(&other.y) { + Some(Ordering::Equal) | None => self.x.partial_cmp(&other.x), + y_order => y_order, + } + } +} + impl Ord for Vec2 where T: Ord + Copy + 'static, -- cgit v1.2.3-70-g09d2