makes rustc-serialize optional
This commit is contained in:
parent
a7f4aa1756
commit
f3673a1d4c
11 changed files with 44 additions and 22 deletions
|
@ -28,11 +28,12 @@ name = "cgmath"
|
|||
|
||||
[features]
|
||||
unstable = []
|
||||
default = ["rustc-serialize"]
|
||||
|
||||
[dependencies]
|
||||
num-traits = "0.1"
|
||||
rand = "0.3"
|
||||
rustc-serialize = "0.3"
|
||||
rustc-serialize = { version = "0.3", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
glium = "0.14.0"
|
||||
|
|
|
@ -32,14 +32,16 @@ use num::BaseFloat;
|
|||
///
|
||||
/// This type is marked as `#[repr(C, packed)]`.
|
||||
#[repr(C, packed)]
|
||||
#[derive(Copy, Clone, PartialEq, PartialOrd, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Copy, Clone, PartialEq, PartialOrd)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Rad<S> { pub s: S }
|
||||
|
||||
/// An angle, in degrees.
|
||||
///
|
||||
/// This type is marked as `#[repr(C, packed)]`.
|
||||
#[repr(C, packed)]
|
||||
#[derive(Copy, Clone, PartialEq, PartialOrd, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Copy, Clone, PartialEq, PartialOrd)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Deg<S> { pub s: S }
|
||||
|
||||
/// Create a new angle, in radians
|
||||
|
|
|
@ -64,7 +64,7 @@ use num::BaseFloat;
|
|||
#[repr(C, packed)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[derive(PartialEq, Eq)]
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Euler<A: Angle> {
|
||||
/// The angle to apply around the _x_ axis. Also known at the _pitch_.
|
||||
pub x: A,
|
||||
|
|
|
@ -51,9 +51,11 @@
|
|||
//! ```
|
||||
|
||||
pub extern crate num_traits;
|
||||
extern crate rustc_serialize;
|
||||
extern crate rand;
|
||||
|
||||
#[cfg(feature = "rustc-serialize")]
|
||||
extern crate rustc_serialize;
|
||||
|
||||
// Re-exports
|
||||
|
||||
pub use approx::*;
|
||||
|
|
|
@ -35,7 +35,8 @@ use vector::{Vector2, Vector3, Vector4};
|
|||
///
|
||||
/// This type is marked as `#[repr(C, packed)]`.
|
||||
#[repr(C, packed)]
|
||||
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Matrix2<S> {
|
||||
/// The first column of the matrix.
|
||||
pub x: Vector2<S>,
|
||||
|
@ -47,7 +48,8 @@ pub struct Matrix2<S> {
|
|||
///
|
||||
/// This type is marked as `#[repr(C, packed)]`.
|
||||
#[repr(C, packed)]
|
||||
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Matrix3<S> {
|
||||
/// The first column of the matrix.
|
||||
pub x: Vector3<S>,
|
||||
|
@ -61,7 +63,8 @@ pub struct Matrix3<S> {
|
|||
///
|
||||
/// This type is marked as `#[repr(C, packed)]`.
|
||||
#[repr(C, packed)]
|
||||
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Matrix4<S> {
|
||||
/// The first column of the matrix.
|
||||
pub x: Vector4<S>,
|
||||
|
|
|
@ -31,7 +31,8 @@ use vector::{Vector1, Vector2, Vector3, Vector4};
|
|||
///
|
||||
/// This type is marked as `#[repr(C, packed)]`.
|
||||
#[repr(C, packed)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Point1<S> {
|
||||
pub x: S,
|
||||
}
|
||||
|
@ -40,7 +41,8 @@ pub struct Point1<S> {
|
|||
///
|
||||
/// This type is marked as `#[repr(C, packed)]`.
|
||||
#[repr(C, packed)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Point2<S> {
|
||||
pub x: S,
|
||||
pub y: S,
|
||||
|
@ -50,7 +52,8 @@ pub struct Point2<S> {
|
|||
///
|
||||
/// This type is marked as `#[repr(C, packed)]`.
|
||||
#[repr(C, packed)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Point3<S> {
|
||||
pub x: S,
|
||||
pub y: S,
|
||||
|
|
|
@ -66,7 +66,8 @@ pub fn ortho<S: BaseFloat>(left: S, right: S, bottom: S, top: S, near: S, far: S
|
|||
}
|
||||
|
||||
/// A perspective projection based on a vertical field-of-view angle.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct PerspectiveFov<S> {
|
||||
pub fovy: Rad<S>,
|
||||
pub aspect: S,
|
||||
|
@ -132,7 +133,8 @@ impl<S: BaseFloat> From<PerspectiveFov<S>> for Matrix4<S> {
|
|||
}
|
||||
|
||||
/// A perspective projection with arbitrary left/right/bottom/top distances
|
||||
#[derive(Copy, Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Perspective<S> {
|
||||
pub left: S,
|
||||
pub right: S,
|
||||
|
@ -178,7 +180,8 @@ impl<S: BaseFloat> From<Perspective<S>> for Matrix4<S> {
|
|||
}
|
||||
|
||||
/// An orthographic projection with arbitrary left/right/bottom/top distances
|
||||
#[derive(Copy, Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Ortho<S> {
|
||||
pub left: S,
|
||||
pub right: S,
|
||||
|
|
|
@ -36,7 +36,8 @@ use vector::Vector3;
|
|||
///
|
||||
/// This type is marked as `#[repr(C, packed)]`.
|
||||
#[repr(C, packed)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Quaternion<S> {
|
||||
/// The scalar part of the quaternion.
|
||||
pub s: S,
|
||||
|
|
|
@ -137,7 +137,8 @@ pub trait Rotation3<S: BaseFloat>: Rotation<Point3<S>>
|
|||
/// let unit_y3 = (rot_half * rot_half).rotate_vector(unit_x);
|
||||
/// assert!(unit_y3.approx_eq(&unit_y2));
|
||||
/// ```
|
||||
#[derive(PartialEq, Copy, Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(PartialEq, Copy, Clone)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Basis2<S> {
|
||||
mat: Matrix2<S>
|
||||
}
|
||||
|
@ -209,7 +210,8 @@ impl<S: fmt::Debug> fmt::Debug 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`.
|
||||
#[derive(PartialEq, Copy, Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(PartialEq, Copy, Clone)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Basis3<S> {
|
||||
mat: Matrix3<S>
|
||||
}
|
||||
|
|
|
@ -56,7 +56,8 @@ pub trait Transform<P: EuclideanSpace>: Sized {
|
|||
|
||||
/// A generic transformation consisting of a rotation,
|
||||
/// displacement vector and scale amount.
|
||||
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Decomposed<V: VectorSpace, R> {
|
||||
pub scale: V::Scalar,
|
||||
pub rot: R,
|
||||
|
|
|
@ -29,7 +29,8 @@ use num::{BaseNum, BaseFloat, PartialOrd};
|
|||
///
|
||||
/// This type is marked as `#[repr(C, packed)]`.
|
||||
#[repr(C, packed)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Vector1<S> {
|
||||
/// The x component of the vector.
|
||||
pub x: S,
|
||||
|
@ -39,7 +40,8 @@ pub struct Vector1<S> {
|
|||
///
|
||||
/// This type is marked as `#[repr(C, packed)]`.
|
||||
#[repr(C, packed)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Vector2<S> {
|
||||
/// The x component of the vector.
|
||||
pub x: S,
|
||||
|
@ -51,7 +53,8 @@ pub struct Vector2<S> {
|
|||
///
|
||||
/// This type is marked as `#[repr(C, packed)]`.
|
||||
#[repr(C, packed)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Vector3<S> {
|
||||
/// The x component of the vector.
|
||||
pub x: S,
|
||||
|
@ -65,7 +68,8 @@ pub struct Vector3<S> {
|
|||
///
|
||||
/// This type is marked as `#[repr(C, packed)]`.
|
||||
#[repr(C, packed)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||
pub struct Vector4<S> {
|
||||
/// The x component of the vector.
|
||||
pub x: S,
|
||||
|
|
Loading…
Reference in a new issue