From 43c5f4cb7347b8ac966e7ab7c33af8d0aadcad8a Mon Sep 17 00:00:00 2001 From: Jack Wrenn Date: Sun, 9 Dec 2018 15:24:08 -0500 Subject: [PATCH] Rename `Transform::unwrap` to `Transform::into_inner` and deprecate `Transform::unwrap` See #460 --- src/geometry/transform.rs | 12 +++++-- src/geometry/transform_ops.rs | 64 +++++++++++++++++------------------ 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/src/geometry/transform.rs b/src/geometry/transform.rs index 11060977..08248a46 100644 --- a/src/geometry/transform.rs +++ b/src/geometry/transform.rs @@ -248,9 +248,17 @@ where DefaultAllocator: Allocator, DimNameSum> /// 3.0, 4.0, 0.0, /// 0.0, 0.0, 1.0); /// let t = Transform2::from_matrix_unchecked(m); - /// assert_eq!(t.unwrap(), m); + /// assert_eq!(t.into_inner(), m); /// ``` #[inline] + pub fn into_inner(self) -> MatrixN> { + self.matrix + } + + /// Retrieves the underlying matrix. + /// Deprecated: Use [Transform::into_inner] instead. + #[deprecated(note="use `.into_inner()` instead")] + #[inline] pub fn unwrap(self) -> MatrixN> { self.matrix } @@ -329,7 +337,7 @@ where DefaultAllocator: Allocator, DimNameSum> /// 3.0, 4.0, 0.0, /// 0.0, 0.0, 1.0); /// let t = Transform2::from_matrix_unchecked(m); - /// assert_eq!(t.unwrap(), m); + /// assert_eq!(t.into_inner(), m); /// ``` #[inline] pub fn to_homogeneous(&self) -> MatrixN> { diff --git a/src/geometry/transform_ops.rs b/src/geometry/transform_ops.rs index 6fc4ec32..1c95f3b0 100644 --- a/src/geometry/transform_ops.rs +++ b/src/geometry/transform_ops.rs @@ -159,9 +159,9 @@ md_impl_all!( Mul, mul where N: Real; (DimNameSum, DimNameSum), (DimNameSum, DimNameSum) for D: DimNameAdd, CA: TCategoryMul, CB: TCategory; self: Transform, rhs: Transform, Output = Transform; - [val val] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.unwrap()); - [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.unwrap()); - [val ref] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.matrix()); + [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.into_inner()); + [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.into_inner()); + [val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.matrix()); [ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.matrix()); ); @@ -170,9 +170,9 @@ md_impl_all!( Mul, mul where N: Real; (DimNameSum, DimNameSum), (D, D) for D: DimNameAdd, C: TCategoryMul; self: Transform, rhs: Rotation, Output = Transform; - [val val] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.to_homogeneous()); + [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); - [val ref] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.to_homogeneous()); + [val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); ); @@ -181,8 +181,8 @@ md_impl_all!( Mul, mul where N: Real; (D, D), (DimNameSum, DimNameSum) for D: DimNameAdd, C: TCategoryMul; self: Rotation, rhs: Transform, Output = Transform; - [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.unwrap()); - [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.unwrap()); + [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); + [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); [val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); [ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); ); @@ -192,9 +192,9 @@ md_impl_all!( Mul, mul where N: Real; (U4, U4), (U4, U1) for C: TCategoryMul; self: Transform, rhs: UnitQuaternion, Output = Transform; - [val val] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.to_homogeneous()); + [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); - [val ref] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.to_homogeneous()); + [val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); ); @@ -203,8 +203,8 @@ md_impl_all!( Mul, mul where N: Real; (U4, U1), (U4, U4) for C: TCategoryMul; self: UnitQuaternion, rhs: Transform, Output = Transform; - [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.unwrap()); - [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.unwrap()); + [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); + [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); [val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); [ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); ); @@ -215,9 +215,9 @@ md_impl_all!( (DimNameSum, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> >; self: Transform, rhs: Isometry, Output = Transform; - [val val] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.to_homogeneous()); + [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); - [val ref] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.to_homogeneous()); + [val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); ); @@ -227,8 +227,8 @@ md_impl_all!( (D, U1), (DimNameSum, DimNameSum) for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> >; self: Isometry, rhs: Transform, Output = Transform; - [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.unwrap()); - [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.unwrap()); + [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); + [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); [val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); [ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); ); @@ -239,9 +239,9 @@ md_impl_all!( (DimNameSum, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> >; self: Transform, rhs: Similarity, Output = Transform; - [val val] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.to_homogeneous()); + [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); - [val ref] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.to_homogeneous()); + [val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); ); @@ -251,8 +251,8 @@ md_impl_all!( (D, U1), (DimNameSum, DimNameSum) for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> >; self: Similarity, rhs: Transform, Output = Transform; - [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.unwrap()); - [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.unwrap()); + [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); + [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); [val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); [ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); ); @@ -270,9 +270,9 @@ md_impl_all!( Mul, mul where N: Real; (DimNameSum, DimNameSum), (D, U1) for D: DimNameAdd, C: TCategoryMul; self: Transform, rhs: Translation, Output = Transform; - [val val] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.to_homogeneous()); + [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); - [val ref] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.to_homogeneous()); + [val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); [ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); ); @@ -282,8 +282,8 @@ md_impl_all!( (D, U1), (DimNameSum, DimNameSum) for D: DimNameAdd, C: TCategoryMul; self: Translation, rhs: Transform, Output = Transform; - [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.unwrap()); - [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.unwrap()); + [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); + [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); [val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); [ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); ); @@ -350,9 +350,9 @@ md_impl_all!( // for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> > // where SB::Alloc: Allocator, DimNameSum >; // self: Transform, rhs: Isometry, Output = Transform; -// [val val] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.inverse().to_homogeneous()); +// [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.inverse().to_homogeneous()); // [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.inverse().to_homogeneous()); -// [val ref] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.inverse().to_homogeneous()); +// [val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.inverse().to_homogeneous()); // [ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.inverse().to_homogeneous()); // ); @@ -363,8 +363,8 @@ md_impl_all!( // for D: DimNameAdd, C: TCategoryMul, R: SubsetOf> > // where SA::Alloc: Allocator, DimNameSum >; // self: Isometry, rhs: Transform, Output = Transform; -// [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.unwrap()); -// [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.unwrap()); +// [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); +// [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); // [val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); // [ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); // ); @@ -377,9 +377,9 @@ md_impl_all!( // where SB::Alloc: Allocator // where SB::Alloc: Allocator, DimNameSum >; // self: Transform, rhs: Similarity, Output = Transform; -// [val val] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.to_homogeneous()); +// [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); // [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); -// [val ref] => Self::Output::from_matrix_unchecked(self.unwrap() * rhs.to_homogeneous()); +// [val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); // [ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); // ); @@ -391,8 +391,8 @@ md_impl_all!( // where SA::Alloc: Allocator // where SA::Alloc: Allocator, DimNameSum >; // self: Similarity, rhs: Transform, Output = Transform; -// [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.unwrap()); -// [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.unwrap()); +// [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); +// [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); // [val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); // [ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); // ); @@ -425,7 +425,7 @@ md_assign_impl_all!( MulAssign, mul_assign where N: Real; (DimNameSum, DimNameSum), (DimNameSum, DimNameSum) for D: DimNameAdd, CA: TCategory, CB: SubTCategoryOf; self: Transform, rhs: Transform; - [val] => *self.matrix_mut_unchecked() *= rhs.unwrap(); + [val] => *self.matrix_mut_unchecked() *= rhs.into_inner(); [ref] => *self.matrix_mut_unchecked() *= rhs.matrix(); );