Update to the last rust-nightly.
Version of rustc: 0.11.0-pre-nightly (faa7ba7 2014-05-31 01:06:40 -0700). Main changes: * `cmp::Ord` -> `cmp::PartialOrd` * `cmp::Eq` -> `cmp::PartialEq` Note that `na::PartialOrd` is not the same as `cmp::PartialOrd` (which lacks a lot of partial ordering operators).
This commit is contained in:
parent
fbe9cf7843
commit
f6c597f102
@ -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};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use rand::random;
|
||||
use std::rand::random;
|
||||
use test::Bencher;
|
||||
use na::{Vec2, Vec3, Vec4, Vec5, Vec6};
|
||||
use na;
|
||||
|
@ -115,6 +115,8 @@ extern crate serialize;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate test;
|
||||
#[cfg(test)]
|
||||
extern crate debug;
|
||||
|
||||
pub mod na;
|
||||
mod structs;
|
||||
|
@ -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<T: Ord>(val: T, min: T, max: T) -> T {
|
||||
pub fn clamp<T: cmp::PartialOrd>(val: T, min: T, max: T) -> T {
|
||||
if val > min {
|
||||
if val < max {
|
||||
val
|
||||
|
@ -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<N> {
|
||||
nrows: uint,
|
||||
ncols: uint,
|
||||
|
@ -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<N> {
|
||||
/// Components of the vector. Contains as much elements as the vector dimension.
|
||||
pub at: Vec<N>
|
||||
|
@ -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<N> {
|
||||
/// The rotation applicable by this isometry.
|
||||
pub rotation: Rot2<N>,
|
||||
@ -30,7 +30,7 @@ pub struct Iso2<N> {
|
||||
///
|
||||
/// 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<N> {
|
||||
/// The rotation applicable by this isometry.
|
||||
pub rotation: Rot3<N>,
|
||||
@ -41,7 +41,7 @@ pub struct Iso3<N> {
|
||||
/// 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<N> {
|
||||
/// The rotation applicable by this isometry.
|
||||
pub rotation: Rot4<N>,
|
||||
|
@ -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<N> {
|
||||
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<N> {
|
||||
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<N> {
|
||||
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<N> {
|
||||
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<N> {
|
||||
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<N> {
|
||||
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,
|
||||
|
@ -397,7 +397,7 @@ macro_rules! mat_mul_vec_impl(
|
||||
|
||||
macro_rules! inv_impl(
|
||||
($t: ident, $dim: expr) => (
|
||||
impl<N: Clone + Eq + Num>
|
||||
impl<N: Clone + Num>
|
||||
Inv for $t<N> {
|
||||
#[inline]
|
||||
fn inv_cpy(m: &$t<N>) -> Option<$t<N>> {
|
||||
|
@ -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<N> {
|
||||
submat: Mat2<N>
|
||||
}
|
||||
@ -91,7 +91,7 @@ impl<N: Signed> AbsoluteRotate<Vec2<N>> for Rot2<N> {
|
||||
* 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<N> {
|
||||
submat: Mat3<N>
|
||||
}
|
||||
@ -262,7 +262,7 @@ impl<N: Signed> AbsoluteRotate<Vec3<N>> for Rot3<N> {
|
||||
}
|
||||
|
||||
/// Four dimensional rotation matrix.
|
||||
#[deriving(TotalEq, Eq, Encodable, Decodable, Clone, Show, Hash)]
|
||||
#[deriving(TotalEq, PartialEq, Encodable, Decodable, Clone, Show, Hash)]
|
||||
pub struct Rot4<N> {
|
||||
submat: Mat4<N>
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ impl<N: Clone + One + Zero + Neg<N>> Basis for Vec2<N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: Clone + Ord + Float + Signed> Basis for Vec3<N> {
|
||||
impl<N: Clone + PartialOrd + Float + Signed> Basis for Vec3<N> {
|
||||
#[inline(always)]
|
||||
fn canonical_basis(f: |Vec3<N>| -> bool) {
|
||||
if !f(Vec3::new(One::one(), Zero::zero(), Zero::zero())) { return };
|
||||
|
@ -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<N>;
|
||||
|
||||
/// 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<N> {
|
||||
/// 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<N> {
|
||||
/// 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<N> {
|
||||
/// 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<N> {
|
||||
/// 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<N> {
|
||||
/// 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<N> {
|
||||
/// First component of the vector.
|
||||
pub x: N,
|
||||
|
@ -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<N: FloatMath + Eq + Clone> PartialOrd for $t<N> {
|
||||
impl<N: FloatMath + Clone> PartialOrd for $t<N> {
|
||||
#[inline]
|
||||
fn inf(a: &$t<N>, b: &$t<N>) -> $t<N> {
|
||||
$t::new(a.$comp0.min(b.$comp0.clone())
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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<N>: Dim + Sub<Self, Self> + Add<Self, Self> + Neg<Self> + Zero + Eq + Mul<N, Self>
|
||||
pub trait AnyVec<N>: Dim + Sub<Self, Self> + Add<Self, Self> + Neg<Self> + Zero + PartialEq + Mul<N, Self>
|
||||
+ Div<N, Self> + Dot<N> {
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ pub trait VecExt<N>: AnyVec<N> + Indexable<uint, N> + Iterable<N> +
|
||||
/// operations on vectors.
|
||||
pub trait FloatVecExt<N: Float>: FloatVec<N> + VecExt<N> + Basis { }
|
||||
|
||||
impl<N, V: Dim + Sub<V, V> + Add<V, V> + Neg<V> + Zero + Eq + Mul<N, V> + Div<N, V> + Dot<N>>
|
||||
impl<N, V: Dim + Sub<V, V> + Add<V, V> + Neg<V> + Zero + PartialEq + Mul<N, V> + Div<N, V> + Dot<N>>
|
||||
AnyVec<N> for V { }
|
||||
|
||||
impl<N: Float, V: AnyVec<N> + Norm<N>> FloatVec<N> for V { }
|
||||
|
Loading…
Reference in New Issue
Block a user