Refined serde dependencies

This commit is contained in:
Dzmitry Malyshau 2017-06-06 16:48:55 -04:00
parent 087336d0c0
commit 7a21125c55
13 changed files with 30 additions and 34 deletions

View file

@ -9,14 +9,14 @@ cache: cargo
env:
- CARGO_FEATURES=""
- CARGO_FEATURES="eders"
- CARGO_FEATURES="serde"
matrix:
include:
- rust: nightly
env: CARGO_FEATURES="simd"
- rust: nightly
env: CARGO_FEATURES="eders simd"
env: CARGO_FEATURES="serde simd"
script:
- cargo build --features "$CARGO_FEATURES"

View file

@ -1,7 +1,7 @@
[package]
name = "cgmath"
version = "0.14.1"
version = "0.15.0"
authors = ["Brendan Zabarauskas <bjzaba@yahoo.com.au>"]
license = "Apache-2.0"
description = "A linear algebra and mathematics library for computer graphics."
@ -18,14 +18,12 @@ name = "cgmath"
[features]
unstable = []
eders = ["serde", "serde_derive"]
[dependencies]
approx = "0.1"
num-traits = "0.1"
rand = "0.3"
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
serde = { version = "1.0", features = ["serde_derive"], optional = true }
simd = { version = "0.2", optional = true }
[dev-dependencies]

View file

