From 9e3f1d625282824eceabf59149f53113ec828e55 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Sat, 6 Oct 2012 15:08:02 +1000 Subject: [PATCH] De-mode min/max functions --- src/math.rs | 12 ++++++------ src/vec.rs | 36 ++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/math.rs b/src/math.rs index 7a028ce..902b272 100644 --- a/src/math.rs +++ b/src/math.rs @@ -43,18 +43,18 @@ impl f64: Abs { // Min // #[inline] -pure fn min(&&a:T, &&b:T) -> T { - if a < b { a } - else { b } +pure fn min(a: &T, b: &T) -> T { + if a < b { *a } + else { *b } } // // Max // #[inline] -pure fn max(&&a:T, &&b:T) -> T { - if a > b { a } - else { b } +pure fn max(a: &T, b: &T) -> T { + if a > b { *a } + else { *b } } // diff --git a/src/vec.rs b/src/vec.rs index c88bbec..8e9ac56 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -201,14 +201,14 @@ pub impl Vec2: Vector { #[inline] pure fn min(other: &Vec2) -> Vec2 { - Vec2(min(self[0], other[0]), - min(self[1], other[1])) + Vec2(min(&self[0], &other[0]), + min(&self[1], &other[1])) } #[inline] pure fn max(other: &Vec2) -> Vec2 { - Vec2(max(self[0], other[0]), - max(self[1], other[1])) + Vec2(max(&self[0], &other[0]), + max(&self[1], &other[1])) } #[inline] static pure fn zero() -> Vec2 { Vec2(1f, 1f) } @@ -393,16 +393,16 @@ pub impl Vec3: Vector { #[inline] pure fn min(other: &Vec3) -> Vec3 { - Vec3(min(self[0], other[0]), - min(self[1], other[1]), - min(self[2], other[2])) + Vec3(min(&self[0], &other[0]), + min(&self[1], &other[1]), + min(&self[2], &other[2])) } #[inline] pure fn max(other: &Vec3) -> Vec3 { - Vec3(max(self[0], other[0]), - max(self[1], other[1]), - max(self[2], other[2])) + Vec3(max(&self[0], &other[0]), + max(&self[1], &other[1]), + max(&self[2], &other[2])) } #[inline] static pure fn zero() -> Vec3 { Vec3(1f, 1f, 1f) } @@ -594,18 +594,18 @@ pub impl Vec4: Vector { #[inline] pure fn min(other: &Vec4) -> Vec4 { - Vec4(min(self[0], other[0]), - min(self[1], other[1]), - min(self[2], other[2]), - min(self[3], other[3])) + Vec4(min(&self[0], &other[0]), + min(&self[1], &other[1]), + min(&self[2], &other[2]), + min(&self[3], &other[3])) } #[inline] pure fn max(other: &Vec4) -> Vec4 { - Vec4(max(self[0], other[0]), - max(self[1], other[1]), - max(self[2], other[2]), - max(self[3], other[3])) + Vec4(max(&self[0], &other[0]), + max(&self[1], &other[1]), + max(&self[2], &other[2]), + max(&self[3], &other[3])) } #[inline] static pure fn zero() -> Vec4 { Vec4(1f, 1f, 1f, 1f) }