Add deriving `Hash` and `Show`.

This commit is contained in:
Sébastien Crozet 2014-02-23 08:44:21 +01:00
parent 9a49bb5895
commit ba32051fdf
6 changed files with 22 additions and 22 deletions

View File

@ -16,7 +16,7 @@ use traits::structure::{Iterable, IterableMut};
mod metal; mod metal;
/// Vector with a dimension unknown at compile-time. /// Vector with a dimension unknown at compile-time.
#[deriving(Eq, ToStr, Clone)] #[deriving(Eq, Show, ToStr, Clone)]
pub struct DVec<N> { pub struct DVec<N> {
/// Components of the vector. Contains as much elements as the vector dimension. /// Components of the vector. Contains as much elements as the vector dimension.
at: ~[N] at: ~[N]

View File

@ -20,7 +20,7 @@ mod iso_macros;
/// ///
/// This is the composition of a rotation followed by a translation. /// This is the composition of a rotation followed by a translation.
/// Isometries conserve angles and distances, hence do not allow shearing nor scaling. /// Isometries conserve angles and distances, hence do not allow shearing nor scaling.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, ToStr, IterBytes)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Show, ToStr, IterBytes)]
pub struct Iso2<N> { pub struct Iso2<N> {
/// The rotation applicable by this isometry. /// The rotation applicable by this isometry.
rotation: Rot2<N>, rotation: Rot2<N>,
@ -32,7 +32,7 @@ pub struct Iso2<N> {
/// ///
/// This is the composition of a rotation followed by a translation. /// This is the composition of a rotation followed by a translation.
/// Isometries conserve angles and distances, hence do not allow shearing nor scaling. /// Isometries conserve angles and distances, hence do not allow shearing nor scaling.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, ToStr, IterBytes)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Show, ToStr, IterBytes)]
pub struct Iso3<N> { pub struct Iso3<N> {
/// The rotation applicable by this isometry. /// The rotation applicable by this isometry.
rotation: Rot3<N>, rotation: Rot3<N>,
@ -43,7 +43,7 @@ pub struct Iso3<N> {
/// Four dimensional isometry. /// Four dimensional isometry.
/// ///
/// Isometries conserve angles and distances, hence do not allow shearing nor scaling. /// Isometries conserve angles and distances, hence do not allow shearing nor scaling.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, ToStr, IterBytes)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Show, ToStr, IterBytes)]
pub struct Iso4<N> { pub struct Iso4<N> {
/// The rotation applicable by this isometry. /// The rotation applicable by this isometry.
rotation: Rot4<N>, rotation: Rot4<N>,

View File

@ -17,7 +17,7 @@ mod metal;
mod mat_macros; mod mat_macros;
/// Special identity matrix. All its operation are no-ops. /// Special identity matrix. All its operation are no-ops.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Rand, ToStr)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Rand, Show, ToStr)]
pub struct Identity; pub struct Identity;
impl Identity { impl Identity {
@ -29,7 +29,7 @@ impl Identity {
} }
/// Square matrix of dimension 1. /// Square matrix of dimension 1.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Hash, Rand, Zero, Show, ToStr)]
pub struct Mat1<N> { pub struct Mat1<N> {
m11: N m11: N
} }
@ -121,7 +121,7 @@ from_homogeneous_impl!(Mat1, Mat2, 1, 2)
outer_impl!(Vec1, Mat1) outer_impl!(Vec1, Mat1)
/// Square matrix of dimension 2. /// Square matrix of dimension 2.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Hash, Rand, Zero, Show, ToStr)]
pub struct Mat2<N> { pub struct Mat2<N> {
m11: N, m21: N, m11: N, m21: N,
m12: N, m22: N m12: N, m22: N
@ -218,7 +218,7 @@ from_homogeneous_impl!(Mat2, Mat3, 2, 3)
outer_impl!(Vec2, Mat2) outer_impl!(Vec2, Mat2)
/// Square matrix of dimension 3. /// Square matrix of dimension 3.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Hash, Rand, Zero, Show, ToStr)]
pub struct Mat3<N> { pub struct Mat3<N> {
m11: N, m21: N, m31: N, m11: N, m21: N, m31: N,
m12: N, m22: N, m32: N, m12: N, m22: N, m32: N,
@ -329,7 +329,7 @@ from_homogeneous_impl!(Mat3, Mat4, 3, 4)
outer_impl!(Vec3, Mat3) outer_impl!(Vec3, Mat3)
/// Square matrix of dimension 4. /// Square matrix of dimension 4.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Hash, Rand, Zero, Show, ToStr)]
pub struct Mat4<N> { pub struct Mat4<N> {
m11: N, m21: N, m31: N, m41: N, m11: N, m21: N, m31: N, m41: N,
m12: N, m22: N, m32: N, m42: N, m12: N, m22: N, m32: N, m42: N,
@ -492,7 +492,7 @@ from_homogeneous_impl!(Mat4, Mat5, 4, 5)
outer_impl!(Vec4, Mat4) outer_impl!(Vec4, Mat4)
/// Square matrix of dimension 5. /// Square matrix of dimension 5.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Hash, Rand, Zero, Show, ToStr)]
pub struct Mat5<N> { pub struct Mat5<N> {
m11: N, m21: N, m31: N, m41: N, m51: N, m11: N, m21: N, m31: N, m41: N, m51: N,
m12: N, m22: N, m32: N, m42: N, m52: N, m12: N, m22: N, m32: N, m42: N, m52: N,
@ -671,7 +671,7 @@ from_homogeneous_impl!(Mat5, Mat6, 5, 6)
outer_impl!(Vec5, Mat5) outer_impl!(Vec5, Mat5)
/// Square matrix of dimension 6. /// Square matrix of dimension 6.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Hash, Rand, Zero, Show, ToStr)]
pub struct Mat6<N> { pub struct Mat6<N> {
m11: N, m21: N, m31: N, m41: N, m51: N, m61: N, m11: N, m21: N, m31: N, m41: N, m51: N, m61: N,
m12: N, m22: N, m32: N, m42: N, m52: N, m62: N, m12: N, m22: N, m32: N, m42: N, m52: N, m62: N,

View File

@ -15,7 +15,7 @@ mod metal;
mod rot_macros; mod rot_macros;
/// Two dimensional rotation matrix. /// Two dimensional rotation matrix.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, ToStr, IterBytes)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Show, ToStr, IterBytes)]
pub struct Rot2<N> { pub struct Rot2<N> {
priv submat: Mat2<N> priv submat: Mat2<N>
} }
@ -93,7 +93,7 @@ impl<N: Signed> AbsoluteRotate<Vec2<N>> for Rot2<N> {
* 3d rotation * 3d rotation
*/ */
/// Three dimensional rotation matrix. /// Three dimensional rotation matrix.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, ToStr, IterBytes)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Show, ToStr, IterBytes)]
pub struct Rot3<N> { pub struct Rot3<N> {
priv submat: Mat3<N> priv submat: Mat3<N>
} }
@ -264,7 +264,7 @@ impl<N: Signed> AbsoluteRotate<Vec3<N>> for Rot3<N> {
} }
/// Four dimensional rotation matrix. /// Four dimensional rotation matrix.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, ToStr, IterBytes)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Show, ToStr, IterBytes)]
pub struct Rot4<N> { pub struct Rot4<N> {
priv submat: Mat4<N> priv submat: Mat4<N>
} }

View File

@ -17,11 +17,11 @@ mod metal;
mod vec_macros; mod vec_macros;
/// Vector of dimension 0. /// Vector of dimension 0.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Rand, Zero, ToStr)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Rand, Zero, Show, ToStr)]
pub struct Vec0<N>; pub struct Vec0<N>;
/// Vector of dimension 1. /// Vector of dimension 1.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Hash, Rand, Zero, Show, ToStr)]
pub struct Vec1<N> { pub struct Vec1<N> {
/// First component of the vector. /// First component of the vector.
x: N x: N
@ -117,7 +117,7 @@ rotate_impl!(Vec1)
transform_impl!(Vec1) transform_impl!(Vec1)
/// Vector of dimension 2. /// Vector of dimension 2.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Hash, Rand, Zero, Show, ToStr)]
pub struct Vec2<N> { pub struct Vec2<N> {
/// First component of the vector. /// First component of the vector.
x: N, x: N,
@ -215,7 +215,7 @@ rotate_impl!(Vec2)
transform_impl!(Vec2) transform_impl!(Vec2)
/// Vector of dimension 3. /// Vector of dimension 3.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Hash, Rand, Zero, Show, ToStr)]
pub struct Vec3<N> { pub struct Vec3<N> {
/// First component of the vector. /// First component of the vector.
x: N, x: N,
@ -319,7 +319,7 @@ transform_impl!(Vec3)
/// Vector of dimension 4. /// Vector of dimension 4.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Hash, Rand, Zero, Show, ToStr)]
pub struct Vec4<N> { pub struct Vec4<N> {
/// First component of the vector. /// First component of the vector.
x: N, x: N,
@ -421,7 +421,7 @@ rotate_impl!(Vec4)
transform_impl!(Vec4) transform_impl!(Vec4)
/// Vector of dimension 5. /// Vector of dimension 5.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Hash, Rand, Zero, Show, ToStr)]
pub struct Vec5<N> { pub struct Vec5<N> {
/// First component of the vector. /// First component of the vector.
x: N, x: N,
@ -525,7 +525,7 @@ rotate_impl!(Vec5)
transform_impl!(Vec5) transform_impl!(Vec5)
/// Vector of dimension 6. /// Vector of dimension 6.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Hash, Rand, Zero, Show, ToStr)]
pub struct Vec6<N> { pub struct Vec6<N> {
/// First component of the vector. /// First component of the vector.
x: N, x: N,

View File

@ -4,7 +4,7 @@ use std::cmp;
/// Result of a partial ordering. /// Result of a partial ordering.
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, ToStr, Show)] #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Show, ToStr)]
pub enum PartialOrdering { pub enum PartialOrdering {
/// Result of a strict comparison. /// Result of a strict comparison.
Less, Less,