Ensure Isometry implements Copy when targeting no-std.

Fix #774.
This commit is contained in:
Crozet Sébastien 2020-10-13 10:12:14 +02:00
parent 81d2cbf96c
commit 343fb2f24f
2 changed files with 18 additions and 4 deletions

View File

@ -82,21 +82,23 @@ where
} }
} }
impl<N: Scalar + Copy, D: DimName + Copy, R: AbstractRotation<N, D> + Copy> Copy impl<N: Scalar + Copy, D: DimName + Copy, R: Copy> Copy for Isometry<N, D, R>
for Isometry<N, D, R>
where where
DefaultAllocator: Allocator<N, D>, DefaultAllocator: Allocator<N, D>,
Owned<N, D>: Copy, Owned<N, D>: Copy,
{ {
} }
impl<N: Scalar, D: DimName, R: AbstractRotation<N, D> + Clone> Clone for Isometry<N, D, R> impl<N: Scalar, D: DimName, R: Clone> Clone for Isometry<N, D, R>
where where
DefaultAllocator: Allocator<N, D>, DefaultAllocator: Allocator<N, D>,
{ {
#[inline] #[inline]
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self::from_parts(self.translation.clone(), self.rotation.clone()) Self {
rotation: self.rotation.clone(),
translation: self.translation.clone(),
}
} }
} }

View File

@ -13,3 +13,15 @@ pub type IsometryMatrix2<N> = Isometry<N, U2, Rotation2<N>>;
/// A 3-dimensional direct isometry using a rotation matrix for its rotational part. Also known as a rigid-body motion, or as an element of SE(3). /// A 3-dimensional direct isometry using a rotation matrix for its rotational part. Also known as a rigid-body motion, or as an element of SE(3).
pub type IsometryMatrix3<N> = Isometry<N, U3, Rotation3<N>>; pub type IsometryMatrix3<N> = Isometry<N, U3, Rotation3<N>>;
// This tests that the types correctly implement `Copy`, without having to run tests
// (when targeting no-std for example).
#[allow(dead_code)]
fn ensure_copy() {
fn is_copy<T: Copy>() {}
is_copy::<IsometryMatrix2<f32>>();
is_copy::<IsometryMatrix3<f32>>();
is_copy::<Isometry2<f32>>();
is_copy::<Isometry3<f32>>();
}