Updated to latest Rust: PartialEq, PartialOrd

This commit is contained in:
ozkriff 2014-06-02 12:18:05 +04:00
parent 31fdd67808
commit a850e37424
15 changed files with 27 additions and 27 deletions

View file

@ -82,7 +82,7 @@ pub trait Aabb<S: BaseNum, V: Vector<S>, P: Point<S, V>> {
}
/// A two-dimensional AABB, aka a rectangle.
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Aabb2<S> {
pub min: Point2<S>,
pub max: Point2<S>,
@ -127,7 +127,7 @@ impl<S: BaseNum> fmt::Show for Aabb2<S> {
}
/// A three-dimensional AABB, aka a rectangular prism.
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Aabb3<S> {
pub min: Point3<S>,
pub max: Point3<S>,

View file

@ -22,9 +22,9 @@ use approx::ApproxEq;
use num::BaseFloat;
/// An angle, in radians
#[deriving(Clone, Eq, Ord, Hash)] pub struct Rad<S> { pub s: S }
#[deriving(Clone, PartialEq, PartialOrd, Hash)] pub struct Rad<S> { pub s: S }
/// An angle, in degrees
#[deriving(Clone, Eq, Ord, Hash)] pub struct Deg<S> { pub s: S }
#[deriving(Clone, PartialEq, PartialOrd, Hash)] pub struct Deg<S> { pub s: S }
/// Create a new angle, in radians
#[inline] pub fn rad<S: BaseFloat>(s: S) -> Rad<S> { Rad { s: s } }
@ -74,7 +74,7 @@ pub trait Angle
S: BaseFloat
>
: Clone + Zero
+ Eq + Equiv<Self> + Ord
+ PartialEq + Equiv<Self> + PartialOrd
+ ApproxEq<S>
+ Neg<Self>
+ ToRad<S>

View file

@ -18,7 +18,7 @@
use point::Point3;
use vector::Vector3;
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Cylinder<S> {
pub center: Point3<S>,
pub axis: Vector3<S>,

View file

@ -22,7 +22,7 @@ use plane::Plane;
use point::Point3;
use vector::{Vector, EuclideanVector};
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Frustum<S> {
pub left: Plane<S>,
pub right: Plane<S>,
@ -59,7 +59,7 @@ Frustum<S> {
}
}
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct FrustumPoints<S> {
pub near_top_left: Point3<S>,
pub near_top_right: Point3<S>,

View file

@ -23,7 +23,7 @@ use vector::{Vector, Vector2};
use intersect::Intersect;
/// A generic directed line segment from `origin` to `dest`.
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Line<P> {
pub origin: P,
pub dest: P,

View file

@ -29,15 +29,15 @@ use vector::{Vector, EuclideanVector};
use vector::{Vector2, Vector3, Vector4};
/// A 2 x 2, column major matrix
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Matrix2<S> { pub x: Vector2<S>, pub y: Vector2<S> }
/// A 3 x 3, column major matrix
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Matrix3<S> { pub x: Vector3<S>, pub y: Vector3<S>, pub z: Vector3<S> }
/// A 4 x 4, column major matrix
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Matrix4<S> { pub x: Vector4<S>, pub y: Vector4<S>, pub z: Vector4<S>, pub w: Vector4<S> }

View file

@ -18,14 +18,14 @@
use point::{Point2, Point3};
use vector::{Vector2, Vector3};
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Obb2<S> {
pub center: Point2<S>,
pub axis: Vector2<S>,
pub extents: Vector2<S>,
}
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Obb3<S> {
pub center: Point3<S>,
pub axis: Vector3<S>,

View file

@ -41,7 +41,7 @@ use vector::{Vector, EuclideanVector};
/// The `A*x + B*y + C*z - D = 0` form is preferred over the other common
/// alternative, `A*x + B*y + C*z + D = 0`, because it tends to avoid
/// superfluous negations (see _Real Time Collision Detection_, p. 55).
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Plane<S> {
pub n: Vector3<S>,
pub d: S,

View file

@ -27,11 +27,11 @@ use num::{BaseNum, BaseFloat};
use vector::*;
/// A point in 2-dimensional space.
#[deriving(Eq, Clone, Hash)]
#[deriving(PartialEq, Clone, Hash)]
pub struct Point2<S> { pub x: S, pub y: S }
/// A point in 3-dimensional space.
#[deriving(Eq, Clone, Hash)]
#[deriving(PartialEq, Clone, Hash)]
pub struct Point3<S> { pub x: S, pub y: S, pub z: S }

View file

@ -69,7 +69,7 @@ pub trait Projection<S>: ToMatrix4<S> {
}
/// A perspective projection based on a vertical field-of-view angle.
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct PerspectiveFov<S, A> {
pub fovy: A,
pub aspect: S,
@ -143,7 +143,7 @@ impl<S: BaseFloat, A: Angle<S>> ToMatrix4<S> for PerspectiveFov<S, A> {
}
/// A perspective projection with arbitrary left/right/bottom/top distances
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Perspective<S> {
pub left: S, right: S,
pub bottom: S, top: S,
@ -193,7 +193,7 @@ impl<S: BaseFloat> ToMatrix4<S> for Perspective<S> {
}
/// An orthographic projection with arbitrary left/right/bottom/top distances
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Ortho<S> {
pub left: S, right: S,
pub bottom: S, top: S,

View file

@ -28,7 +28,7 @@ use vector::{Vector3, Vector, EuclideanVector};
/// A [quaternion](https://en.wikipedia.org/wiki/Quaternion) in scalar/vector
/// form.
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Quaternion<S> { pub s: S, pub v: Vector3<S> }
/// Represents types which can be expressed as a quaternion.

View file

@ -19,7 +19,7 @@ use vector::{Vector, Vector2, Vector3};
/// A generic ray starting at `origin` and extending infinitely in
/// `direction`.
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Ray<P,V> {
pub origin: P,
pub direction: V,

View file

@ -26,7 +26,7 @@ use vector::{Vector, Vector2, Vector3};
/// A trait for a generic rotation. A rotation is a transformation that
/// creates a circular motion, and preserves at least one point in the space.
pub trait Rotation<S: BaseNum, V: Vector<S>, P: Point<S, V>>: Eq + ApproxEq<S> {
pub trait Rotation<S: BaseNum, V: Vector<S>, P: Point<S, V>>: PartialEq + ApproxEq<S> {
/// Create the identity transform (causes no transformation).
fn identity() -> Self;
@ -125,7 +125,7 @@ pub trait Rotation3<S: BaseNum>: Rotation<S, Vector3<S>, Point3<S>>
/// implemented more efficiently than the implementations for `math::Matrix2`. To
/// enforce orthogonality at the type level the operations have been restricted
/// to a subset of those implemented on `Matrix2`.
#[deriving(Eq, Clone)]
#[deriving(PartialEq, Clone)]
pub struct Basis2<S> {
mat: Matrix2<S>
}
@ -203,7 +203,7 @@ impl<S: BaseFloat> Rotation2<S> for Basis2<S> {
/// inversion, can be implemented more efficiently than the implementations for
/// `math::Matrix3`. To ensure orthogonality is maintained, the operations have
/// been restricted to a subeset of those implemented on `Matrix3`.
#[deriving(Eq, Clone)]
#[deriving(PartialEq, Clone)]
pub struct Basis3<S> {
mat: Matrix3<S>
}

View file

@ -23,7 +23,7 @@ use vector::Vector;
use std::num::zero;
#[deriving(Clone, Eq)]
#[deriving(Clone, PartialEq)]
pub struct Sphere<S> {
pub center: Point3<S>,
pub radius: S,

View file

@ -97,7 +97,7 @@ pub trait Vector<S: BaseNum>: Array1<S>
// Utility macro for generating associated functions for the vectors
macro_rules! vec(
($Self:ident <$S:ident> { $($field:ident),+ }, $n:expr) => (
#[deriving(Eq, TotalEq, Clone, Hash)]
#[deriving(PartialEq, Eq, Clone, Hash)]
pub struct $Self<S> { $(pub $field: S),+ }
impl<$S> $Self<$S> {