Remove the inherent clone method from points.

Fix #458.
This commit is contained in:
sebcrozet 2018-10-30 17:56:33 +01:00 committed by Sébastien Crozet
parent c80cf75bb4
commit 98b0b842e9
2 changed files with 15 additions and 23 deletions

View File

@ -19,7 +19,7 @@ use base::{DefaultAllocator, Scalar, VectorN};
/// A point in a n-dimensional euclidean space.
#[repr(C)]
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct Point<N: Scalar, D: DimName>
where DefaultAllocator: Allocator<N, D>
{
@ -41,17 +41,7 @@ impl<N: Scalar, D: DimName> Copy for Point<N, D>
where
DefaultAllocator: Allocator<N, D>,
<DefaultAllocator as Allocator<N, D>>::Buffer: Copy,
{}
impl<N: Scalar, D: DimName> Clone for Point<N, D>
where
DefaultAllocator: Allocator<N, D>,
<DefaultAllocator as Allocator<N, D>>::Buffer: Clone,
{
#[inline]
fn clone(&self) -> Self {
Point::from(self.coords.clone())
}
}
#[cfg(feature = "serde-serialize")]
@ -104,13 +94,6 @@ where
impl<N: Scalar, D: DimName> Point<N, D>
where DefaultAllocator: Allocator<N, D>
{
/// Clones this point into one that owns its data.
#[inline]
#[deprecated(note = "This will be removed. Use the `.clone()` method from the `Clone` trait instead.")]
pub fn clone(&self) -> Point<N, D> {
Point::from(self.coords.clone_owned())
}
/// Converts this point into a vector in homogeneous coordinates, i.e., appends a `1` at the
/// end of it.
///

View File

@ -1,7 +1,13 @@
#![cfg(feature = "arbitrary")]
use na::{Point3, Vector3, Vector4};
use num::Zero;
#[test]
fn point_clone() {
let p = Point3::new(1.0, 2.0, 3.0);
let p2 = p.clone();
assert_eq!(p, p2);
}
#[test]
fn point_ops() {
let a = Point3::new(1.0, 2.0, 3.0);
@ -87,7 +93,10 @@ fn to_homogeneous() {
assert_eq!(a.to_homogeneous(), expected);
}
quickcheck!(fn point_sub(pt1: Point3<f64>, pt2: Point3<f64>) -> bool {
let dpt = &pt2 - &pt1;
relative_eq!(pt2, pt1 + dpt, epsilon = 1.0e-7)
});
#[cfg(feature = "arbitrary")]
quickcheck!(
fn point_sub(pt1: Point3<f64>, pt2: Point3<f64>) -> bool {
let dpt = &pt2 - &pt1;
relative_eq!(pt2, pt1 + dpt, epsilon = 1.0e-7)
}
);