From 778a3c13aaed5530cfb25a05fbba389ff4d3aaf6 Mon Sep 17 00:00:00 2001 From: Colin Sherratt Date: Sun, 8 Feb 2015 13:25:42 -0500 Subject: [PATCH] use the new rand_macros crate --- Cargo.toml | 4 +++- src/angle.rs | 6 ++++-- src/cgmath.rs | 5 ++++- src/matrix.rs | 9 ++++++--- src/quaternion.rs | 3 ++- src/vector.rs | 3 ++- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 53bf6ef..9075aef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,4 +17,6 @@ authors = ["Brendan Zabarauskas ", name = "cgmath" [dependencies] -rustc-serialize="*" \ No newline at end of file +rustc-serialize="*" +rand_macros="*" +rand="*" \ No newline at end of file diff --git a/src/angle.rs b/src/angle.rs index f93768b..9dc3f24 100644 --- a/src/angle.rs +++ b/src/angle.rs @@ -24,10 +24,12 @@ use approx::ApproxEq; use num::{BaseFloat, One, one, Zero, zero}; /// An angle, in radians -#[derive(Copy, Clone, PartialEq, PartialOrd, Hash, RustcEncodable, RustcDecodable, Rand)] +#[derive_Rand] +#[derive(Copy, Clone, PartialEq, PartialOrd, Hash, RustcEncodable, RustcDecodable)] pub struct Rad { pub s: S } /// An angle, in degrees -#[derive(Copy, Clone, PartialEq, PartialOrd, Hash, RustcEncodable, RustcDecodable, Rand)] +#[derive_Rand] +#[derive(Copy, Clone, PartialEq, PartialOrd, Hash, RustcEncodable, RustcDecodable)] pub struct Deg { pub s: S } /// Create a new angle, in radians diff --git a/src/cgmath.rs b/src/cgmath.rs index 351eb13..6009a7f 100644 --- a/src/cgmath.rs +++ b/src/cgmath.rs @@ -15,7 +15,7 @@ #![crate_type = "rlib"] #![crate_type = "dylib"] -#![feature(old_impl_check)] +#![feature(old_impl_check, plugin)] //! Computer graphics-centric math. //! @@ -32,6 +32,9 @@ //! These are provided for convenience. extern crate "rustc-serialize" as rustc_serialize; +extern crate rand; +#[plugin] +extern crate rand_macros; // Re-exports diff --git a/src/matrix.rs b/src/matrix.rs index 8f4fda1..e015b04 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -30,15 +30,18 @@ use vector::{Vector, EuclideanVector}; use vector::{Vector2, Vector3, Vector4}; /// A 2 x 2, column major matrix -#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)] +#[derive_Rand] +#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Matrix2 { pub x: Vector2, pub y: Vector2 } /// A 3 x 3, column major matrix -#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)] +#[derive_Rand] +#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Matrix3 { pub x: Vector3, pub y: Vector3, pub z: Vector3 } /// A 4 x 4, column major matrix -#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)] +#[derive_Rand] +#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Matrix4 { pub x: Vector4, pub y: Vector4, pub z: Vector4, pub w: Vector4 } diff --git a/src/quaternion.rs b/src/quaternion.rs index 454a56e..3267a66 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -30,7 +30,8 @@ use vector::{Vector3, Vector, EuclideanVector}; /// A [quaternion](https://en.wikipedia.org/wiki/Quaternion) in scalar/vector /// form. -#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)] +#[derive_Rand] +#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Quaternion { pub s: S, pub v: Vector3 } /// Represents types which can be expressed as a quaternion. diff --git a/src/vector.rs b/src/vector.rs index 2176675..e003c87 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -178,7 +178,8 @@ pub trait Vector: Array1 + Zero + One + Neg { // Utility macro for generating associated functions for the vectors macro_rules! vec( ($Self:ident <$S:ident> { $($field:ident),+ }, $n:expr, $constructor:ident) => ( - #[derive(PartialEq, Eq, Copy, Clone, Hash, RustcEncodable, RustcDecodable, Rand)] + #[derive_Rand] + #[derive(PartialEq, Eq, Copy, Clone, Hash, RustcEncodable, RustcDecodable)] pub struct $Self { $(pub $field: S),+ } impl<$S> $Self<$S> {