diff --git a/src/rotation.rs b/src/rotation.rs index 39cf1a0..1e65e03 100644 --- a/src/rotation.rs +++ b/src/rotation.rs @@ -167,10 +167,11 @@ pub struct Basis2 { mat: Matrix2 } -impl Basis2 { - /// Coerce to a `Matrix2` +impl AsRef> for Basis2 { #[inline] - pub fn as_matrix2<'a>(&'a self) -> &'a Matrix2 { &self.mat } + fn as_ref(&self) -> &Matrix2 { + &self.mat + } } /// Represents types which can be converted to a rotation matrix. @@ -251,10 +252,13 @@ impl Basis3 { pub fn from_quaternion(quaternion: &Quaternion) -> Basis3 { Basis3 { mat: quaternion.clone().into() } } +} - /// Coerce to a `Matrix3` +impl AsRef> for Basis3 { #[inline] - pub fn as_matrix3<'a>(&'a self) -> &'a Matrix3 { &self.mat } + fn as_ref(&self) -> &Matrix3 { + &self.mat + } } /// Represents types which can be converted to a rotation matrix. diff --git a/tests/rotation.rs b/tests/rotation.rs index 5acc26e..4ee31de 100644 --- a/tests/rotation.rs +++ b/tests/rotation.rs @@ -33,11 +33,15 @@ mod rotation { #[test] fn test_invert_basis2() { let a: Basis2<_> = rotation::a2(); - assert!(a.concat(&a.invert()).as_matrix2().is_identity()); + let a = a.concat(&a.invert()); + let a: &Matrix2<_> = a.as_ref(); + assert!(a.is_identity()); } #[test] fn test_invert_basis3() { let a: Basis3<_> = rotation::a3(); - assert!(a.concat(&a.invert()).as_matrix3().is_identity()); + let a = a.concat(&a.invert()); + let a: &Matrix3<_> = a.as_ref(); + assert!(a.is_identity()); }