From 343fb2f24f1486ec01fb70c1b415de1d9544e470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crozet=20S=C3=A9bastien?= Date: Tue, 13 Oct 2020 10:12:14 +0200 Subject: [PATCH] Ensure Isometry implements Copy when targeting no-std. Fix #774. --- src/geometry/isometry.rs | 10 ++++++---- src/geometry/isometry_alias.rs | 12 ++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/geometry/isometry.rs b/src/geometry/isometry.rs index 2e4b7cd5..a4e16abe 100755 --- a/src/geometry/isometry.rs +++ b/src/geometry/isometry.rs @@ -82,21 +82,23 @@ where } } -impl + Copy> Copy - for Isometry +impl Copy for Isometry where DefaultAllocator: Allocator, Owned: Copy, { } -impl + Clone> Clone for Isometry +impl Clone for Isometry where DefaultAllocator: Allocator, { #[inline] fn clone(&self) -> Self { - Self::from_parts(self.translation.clone(), self.rotation.clone()) + Self { + rotation: self.rotation.clone(), + translation: self.translation.clone(), + } } } diff --git a/src/geometry/isometry_alias.rs b/src/geometry/isometry_alias.rs index ba9a69e7..69d33cb4 100644 --- a/src/geometry/isometry_alias.rs +++ b/src/geometry/isometry_alias.rs @@ -13,3 +13,15 @@ pub type IsometryMatrix2 = Isometry>; /// 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 = Isometry>; + +// 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() {} + + is_copy::>(); + is_copy::>(); + is_copy::>(); + is_copy::>(); +}