Use default method impl for swap_r

This commit is contained in:
Brendan Zabarauskas 2013-08-27 21:24:13 +10:00
parent 75988e45d2
commit 6ec0d47ecf
2 changed files with 4 additions and 22 deletions

View file

@ -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) }

View file

@ -160,12 +160,6 @@ for Mat2<S>
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<S> {
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<S>
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<S> {
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<S>
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<S> {
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(),