From 21a01177557983878bf1c4c11c9d6995efbeb5de Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Fri, 26 May 2017 14:33:38 +0200 Subject: [PATCH] Reviews - rect.rs and length. --- src/rect.rs | 5 +---- src/vector.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/rect.rs b/src/rect.rs index 091b0e12..9b512215 100644 --- a/src/rect.rs +++ b/src/rect.rs @@ -158,10 +158,7 @@ where T: Copy + Clone + Zero + PartialOrd + PartialEq + Add + Sub) -> TypedRect { - TypedRect::new( - TypedPoint2D::new(self.origin.x + by.x, self.origin.y + by.y), - self.size - ) + Self::new(self.origin + *by, self.size) } /// Returns true if this rectangle contains the point. Points are considered diff --git a/src/vector.rs b/src/vector.rs index 29db3371..7f33a2a5 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -137,13 +137,13 @@ where T: Copy + Mul + Add + Sub { } #[inline] - pub fn square_norm(&self) -> T { + pub fn square_length(&self) -> T { self.x * self.x + self.y * self.y } #[inline] - pub fn norm(&self) -> T where T: Float + ApproxEq { - self.square_norm().sqrt() + pub fn length(&self) -> T where T: Float + ApproxEq { + self.square_length().sqrt() } } @@ -473,13 +473,13 @@ impl + } #[inline] - pub fn square_norm(&self) -> T { + pub fn square_length(&self) -> T { self.x * self.x + self.y * self.y + self.z * self.z } #[inline] - pub fn norm(&self) -> T where T: Float + ApproxEq { - self.square_norm().sqrt() + pub fn length(&self) -> T where T: Float + ApproxEq { + self.square_length().sqrt() } }