From f3e680fc34c4b5b515879baed793f6bb7539816f Mon Sep 17 00:00:00 2001 From: Rich Lane Date: Sun, 26 Jan 2014 13:39:57 -0800 Subject: [PATCH] derive IterBytes for vectors, points, and angles It's useful to be able to have types like `Vec3` as hashtable keys. --- src/cgmath/angle.rs | 4 ++-- src/cgmath/point.rs | 4 ++-- src/cgmath/vector.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cgmath/angle.rs b/src/cgmath/angle.rs index 637c408..dbea325 100644 --- a/src/cgmath/angle.rs +++ b/src/cgmath/angle.rs @@ -23,8 +23,8 @@ use std::num::{One, one, Zero, zero, cast}; use approx::ApproxEq; -#[deriving(Clone, Eq, Ord)] pub struct Rad { s: S } -#[deriving(Clone, Eq, Ord)] pub struct Deg { s: S } +#[deriving(Clone, Eq, Ord, IterBytes)] pub struct Rad { s: S } +#[deriving(Clone, Eq, Ord, IterBytes)] pub struct Deg { s: S } #[inline] pub fn rad(s: S) -> Rad { Rad { s: s } } #[inline] pub fn deg(s: S) -> Deg { Deg { s: s } } diff --git a/src/cgmath/point.rs b/src/cgmath/point.rs index 193a1ed..aa0a905 100644 --- a/src/cgmath/point.rs +++ b/src/cgmath/point.rs @@ -24,11 +24,11 @@ use array::*; use vector::*; /// A point in 2-dimensional space. -#[deriving(Eq, Clone)] +#[deriving(Eq, Clone, IterBytes)] pub struct Point2 { x: S, y: S } /// A point in 3-dimensional space. -#[deriving(Eq, Clone)] +#[deriving(Eq, Clone, IterBytes)] pub struct Point3 { x: S, y: S, z: S } diff --git a/src/cgmath/vector.rs b/src/cgmath/vector.rs index 59c5aa0..dadcb09 100644 --- a/src/cgmath/vector.rs +++ b/src/cgmath/vector.rs @@ -79,7 +79,7 @@ pub trait Vector // Utility macro for generating associated functions for the vectors macro_rules! vec( ($Self:ident <$S:ident> { $($field:ident),+ }, $n:expr) => ( - #[deriving(Eq, Clone)] + #[deriving(Eq, Clone, IterBytes)] pub struct $Self { $($field: S),+ } impl<$S: Primitive> $Self<$S> {