diff --git a/src/cgmath/traits/alg/matrix.rs b/src/cgmath/traits/alg/matrix.rs index 988a729..df23e55 100644 --- a/src/cgmath/traits/alg/matrix.rs +++ b/src/cgmath/traits/alg/matrix.rs @@ -44,7 +44,10 @@ pub trait Matrix fn r(&self, r: uint) -> RV; - fn swap_r(&mut self, a: uint, b: uint); + #[inline] + fn swap_r(&mut self, a: uint, b: uint) { + self.map_mut(|c| c.swap(a, b)); + } #[inline] fn cr<'a>(&'a self, c: uint, r: uint) -> &'a S { self.i(c).i(r) } diff --git a/src/cgmath/types/matrix.rs b/src/cgmath/types/matrix.rs index abe38b4..6efd0a6 100644 --- a/src/cgmath/types/matrix.rs +++ b/src/cgmath/types/matrix.rs @@ -160,12 +160,6 @@ for Mat2 self.i(1).i(r).clone()) } - #[inline] - fn swap_r(&mut self, a: uint, b: uint) { - self.mut_c(0).swap(a, b); - self.mut_c(1).swap(a, b); - } - fn transpose(&self) -> Mat2 { Mat2::new(self.cr(0, 0).clone(), self.cr(1, 0).clone(), self.cr(0, 1).clone(), self.cr(1, 1).clone()) @@ -190,13 +184,6 @@ for Mat3 self.i(2).i(r).clone()) } - #[inline] - fn swap_r(&mut self, a: uint, b: uint) { - self.mut_c(0).swap(a, b); - self.mut_c(1).swap(a, b); - self.mut_c(2).swap(a, b); - } - fn transpose(&self) -> Mat3 { Mat3::new(self.cr(0, 0).clone(), self.cr(1, 0).clone(), self.cr(2, 0).clone(), self.cr(0, 1).clone(), self.cr(1, 1).clone(), self.cr(2, 1).clone(), @@ -223,14 +210,6 @@ for Mat4 self.i(2).i(r).clone()) } - #[inline] - fn swap_r(&mut self, a: uint, b: uint) { - self.mut_c(0).swap(a, b); - self.mut_c(1).swap(a, b); - self.mut_c(2).swap(a, b); - self.mut_c(3).swap(a, b); - } - fn transpose(&self) -> Mat4 { Mat4::new(self.cr(0, 0).clone(), self.cr(1, 0).clone(), self.cr(2, 0).clone(), self.cr(3, 0).clone(), self.cr(0, 1).clone(), self.cr(1, 1).clone(), self.cr(2, 1).clone(), self.cr(3, 1).clone(),