From 6e627f3378bc4400f003ad00329b2e87236f4d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sat, 15 Jun 2013 18:06:13 +0000 Subject: [PATCH] Add Ord instances. --- src/dim1/vec1.rs | 6 +++--- src/dim2/vec2.rs | 2 +- src/dim3/vec3.rs | 2 +- src/ndim/dvec.rs | 2 +- src/ndim/nvec.rs | 2 +- src/traits/dim.rs | 16 ++++++++-------- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/dim1/vec1.rs b/src/dim1/vec1.rs index 66c04ddb..b9fd8893 100644 --- a/src/dim1/vec1.rs +++ b/src/dim1/vec1.rs @@ -10,7 +10,7 @@ use traits::sub_dot::SubDot; use traits::flatten::Flatten; use traits::workarounds::scalar_op::{ScalarMul, ScalarDiv, ScalarAdd, ScalarSub}; -#[deriving(Eq, ToStr)] +#[deriving(Eq, Ord, ToStr)] pub struct Vec1 { x : N } @@ -171,7 +171,7 @@ impl Zero for Vec1 impl Basis for Vec1 { #[inline(always)] - fn canonical_basis() -> ~[Vec1] + fn canonical_basis() -> ~[Vec1] { ~[ Vec1::new(One::one()) ] } // FIXME: this should be static #[inline(always)] @@ -194,7 +194,7 @@ impl> ApproxEq for Vec1 { self.x.approx_eq_eps(&other.x, epsilon) } } -impl Rand for Vec1 +impl Rand for Vec1 { #[inline(always)] fn rand(rng: &mut R) -> Vec1 diff --git a/src/dim2/vec2.rs b/src/dim2/vec2.rs index 343bcbd4..f8d575d7 100644 --- a/src/dim2/vec2.rs +++ b/src/dim2/vec2.rs @@ -12,7 +12,7 @@ use traits::flatten::Flatten; use traits::translation::Translation; use traits::workarounds::scalar_op::{ScalarMul, ScalarDiv, ScalarAdd, ScalarSub}; -#[deriving(Eq, ToStr)] +#[deriving(Eq, Ord, ToStr)] pub struct Vec2 { x : N, diff --git a/src/dim3/vec3.rs b/src/dim3/vec3.rs index 62746665..6d05db27 100644 --- a/src/dim3/vec3.rs +++ b/src/dim3/vec3.rs @@ -11,7 +11,7 @@ use traits::flatten::Flatten; use traits::translation::Translation; use traits::workarounds::scalar_op::{ScalarMul, ScalarDiv, ScalarAdd, ScalarSub}; -#[deriving(Eq, ToStr)] +#[deriving(Eq, Ord, ToStr)] pub struct Vec3 { x : N, diff --git a/src/ndim/dvec.rs b/src/ndim/dvec.rs index f9db1385..74b2628f 100644 --- a/src/ndim/dvec.rs +++ b/src/ndim/dvec.rs @@ -11,7 +11,7 @@ use traits::norm::Norm; use traits::translation::Translation; use traits::workarounds::scalar_op::{ScalarMul, ScalarDiv, ScalarAdd, ScalarSub}; -#[deriving(Eq, ToStr, Clone)] +#[deriving(Eq, Ord, ToStr, Clone)] pub struct DVec { at: ~[N] diff --git a/src/ndim/nvec.rs b/src/ndim/nvec.rs index a1185847..c9c6216e 100644 --- a/src/ndim/nvec.rs +++ b/src/ndim/nvec.rs @@ -21,7 +21,7 @@ use traits::workarounds::scalar_op::{ScalarMul, ScalarDiv, ScalarAdd, ScalarSub} // using d0, d1, d2, d3, ..., d7 (or your own dn) are prefered. // FIXME: it might be possible to implement type-level integers and use them // here? -#[deriving(Eq, ToStr)] +#[deriving(Eq, Ord, ToStr)] pub struct NVec { at: DVec } diff --git a/src/traits/dim.rs b/src/traits/dim.rs index f35e14af..49f007ea 100644 --- a/src/traits/dim.rs +++ b/src/traits/dim.rs @@ -11,42 +11,42 @@ pub trait Dim { /// Dimensional token for 0-dimensions. Dimensional tokens are the preferred /// way to specify at the type level the dimension of n-dimensional objects. -#[deriving(Eq, ToStr)] +#[deriving(Eq, Ord, ToStr)] pub struct d0; /// Dimensional token for 1-dimension. Dimensional tokens are the preferred /// way to specify at the type level the dimension of n-dimensional objects. -#[deriving(Eq, ToStr)] +#[deriving(Eq, Ord, ToStr)] pub struct d1; /// Dimensional token for 2-dimensions. Dimensional tokens are the preferred /// way to specify at the type level the dimension of n-dimensional objects. -#[deriving(Eq, ToStr)] +#[deriving(Eq, Ord, ToStr)] pub struct d2; /// Dimensional token for 3-dimensions. Dimensional tokens are the preferred /// way to specify at the type level the dimension of n-dimensional objects. -#[deriving(Eq, ToStr)] +#[deriving(Eq, Ord, ToStr)] pub struct d3; /// Dimensional token for 4-dimensions. Dimensional tokens are the preferred /// way to specify at the type level the dimension of n-dimensional objects. -#[deriving(Eq, ToStr)] +#[deriving(Eq, Ord, ToStr)] pub struct d4; /// Dimensional token for 5-dimensions. Dimensional tokens are the preferred /// way to specify at the type level the dimension of n-dimensional objects. -#[deriving(Eq, ToStr)] +#[deriving(Eq, Ord, ToStr)] pub struct d5; /// Dimensional token for 6-dimensions. Dimensional tokens are the preferred /// way to specify at the type level the dimension of n-dimensional objects. -#[deriving(Eq, ToStr)] +#[deriving(Eq, Ord, ToStr)] pub struct d6; /// Dimensional token for 7-dimensions. Dimensional tokens are the preferred /// way to specify at the type level the dimension of n-dimensional objects. -#[deriving(Eq, ToStr)] +#[deriving(Eq, Ord, ToStr)] pub struct d7; impl Dim for d0