Use default method impl for swap_r
This commit is contained in:
parent
75988e45d2
commit
6ec0d47ecf
2 changed files with 4 additions and 22 deletions
|
@ -44,7 +44,10 @@ pub trait Matrix
|
||||||
|
|
||||||
fn r(&self, r: uint) -> RV;
|
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]
|
#[inline]
|
||||||
fn cr<'a>(&'a self, c: uint, r: uint) -> &'a S { self.i(c).i(r) }
|
fn cr<'a>(&'a self, c: uint, r: uint) -> &'a S { self.i(c).i(r) }
|
||||||
|
|
|
@ -160,12 +160,6 @@ for Mat2<S>
|
||||||
self.i(1).i(r).clone())
|
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> {
|
fn transpose(&self) -> Mat2<S> {
|
||||||
Mat2::new(self.cr(0, 0).clone(), self.cr(1, 0).clone(),
|
Mat2::new(self.cr(0, 0).clone(), self.cr(1, 0).clone(),
|
||||||
self.cr(0, 1).clone(), self.cr(1, 1).clone())
|
self.cr(0, 1).clone(), self.cr(1, 1).clone())
|
||||||
|
@ -190,13 +184,6 @@ for Mat3<S>
|
||||||
self.i(2).i(r).clone())
|
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> {
|
fn transpose(&self) -> Mat3<S> {
|
||||||
Mat3::new(self.cr(0, 0).clone(), self.cr(1, 0).clone(), self.cr(2, 0).clone(),
|
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(),
|
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())
|
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> {
|
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(),
|
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(),
|
self.cr(0, 1).clone(), self.cr(1, 1).clone(), self.cr(2, 1).clone(), self.cr(3, 1).clone(),
|
||||||
|
|
Loading…
Reference in a new issue