diff --git a/src/bench/mat.rs b/src/bench/mat.rs index 7618637b..3b0e2fe1 100644 --- a/src/bench/mat.rs +++ b/src/bench/mat.rs @@ -1,4 +1,4 @@ -use rand::random; +use std::rand::random; use test::Bencher; use na::{Vec2, Vec3, Vec4, Vec5, Vec6, DVec, Mat2, Mat3, Mat4, Mat5, Mat6, DMat}; diff --git a/src/bench/vec.rs b/src/bench/vec.rs index d570b69d..2de2546e 100644 --- a/src/bench/vec.rs +++ b/src/bench/vec.rs @@ -1,4 +1,4 @@ -use rand::random; +use std::rand::random; use test::Bencher; use na::{Vec2, Vec3, Vec4, Vec5, Vec6}; use na; diff --git a/src/lib.rs b/src/lib.rs index 125c679a..161becd2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -115,6 +115,8 @@ extern crate serialize; #[cfg(test)] extern crate test; +#[cfg(test)] +extern crate debug; pub mod na; mod structs; diff --git a/src/na.rs b/src/na.rs index 49c49b8d..00088eff 100644 --- a/src/na.rs +++ b/src/na.rs @@ -89,7 +89,7 @@ pub mod overload { /// Change the input value to ensure it is on the range `[min, max]`. #[inline(always)] -pub fn clamp(val: T, min: T, max: T) -> T { +pub fn clamp(val: T, min: T, max: T) -> T { if val > min { if val < max { val diff --git a/src/structs/dmat.rs b/src/structs/dmat.rs index e66d1edb..b03e62bd 100644 --- a/src/structs/dmat.rs +++ b/src/structs/dmat.rs @@ -14,7 +14,7 @@ use std::fmt::{Show, Formatter, Result}; /// Matrix with dimensions unknown at compile-time. -#[deriving(TotalEq, Eq, Clone)] +#[deriving(TotalEq, PartialEq, Clone)] pub struct DMat { nrows: uint, ncols: uint, diff --git a/src/structs/dvec.rs b/src/structs/dvec.rs index a5200dfa..2b637c4c 100644 --- a/src/structs/dvec.rs +++ b/src/structs/dvec.rs @@ -12,7 +12,7 @@ use traits::geometry::{Dot, Norm}; use traits::structure::{Iterable, IterableMut, Indexable}; /// Vector with a dimension unknown at compile-time. -#[deriving(TotalEq, Eq, Show, Clone)] +#[deriving(TotalEq, PartialEq, Show, Clone)] pub struct DVec { /// Components of the vector. Contains as much elements as the vector dimension. pub at: Vec diff --git a/src/structs/iso.rs b/src/structs/iso.rs index 15b8f55e..98e97610 100644 --- a/src/structs/iso.rs +++ b/src/structs/iso.rs @@ -18,7 +18,7 @@ use structs::rot::{Rot2, Rot3, Rot4}; /// /// This is the composition of a rotation followed by a translation. /// Isometries conserve angles and distances, hence do not allow shearing nor scaling. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Show)] pub struct Iso2 { /// The rotation applicable by this isometry. pub rotation: Rot2, @@ -30,7 +30,7 @@ pub struct Iso2 { /// /// This is the composition of a rotation followed by a translation. /// Isometries conserve angles and distances, hence do not allow shearing nor scaling. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Show)] pub struct Iso3 { /// The rotation applicable by this isometry. pub rotation: Rot3, @@ -41,7 +41,7 @@ pub struct Iso3 { /// Four dimensional isometry. /// /// Isometries conserve angles and distances, hence do not allow shearing nor scaling. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Show)] pub struct Iso4 { /// The rotation applicable by this isometry. pub rotation: Rot4, diff --git a/src/structs/mat.rs b/src/structs/mat.rs index 425786d6..a9cacf66 100644 --- a/src/structs/mat.rs +++ b/src/structs/mat.rs @@ -17,7 +17,7 @@ use traits::geometry::{ToHomogeneous, FromHomogeneous}; /// Special identity matrix. All its operation are no-ops. -#[deriving(TotalEq, Eq, Decodable, Clone, Rand, Show)] +#[deriving(TotalEq, PartialEq, Decodable, Clone, Rand, Show)] pub struct Identity; impl Identity { @@ -29,7 +29,7 @@ impl Identity { } /// Square matrix of dimension 1. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] pub struct Mat1 { pub m11: N } @@ -125,7 +125,7 @@ from_homogeneous_impl!(Mat1, Mat2, 1, 2) outer_impl!(Vec1, Mat1) /// Square matrix of dimension 2. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] pub struct Mat2 { pub m11: N, pub m21: N, pub m12: N, pub m22: N @@ -226,7 +226,7 @@ from_homogeneous_impl!(Mat2, Mat3, 2, 3) outer_impl!(Vec2, Mat2) /// Square matrix of dimension 3. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] pub struct Mat3 { pub m11: N, pub m21: N, pub m31: N, pub m12: N, pub m22: N, pub m32: N, @@ -341,7 +341,7 @@ from_homogeneous_impl!(Mat3, Mat4, 3, 4) outer_impl!(Vec3, Mat3) /// Square matrix of dimension 4. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] pub struct Mat4 { pub m11: N, pub m21: N, pub m31: N, pub m41: N, pub m12: N, pub m22: N, pub m32: N, pub m42: N, @@ -508,7 +508,7 @@ from_homogeneous_impl!(Mat4, Mat5, 4, 5) outer_impl!(Vec4, Mat4) /// Square matrix of dimension 5. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] pub struct Mat5 { pub m11: N, pub m21: N, pub m31: N, pub m41: N, pub m51: N, pub m12: N, pub m22: N, pub m32: N, pub m42: N, pub m52: N, @@ -691,7 +691,7 @@ from_homogeneous_impl!(Mat5, Mat6, 5, 6) outer_impl!(Vec5, Mat5) /// Square matrix of dimension 6. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] pub struct Mat6 { pub m11: N, pub m21: N, pub m31: N, pub m41: N, pub m51: N, pub m61: N, pub m12: N, pub m22: N, pub m32: N, pub m42: N, pub m52: N, pub m62: N, diff --git a/src/structs/mat_macros.rs b/src/structs/mat_macros.rs index 492a8824..0ca91a3e 100644 --- a/src/structs/mat_macros.rs +++ b/src/structs/mat_macros.rs @@ -397,7 +397,7 @@ macro_rules! mat_mul_vec_impl( macro_rules! inv_impl( ($t: ident, $dim: expr) => ( - impl + impl Inv for $t { #[inline] fn inv_cpy(m: &$t) -> Option<$t> { diff --git a/src/structs/rot.rs b/src/structs/rot.rs index 6e895d0c..f2c56624 100644 --- a/src/structs/rot.rs +++ b/src/structs/rot.rs @@ -13,7 +13,7 @@ use structs::mat::{Mat2, Mat3, Mat4, Mat5}; /// Two dimensional rotation matrix. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Show, Hash)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Show, Hash)] pub struct Rot2 { submat: Mat2 } @@ -91,7 +91,7 @@ impl AbsoluteRotate> for Rot2 { * 3d rotation */ /// Three dimensional rotation matrix. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Show, Hash)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Show, Hash)] pub struct Rot3 { submat: Mat3 } @@ -262,7 +262,7 @@ impl AbsoluteRotate> for Rot3 { } /// Four dimensional rotation matrix. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Show, Hash)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Show, Hash)] pub struct Rot4 { submat: Mat4 } diff --git a/src/structs/spec/vec.rs b/src/structs/spec/vec.rs index 1ab7ef13..2e44b8b1 100644 --- a/src/structs/spec/vec.rs +++ b/src/structs/spec/vec.rs @@ -91,7 +91,7 @@ impl> Basis for Vec2 { } } -impl Basis for Vec3 { +impl Basis for Vec3 { #[inline(always)] fn canonical_basis(f: |Vec3| -> bool) { if !f(Vec3::new(One::one(), Zero::zero(), Zero::zero())) { return }; diff --git a/src/structs/vec.rs b/src/structs/vec.rs index 0d5fe63c..7ad3d2eb 100644 --- a/src/structs/vec.rs +++ b/src/structs/vec.rs @@ -14,11 +14,11 @@ use traits::structure::{Basis, Cast, Dim, Indexable, Iterable, IterableMut}; /// Vector of dimension 0. -#[deriving(TotalEq, Eq, Decodable, Clone, Rand, Zero, Show)] +#[deriving(TotalEq, PartialEq, Decodable, Clone, Rand, Zero, Show)] pub struct Vec0; /// Vector of dimension 1. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] pub struct Vec1 { /// First component of the vector. pub x: N @@ -113,7 +113,7 @@ rotate_impl!(Vec1) transform_impl!(Vec1) /// Vector of dimension 2. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] pub struct Vec2 { /// First component of the vector. pub x: N, @@ -210,7 +210,7 @@ rotate_impl!(Vec2) transform_impl!(Vec2) /// Vector of dimension 3. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] pub struct Vec3 { /// First component of the vector. pub x: N, @@ -313,7 +313,7 @@ transform_impl!(Vec3) /// Vector of dimension 4. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] pub struct Vec4 { /// First component of the vector. pub x: N, @@ -414,7 +414,7 @@ rotate_impl!(Vec4) transform_impl!(Vec4) /// Vector of dimension 5. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] pub struct Vec5 { /// First component of the vector. pub x: N, @@ -517,7 +517,7 @@ rotate_impl!(Vec5) transform_impl!(Vec5) /// Vector of dimension 6. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] pub struct Vec6 { /// First component of the vector. pub x: N, diff --git a/src/structs/vec_macros.rs b/src/structs/vec_macros.rs index 23b0da74..e01f48d8 100644 --- a/src/structs/vec_macros.rs +++ b/src/structs/vec_macros.rs @@ -38,7 +38,7 @@ macro_rules! at_fast_impl( // However, f32/f64 does not implement TotalOrdā€¦ macro_rules! ord_impl( ($t: ident, $comp0: ident $(,$compN: ident)*) => ( - impl PartialOrd for $t { + impl PartialOrd for $t { #[inline] fn inf(a: &$t, b: &$t) -> $t { $t::new(a.$comp0.min(b.$comp0.clone()) diff --git a/src/tests/mat.rs b/src/tests/mat.rs index 305f893d..11730fc0 100644 --- a/src/tests/mat.rs +++ b/src/tests/mat.rs @@ -1,5 +1,5 @@ use std::num::{Float, abs}; -use rand::random; +use std::rand::random; use na::{Vec1, Vec3, Mat1, Mat2, Mat3, Mat4, Mat5, Mat6, Rot3, DMat, DVec, Indexable}; use na; use na::decomp_qr; diff --git a/src/tests/vec.rs b/src/tests/vec.rs index c7728d50..99efd08e 100644 --- a/src/tests/vec.rs +++ b/src/tests/vec.rs @@ -1,4 +1,4 @@ -use rand::random; +use std::rand::random; use na::{Vec0, Vec1, Vec2, Vec3, Vec4, Vec5, Vec6}; use na::{Mat3, Iterable, IterableMut}; // FIXME: get rid of that use na; diff --git a/src/traits/operations.rs b/src/traits/operations.rs index b71a1ff2..a79ef1be 100644 --- a/src/traits/operations.rs +++ b/src/traits/operations.rs @@ -3,7 +3,7 @@ /// Result of a partial ordering. -#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Show)] +#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Show)] pub enum PartialOrdering { /// Result of a strict comparison. PartialLess, diff --git a/src/traits/structure.rs b/src/traits/structure.rs index 0e94e6ad..2d5a56ed 100644 --- a/src/traits/structure.rs +++ b/src/traits/structure.rs @@ -29,7 +29,7 @@ pub trait Eye { // different Add/Sub traits. This is _so_ unfortunateā€¦ /// Trait grouping most common operations on vectors. -pub trait AnyVec: Dim + Sub + Add + Neg + Zero + Eq + Mul +pub trait AnyVec: Dim + Sub + Add + Neg + Zero + PartialEq + Mul + Div + Dot { } @@ -47,7 +47,7 @@ pub trait VecExt: AnyVec + Indexable + Iterable + /// operations on vectors. pub trait FloatVecExt: FloatVec + VecExt + Basis { } -impl + Add + Neg + Zero + Eq + Mul + Div + Dot> +impl + Add + Neg + Zero + PartialEq + Mul + Div + Dot> AnyVec for V { } impl + Norm> FloatVec for V { }