From 34af62601bd76bfe8f036e1f06e0eecfd128e2b6 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Thu, 19 Sep 2013 20:44:26 +1000 Subject: [PATCH] Use .fold for comp_min and comp_max --- src/cgmath/vector.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cgmath/vector.rs b/src/cgmath/vector.rs index 66b40d5..5ca18ff 100644 --- a/src/cgmath/vector.rs +++ b/src/cgmath/vector.rs @@ -139,10 +139,10 @@ pub trait Vector #[inline] fn dot(&self, other: &Self) -> S { self.mul_v(other).comp_add() } /// The minimum component of the vector. - #[inline] fn comp_min(&self) -> S { self.iter().min().unwrap().clone() } + #[inline] fn comp_min(&self) -> S { self.fold(|a, b| a.min(b)) } /// The maximum component of the vector. - #[inline] fn comp_max(&self) -> S { self.iter().max().unwrap().clone() } + #[inline] fn comp_max(&self) -> S { self.fold(|a, b| a.max(b)) } } #[inline] fn dot>(a: V, b: V) -> S { a.dot(&b) }