From e84b73c84828070c5c6ee28cb7d9a17e4fb8421b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sun, 13 Aug 2017 19:53:02 +0200 Subject: [PATCH] Deprecate into_owned and clone_owned for Quaternion, UnitQuaternion, and Transform. --- src/core/matrix.rs | 2 +- src/core/storage.rs | 2 +- src/geometry/quaternion.rs | 10 +++++++--- src/geometry/transform.rs | 1 + src/geometry/transform_ops.rs | 8 ++++---- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/core/matrix.rs b/src/core/matrix.rs index fe14cc4a..e767488b 100644 --- a/src/core/matrix.rs +++ b/src/core/matrix.rs @@ -250,7 +250,7 @@ impl> Matrix { } } - /// Clones this matrix into one that owns its data. + /// Clones this matrix to one that owns its data. #[inline] pub fn clone_owned(&self) -> MatrixMN where DefaultAllocator: Allocator { diff --git a/src/core/storage.rs b/src/core/storage.rs index 6b25a807..a0dd48a2 100644 --- a/src/core/storage.rs +++ b/src/core/storage.rs @@ -105,7 +105,7 @@ pub unsafe trait Storage: Debug + Sized { fn into_owned(self) -> Owned where DefaultAllocator: Allocator; - /// Clones this data storage into one that does not contain any reference. + /// Clones this data storage to one that does not contain any reference. fn clone_owned(&self) -> Owned where DefaultAllocator: Allocator; } diff --git a/src/geometry/quaternion.rs b/src/geometry/quaternion.rs index 125164ea..2d9abad0 100644 --- a/src/geometry/quaternion.rs +++ b/src/geometry/quaternion.rs @@ -76,12 +76,14 @@ where Owned: serde::Deserialize<'a> { impl Quaternion { /// Moves this unit quaternion into one that owns its data. #[inline] + #[deprecated(note = "This method is a no-op and will be removed in a future release.")] pub fn into_owned(self) -> Quaternion { self } /// Clones this unit quaternion into one that owns its data. #[inline] + #[deprecated(note = "This method is a no-op and will be removed in a future release.")] pub fn clone_owned(&self) -> Quaternion { Quaternion::from_vector(self.coords.clone_owned()) } @@ -153,7 +155,7 @@ impl Quaternion { /// Returns, from left to right: the quaternion norm, the half rotation angle, the rotation /// axis. If the rotation angle is zero, the rotation axis is set to `None`. pub fn polar_decomposition(&self) -> (N, N, Option>>) { - if let Some((q, n)) = Unit::try_new_and_get(self.clone_owned(), N::zero()) { + if let Some((q, n)) = Unit::try_new_and_get(*self, N::zero()) { if let Some(axis) = Unit::try_new(self.vector().clone_owned(), N::zero()) { let angle = q.angle() / ::convert(2.0f64); @@ -292,14 +294,16 @@ pub type UnitQuaternion = Unit>; impl UnitQuaternion { /// Moves this unit quaternion into one that owns its data. #[inline] + #[deprecated(note = "This method is a no-op and will be removed in a future release.")] pub fn into_owned(self) -> UnitQuaternion { self } /// Clones this unit quaternion into one that owns its data. #[inline] + #[deprecated(note = "This method is a no-op and will be removed in a future release.")] pub fn clone_owned(&self) -> UnitQuaternion { - UnitQuaternion::new_unchecked(self.as_ref().clone_owned()) + *self } /// The rotation angle in [0; pi] of this unit quaternion. @@ -396,7 +400,7 @@ impl UnitQuaternion { // self == other if c_hang.abs() >= N::one() { - return Some(self.clone_owned()) + return Some(*self) } let hang = c_hang.acos(); diff --git a/src/geometry/transform.rs b/src/geometry/transform.rs index f0f921ae..698c3b89 100644 --- a/src/geometry/transform.rs +++ b/src/geometry/transform.rs @@ -257,6 +257,7 @@ impl, C: TCategory> Transform /// Clones this transform into one that owns its data. #[inline] + #[deprecated(note = "This method is a no-op and will be removed in a future release.")] pub fn clone_owned(&self) -> Transform { Transform::from_matrix_unchecked(self.matrix.clone_owned()) } diff --git a/src/geometry/transform_ops.rs b/src/geometry/transform_ops.rs index 2a5a2d95..56a3d048 100644 --- a/src/geometry/transform_ops.rs +++ b/src/geometry/transform_ops.rs @@ -304,8 +304,8 @@ md_impl_all!( self: Transform, rhs: Transform, Output = Transform; [val val] => self * rhs.inverse(); [ref val] => self * rhs.inverse(); - [val ref] => self * rhs.clone_owned().inverse(); - [ref ref] => self * rhs.clone_owned().inverse(); + [val ref] => self * rhs.clone().inverse(); + [ref ref] => self * rhs.clone().inverse(); ); // Transform รท Rotation @@ -513,8 +513,8 @@ md_assign_impl_all!( (DimNameSum, DimNameSum), (DimNameSum, DimNameSum) for D: DimNameAdd, CA: SuperTCategoryOf, CB: SubTCategoryOf; self: Transform, rhs: Transform; - [val] => *self *= rhs.clone_owned().inverse(); - [ref] => *self *= rhs.clone_owned().inverse(); + [val] => *self *= rhs.inverse(); + [ref] => *self *= rhs.clone().inverse(); );