diff --git a/src/cgmath/array.rs b/src/cgmath/array.rs index 25b2223..eeb3684 100644 --- a/src/cgmath/array.rs +++ b/src/cgmath/array.rs @@ -40,7 +40,7 @@ pub trait Array *self.mut_i(b) = tmp; } - fn zip(&self, f: &fn(&T, &T) -> T) -> T; + fn fold(&self, f: &fn(&T, &T) -> T) -> T; } macro_rules! array( @@ -87,8 +87,8 @@ macro_rules! array( } #[inline] - fn zip(&self, f: &fn(&$T, &$T) -> $T) -> $T { - gen_zip!($_n) + fn fold(&self, f: &fn(&$T, &$T) -> $T) -> $T { + gen_fold!($_n) } } ) @@ -105,7 +105,7 @@ macro_rules! gen_builder( (_4) => ([builder(0), builder(1), builder(2), builder(3)]); ) -macro_rules! gen_zip( +macro_rules! gen_fold( (_2) => (f(self.i(0), self.i(1))); (_3) => (f(&f(self.i(0), self.i(1)), self.i(2))); (_4) => (f(&f(&f(self.i(0), self.i(1)), self.i(2)), self.i(3))); diff --git a/src/cgmath/vector.rs b/src/cgmath/vector.rs index 53f2c84..5769b09 100644 --- a/src/cgmath/vector.rs +++ b/src/cgmath/vector.rs @@ -130,10 +130,10 @@ pub trait Vector #[inline] fn rem_self_v(&mut self, other: &Self); /// The sum of each component of the vector. - #[inline] fn comp_add(&self) -> S { self.zip(|a, b| a.add(b)) } + #[inline] fn comp_add(&self) -> S { self.fold(|a, b| a.add(b)) } /// The product of each component of the vector. - #[inline] fn comp_mul(&self) -> S { self.zip(|a, b| a.mul(b)) } + #[inline] fn comp_mul(&self) -> S { self.fold(|a, b| a.mul(b)) } /// Vector dot product. #[inline] fn dot(&self, other: &Self) -> S { self.mul_v(other).comp_add() }