@ -34,7 +34,7 @@ use num::BaseFloat;
/// This type is marked as `#[repr(C)]`.
#[repr(C)]
#[derive(Copy, Clone, PartialEq, PartialOrd)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Rad<S>(pub S);
/// An angle, in degrees.
@ -42,7 +42,7 @@ pub struct Rad<S>(pub S);
/// This type is marked as `#[repr(C)]`.
#[repr(C)]
#[derive(Copy, Clone, PartialEq, PartialOrd)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Deg<S>(pub S);
impl<S> From<Rad<S>> for Deg<S> where S: BaseFloat {

View file

@ -75,7 +75,7 @@ use num::BaseFloat;
#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[derive(PartialEq, Eq)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Euler<A: Angle> {
/// The angle to apply around the _x_ axis. Also known at the _pitch_.
pub x: A,

View file

@ -57,10 +57,8 @@ extern crate approx;
pub extern crate num_traits;
extern crate rand;
#[cfg(feature = "eders")]
#[cfg(feature = "serde")]
#[macro_use]
extern crate serde_derive;
#[cfg(feature = "eders")]
extern crate serde;
#[cfg(feature = "simd")]

View file

@ -37,7 +37,7 @@ use vector::{Vector2, Vector3, Vector4};
/// This type is marked as `#[repr(C)]`.
#[repr(C)]
#[derive(Copy, Clone, PartialEq)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Matrix2<S> {
/// The first column of the matrix.
pub x: Vector2<S>,
@ -50,7 +50,7 @@ pub struct Matrix2<S> {
/// This type is marked as `#[repr(C)]`.
#[repr(C)]
#[derive(Copy, Clone, PartialEq)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Matrix3<S> {
/// The first column of the matrix.
pub x: Vector3<S>,
@ -65,7 +65,7 @@ pub struct Matrix3<S> {
/// This type is marked as `#[repr(C)]`.
#[repr(C)]
#[derive(Copy, Clone, PartialEq)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Matrix4<S> {
/// The first column of the matrix.
pub x: Vector4<S>,

View file

@ -33,7 +33,7 @@ use vector::{Vector1, Vector2, Vector3, Vector4};
/// This type is marked as `#[repr(C)]`.
#[repr(C)]
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Point1<S> {
pub x: S,
}
@ -43,7 +43,7 @@ pub struct Point1<S> {
/// This type is marked as `#[repr(C)]`.
#[repr(C)]
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Point2<S> {
pub x: S,
pub y: S,
@ -54,7 +54,7 @@ pub struct Point2<S> {
/// This type is marked as `#[repr(C)]`.
#[repr(C)]
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Point3<S> {
pub x: S,
pub y: S,

View file

@ -68,7 +68,7 @@ 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)]
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PerspectiveFov<S> {
pub fovy: Rad<S>,
pub aspect: S,
@ -135,7 +135,7 @@ impl<S: BaseFloat> From<PerspectiveFov<S>> for Matrix4<S> {
/// A perspective projection with arbitrary left/right/bottom/top distances
#[derive(Copy, Clone, Debug, PartialEq)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Perspective<S> {
pub left: S,
pub right: S,
@ -182,7 +182,7 @@ impl<S: BaseFloat> From<Perspective<S>> for Matrix4<S> {
/// An orthographic projection with arbitrary left/right/bottom/top distances
#[derive(Copy, Clone, Debug, PartialEq)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Ortho<S> {
pub left: S,
pub right: S,

View file

@ -40,7 +40,7 @@ use simd::f32x4 as Simdf32x4;
/// This type is marked as `#[repr(C)]`.
#[repr(C)]
#[derive(Copy, Clone, Debug, PartialEq)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Quaternion<S> {
/// The scalar part of the quaternion.
pub s: S,

View file

@ -142,7 +142,7 @@ pub trait Rotation3<S: BaseFloat>: Rotation<Point3<S>>
/// // assert_ulps_eq!(&unit_y3, &unit_y2); // TODO: Figure out how to use this
/// ```
#[derive(PartialEq, Copy, Clone)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Basis2<S> {
mat: Matrix2<S>
}
@ -249,7 +249,7 @@ impl<S: fmt::Debug> fmt::Debug for Basis2<S> {
/// `math::Matrix3`. To ensure orthogonality is maintained, the operations have
/// been restricted to a subset of those implemented on `Matrix3`.
#[derive(PartialEq, Copy, Clone)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Basis3<S> {
mat: Matrix3<S>
}

View file

@ -184,9 +184,9 @@ impl<S: VectorSpace, R, E: BaseFloat> ApproxEq for Decomposed<S, R>
}
}
#[cfg(feature = "eders")]
#[cfg(feature = "serde")]
#[doc(hidden)]
mod eders_ser {
mod serde_ser {
use structure::VectorSpace;
use super::Decomposed;
use serde::{self, Serialize};
@ -209,9 +209,9 @@ mod eders_ser {
}
}
#[cfg(feature = "eders")]
#[cfg(feature = "serde")]
#[doc(hidden)]
mod eders_de {
mod serde_de {
use structure::VectorSpace;
use super::Decomposed;
use serde::{self, Deserialize};

View file

@ -38,7 +38,7 @@ use simd::u32x4 as Simdu32x4;
/// This type is marked as `#[repr(C)]`.
#[repr(C)]
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Vector1<S> {
/// The x component of the vector.
pub x: S,
@ -49,7 +49,7 @@ pub struct Vector1<S> {
/// This type is marked as `#[repr(C)]`.
#[repr(C)]
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Vector2<S> {
/// The x component of the vector.
pub x: S,
@ -62,7 +62,7 @@ pub struct Vector2<S> {
/// This type is marked as `#[repr(C)]`.
#[repr(C)]
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Vector3<S> {
/// The x component of the vector.
pub x: S,
@ -77,7 +77,7 @@ pub struct Vector3<S> {
/// This type is marked as `#[repr(C)]`.
#[repr(C)]
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Vector4<S> {
/// The x component of the vector.
pub x: S,

View file

@ -17,7 +17,7 @@
extern crate approx;
extern crate cgmath;
#[cfg(feature = "eders")]
#[cfg(feature = "serde")]
extern crate serde_json;
use cgmath::*;
@ -46,7 +46,7 @@ fn test_look_at() {
assert_ulps_eq!(&t.transform_point(point), &view_point);
}
#[cfg(feature = "eders")]
#[cfg(feature = "serde")]
#[test]
fn test_serialize() {
let t = Decomposed {