diff --git a/.travis.yml b/.travis.yml index c04c746..99d2910 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,14 +9,14 @@ cache: cargo env: - CARGO_FEATURES="" - - CARGO_FEATURES="eders" + - CARGO_FEATURES="serde" matrix: include: - rust: nightly - env: CARGO_FEATURES="use_simd" + env: CARGO_FEATURES="simd" - rust: nightly - env: CARGO_FEATURES="eders use_simd" + env: CARGO_FEATURES="serde simd" script: - cargo build --features "$CARGO_FEATURES" diff --git a/CHANGELOG.md b/CHANGELOG.md index f5a89c1..45bc5e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +- Refactored `simd` and `serde` dependencies to match feature names + ## [v0.14.1] - 2017-05-02 ### Fixed diff --git a/Cargo.toml b/Cargo.toml index c16905b..9ae5550 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "cgmath" -version = "0.14.1" +version = "0.15.0" authors = ["Brendan Zabarauskas "] license = "Apache-2.0" description = "A linear algebra and mathematics library for computer graphics." @@ -18,15 +18,12 @@ name = "cgmath" [features] unstable = [] -eders = ["serde", "serde_derive"] -use_simd = ["simd"] [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] diff --git a/src/angle.rs b/src/angle.rs index fd02f61..922ee24 100644 --- a/src/angle.rs +++ b/src/angle.rs @@ -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(pub S); /// An angle, in degrees. @@ -42,7 +42,7 @@ pub struct Rad(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(pub S); impl From> for Deg where S: BaseFloat { diff --git a/src/euler.rs b/src/euler.rs index 8c8bfaa..5fd83e2 100644 --- a/src/euler.rs +++ b/src/euler.rs @@ -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 { /// The angle to apply around the _x_ axis. Also known at the _pitch_. pub x: A, diff --git a/src/lib.rs b/src/lib.rs index 9262a8c..a9b1b0d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,20 +50,18 @@ //! use cgmath::prelude::*; //! ``` -#![cfg_attr(feature = "use_simd", feature(specialization))] +#![cfg_attr(feature = "simd", feature(specialization))] #[macro_use] 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 = "use_simd")] +#[cfg(feature = "simd")] extern crate simd; // Re-exports diff --git a/src/macros.rs b/src/macros.rs index e1fa8c6..10e39d3 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -255,7 +255,7 @@ macro_rules! impl_index_operators { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] macro_rules! impl_operator_default { // When it is an unary operator (<$S:ident: $Constraint:ident> $Op:ident for $Lhs:ty { @@ -355,7 +355,7 @@ macro_rules! impl_operator_default { }; } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] macro_rules! impl_assignment_operator_default { (<$S:ident: $Constraint:ident> $Op:ident<$Rhs:ty> for $Lhs:ty { fn $op:ident(&mut $lhs:ident, $rhs:ident) $body:block @@ -368,13 +368,13 @@ macro_rules! impl_assignment_operator_default { } /// Generates a binary operator implementation for the permutations of by-ref and by-val, for simd -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] macro_rules! impl_operator_simd { // When it is an unary operator ([$Simd:ident]; $Op:ident for $Lhs:ty { fn $op:ident($x:ident) -> $Output:ty { $body:expr } }) => { - + impl $Op for $Lhs { #[inline] fn $op(self) -> $Output { @@ -393,7 +393,7 @@ macro_rules! impl_operator_simd { } } - + impl<'a> $Op<$Rhs> for &'a $Lhs { #[inline] fn $op(self, other: $Rhs) -> $Output { @@ -406,7 +406,7 @@ macro_rules! impl_operator_simd { ([$Simd:ident]; $Op:ident<$Rhs:ty> for $Lhs:ty { fn $op:ident($lhs:ident, $rhs:ident) -> $Output:ty { $body:expr } }) => { - + impl $Op<$Rhs> for $Lhs { #[inline] fn $op(self, other: $Rhs) -> $Output { @@ -414,14 +414,14 @@ macro_rules! impl_operator_simd { } } - + impl<'a> $Op<&'a $Rhs> for $Lhs { #[inline] fn $op(self, other: &'a $Rhs) -> $Output { let ($lhs, $rhs): ($Simd, $Simd) = (self.into(), (*other).into()); $body } } - + impl<'a> $Op<$Rhs> for &'a $Lhs { #[inline] fn $op(self, other: $Rhs) -> $Output { @@ -447,7 +447,7 @@ macro_rules! impl_operator_simd { let ($lhs, $rhs): ($Simd, $Simd) = ($Simd::splat(self), other.into()); $body } } - + impl<'a> $Op<&'a $Rhs> for $Lhs { #[inline] fn $op(self, other: &'a $Rhs) -> $Output { diff --git a/src/matrix.rs b/src/matrix.rs index a227f2d..713edca 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -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 { /// The first column of the matrix. pub x: Vector2, @@ -50,7 +50,7 @@ pub struct Matrix2 { /// 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 { /// The first column of the matrix. pub x: Vector3, @@ -65,7 +65,7 @@ pub struct Matrix3 { /// 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 { /// The first column of the matrix. pub x: Vector4, @@ -666,7 +666,7 @@ impl SquareMatrix for Matrix4 { // A better option would be using specialization. But currently somewhat // specialization is too buggy, and it won't apply here. I'm getting // weird error msgs. Help wanted. - #[cfg(not(feature = "use_simd"))] + #[cfg(not(feature = "simd"))] fn invert(&self) -> Option> { let det = self.determinant(); if det == S::zero() { @@ -692,7 +692,7 @@ impl SquareMatrix for Matrix4 { cf(3, 0), cf(3, 1), cf(3, 2), cf(3, 3))) } } - #[cfg(feature = "use_simd")] + #[cfg(feature = "simd")] fn invert(&self) -> Option> { let tmp0 = unsafe { det_sub_proc_unsafe(self, 1, 2, 3) @@ -1057,9 +1057,9 @@ macro_rules! impl_mv_operator { impl_mv_operator!(Matrix2, Vector2 { x: 0, y: 1 }); impl_mv_operator!(Matrix3, Vector3 { x: 0, y: 1, z: 2 }); -#[cfg(not(feature = "use_simd"))] +#[cfg(not(feature = "simd"))] impl_mv_operator!(Matrix4, Vector4 { x: 0, y: 1, z: 2, w: 3 }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator!( Mul > for Matrix4 { fn mul(matrix, vector) -> Vector4 { matrix[0] * vector[0] + matrix[1] * vector[1] + matrix[2] * vector[2] + matrix[3] * vector[3] diff --git a/src/point.rs b/src/point.rs index 8fdb58e..8b08d59 100644 --- a/src/point.rs +++ b/src/point.rs @@ -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 { pub x: S, } @@ -43,7 +43,7 @@ pub struct Point1 { /// 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 { pub x: S, pub y: S, @@ -54,7 +54,7 @@ pub struct Point2 { /// 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 { pub x: S, pub y: S, diff --git a/src/projection.rs b/src/projection.rs index ad24e83..d30a189 100644 --- a/src/projection.rs +++ b/src/projection.rs @@ -68,7 +68,7 @@ pub fn ortho(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 { pub fovy: Rad, pub aspect: S, @@ -135,7 +135,7 @@ impl From> for Matrix4 { /// 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 { pub left: S, pub right: S, @@ -182,7 +182,7 @@ impl From> for Matrix4 { /// 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 { pub left: S, pub right: S, diff --git a/src/quaternion.rs b/src/quaternion.rs index af00103..599756d 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -31,7 +31,7 @@ use point::Point3; use rotation::{Rotation, Rotation3, Basis3}; use vector::Vector3; -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] use simd::f32x4 as Simdf32x4; /// A [quaternion](https://en.wikipedia.org/wiki/Quaternion) in scalar/vector @@ -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 { /// The scalar part of the quaternion. pub s: S, @@ -48,7 +48,7 @@ pub struct Quaternion { pub v: Vector3, } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl From for Quaternion { #[inline] fn from(f: Simdf32x4) -> Self { @@ -63,7 +63,7 @@ impl From for Quaternion { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl Into for Quaternion { #[inline] fn into(self) -> Simdf32x4 { @@ -229,7 +229,7 @@ impl MetricSpace for Quaternion { } } -#[cfg(not(feature = "use_simd"))] +#[cfg(not(feature = "simd"))] impl InnerSpace for Quaternion { #[inline] fn dot(self, other: Quaternion) -> S { @@ -237,7 +237,7 @@ impl InnerSpace for Quaternion { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl InnerSpace for Quaternion { #[inline] default fn dot(self, other: Quaternion) -> S { @@ -245,7 +245,7 @@ impl InnerSpace for Quaternion { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl InnerSpace for Quaternion { #[inline] fn dot(self, other: Quaternion) -> f32 { @@ -277,21 +277,21 @@ impl From> for Quaternion where } } -#[cfg(not(feature = "use_simd"))] +#[cfg(not(feature = "simd"))] impl_operator!( Neg for Quaternion { fn neg(quat) -> Quaternion { Quaternion::from_sv(-quat.s, -quat.v) } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_default!( Neg for Quaternion { fn neg(quat) -> Quaternion { Quaternion::from_sv(-quat.s, -quat.v) } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{ [Simdf32x4]; Neg for Quaternion { fn neg(lhs) -> Quaternion { @@ -300,21 +300,21 @@ impl_operator_simd!{ } } -#[cfg(not(feature = "use_simd"))] +#[cfg(not(feature = "simd"))] impl_operator!( Mul for Quaternion { fn mul(lhs, rhs) -> Quaternion { Quaternion::from_sv(lhs.s * rhs, lhs.v * rhs) } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_default!( Mul for Quaternion { fn mul(lhs, rhs) -> Quaternion { Quaternion::from_sv(lhs.s * rhs, lhs.v * rhs) } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{@rs [Simdf32x4]; Mul for Quaternion { fn mul(lhs, rhs) -> Quaternion { @@ -323,17 +323,17 @@ impl_operator_simd!{@rs } } -#[cfg(not(feature = "use_simd"))] +#[cfg(not(feature = "simd"))] impl_assignment_operator!( MulAssign for Quaternion { fn mul_assign(&mut self, scalar) { self.s *= scalar; self.v *= scalar; } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_assignment_operator_default!( MulAssign for Quaternion { fn mul_assign(&mut self, scalar) { self.s *= scalar; self.v *= scalar; } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl MulAssign for Quaternion { fn mul_assign(&mut self, other: f32) { let s: Simdf32x4 = (*self).into(); @@ -342,21 +342,21 @@ impl MulAssign for Quaternion { } } -#[cfg(not(feature = "use_simd"))] +#[cfg(not(feature = "simd"))] impl_operator!( Div for Quaternion { fn div(lhs, rhs) -> Quaternion { Quaternion::from_sv(lhs.s / rhs, lhs.v / rhs) } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_default!( Div for Quaternion { fn div(lhs, rhs) -> Quaternion { Quaternion::from_sv(lhs.s / rhs, lhs.v / rhs) } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{@rs [Simdf32x4]; Div for Quaternion { fn div(lhs, rhs) -> Quaternion { @@ -365,17 +365,17 @@ impl_operator_simd!{@rs } } -#[cfg(not(feature = "use_simd"))] +#[cfg(not(feature = "simd"))] impl_assignment_operator!( DivAssign for Quaternion { fn div_assign(&mut self, scalar) { self.s /= scalar; self.v /= scalar; } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_assignment_operator_default!( DivAssign for Quaternion { fn div_assign(&mut self, scalar) { self.s /= scalar; self.v /= scalar; } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl DivAssign for Quaternion { fn div_assign(&mut self, other: f32) { let s: Simdf32x4 = (*self).into(); @@ -403,21 +403,21 @@ impl_operator!( Mul > for Quaternion { }} }); -#[cfg(not(feature = "use_simd"))] +#[cfg(not(feature = "simd"))] impl_operator!( Add > for Quaternion { fn add(lhs, rhs) -> Quaternion { Quaternion::from_sv(lhs.s + rhs.s, lhs.v + rhs.v) } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_default!( Add > for Quaternion { fn add(lhs, rhs) -> Quaternion { Quaternion::from_sv(lhs.s + rhs.s, lhs.v + rhs.v) } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{ [Simdf32x4]; Add> for Quaternion { fn add(lhs, rhs) -> Quaternion { @@ -426,17 +426,17 @@ impl_operator_simd!{ } } -#[cfg(not(feature = "use_simd"))] +#[cfg(not(feature = "simd"))] impl_assignment_operator!( AddAssign > for Quaternion { fn add_assign(&mut self, other) { self.s += other.s; self.v += other.v; } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_assignment_operator_default!( AddAssign > for Quaternion { fn add_assign(&mut self, other) { self.s += other.s; self.v += other.v; } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl AddAssign for Quaternion { #[inline] fn add_assign(&mut self, rhs: Self) { @@ -446,21 +446,21 @@ impl AddAssign for Quaternion { } } -#[cfg(not(feature = "use_simd"))] +#[cfg(not(feature = "simd"))] impl_operator!( Sub > for Quaternion { fn sub(lhs, rhs) -> Quaternion { Quaternion::from_sv(lhs.s - rhs.s, lhs.v - rhs.v) } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_default!( Sub > for Quaternion { fn sub(lhs, rhs) -> Quaternion { Quaternion::from_sv(lhs.s - rhs.s, lhs.v - rhs.v) } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{ [Simdf32x4]; Sub> for Quaternion { fn sub(lhs, rhs) -> Quaternion { @@ -469,17 +469,17 @@ impl_operator_simd!{ } } -#[cfg(not(feature = "use_simd"))] +#[cfg(not(feature = "simd"))] impl_assignment_operator!( SubAssign > for Quaternion { fn sub_assign(&mut self, other) { self.s -= other.s; self.v -= other.v; } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_assignment_operator_default!( SubAssign > for Quaternion { fn sub_assign(&mut self, other) { self.s -= other.s; self.v -= other.v; } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl SubAssign for Quaternion { #[inline] fn sub_assign(&mut self, rhs: Self) { @@ -489,7 +489,7 @@ impl SubAssign for Quaternion { } } -#[cfg(not(feature = "use_simd"))] +#[cfg(not(feature = "simd"))] impl_operator!( Mul > for Quaternion { fn mul(lhs, rhs) -> Quaternion { Quaternion::new(lhs.s * rhs.s - lhs.v.x * rhs.v.x - lhs.v.y * rhs.v.y - lhs.v.z * rhs.v.z, @@ -499,7 +499,7 @@ impl_operator!( Mul > for Quaternion { } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_default!( Mul > for Quaternion { fn mul(lhs, rhs) -> Quaternion { Quaternion::new(lhs.s * rhs.s - lhs.v.x * rhs.v.x - lhs.v.y * rhs.v.y - lhs.v.z * rhs.v.z, @@ -509,7 +509,7 @@ impl_operator_default!( Mul > for Quaternion { } }); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{ [Simdf32x4]; Mul> for Quaternion { fn mul(lhs, rhs) -> Quaternion { diff --git a/src/rotation.rs b/src/rotation.rs index 536323a..9e0fe8a 100644 --- a/src/rotation.rs +++ b/src/rotation.rs @@ -142,7 +142,7 @@ pub trait Rotation3: Rotation> /// // 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 { mat: Matrix2 } @@ -249,7 +249,7 @@ impl fmt::Debug for Basis2 { /// `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 { mat: Matrix3 } diff --git a/src/transform.rs b/src/transform.rs index ddf1c56..f995cc7 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -184,9 +184,9 @@ impl ApproxEq for Decomposed } } -#[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}; diff --git a/src/vector.rs b/src/vector.rs index 544374f..412fc43 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -26,11 +26,11 @@ use angle::Rad; use approx::ApproxEq; use num::{BaseNum, BaseFloat}; -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] use simd::f32x4 as Simdf32x4; -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] use simd::i32x4 as Simdi32x4; -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] use simd::u32x4 as Simdu32x4; /// A 1-dimensional vector. @@ -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 { /// The x component of the vector. pub x: S, @@ -49,7 +49,7 @@ pub struct Vector1 { /// 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 { /// The x component of the vector. pub x: S, @@ -62,7 +62,7 @@ pub struct Vector2 { /// 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 { /// The x component of the vector. pub x: S, @@ -77,7 +77,7 @@ pub struct Vector3 { /// 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 { /// The x component of the vector. pub x: S, @@ -301,7 +301,7 @@ macro_rules! impl_vector { // Utility macro for generating associated functions for the vectors // mainly duplication -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] macro_rules! impl_vector_default { ($VectorN:ident { $($field:ident),+ }, $n:expr, $constructor:ident) => { impl $VectorN { @@ -529,7 +529,7 @@ macro_rules! impl_scalar_ops { }; } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] macro_rules! impl_scalar_ops_default { ($VectorN:ident<$S:ident> { $($field:ident),+ }) => { impl_operator_default!(Mul<$VectorN<$S>> for $S { @@ -547,9 +547,9 @@ macro_rules! impl_scalar_ops_default { impl_vector!(Vector1 { x }, 1, vec1); impl_vector!(Vector2 { x, y }, 2, vec2); impl_vector!(Vector3 { x, y, z }, 3, vec3); -#[cfg(not(feature = "use_simd"))] +#[cfg(not(feature = "simd"))] impl_vector!(Vector4 { x, y, z, w }, 4, vec4); -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_vector_default!(Vector4 { x, y, z, w }, 4, vec4); impl_fixed_array_conversions!(Vector1 { x: 0 }, 1); @@ -757,7 +757,7 @@ impl fmt::Debug for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl From for Vector4 { #[inline] fn from(f: Simdf32x4) -> Self { @@ -772,7 +772,7 @@ impl From for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl Vector4 { /// Compute and return the square root of each element. #[inline] @@ -798,7 +798,7 @@ impl Vector4 { -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl Into for Vector4 { #[inline] fn into(self) -> Simdf32x4 { @@ -807,7 +807,7 @@ impl Into for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{ [Simdf32x4]; Add> for Vector4 { fn add(lhs, rhs) -> Vector4 { @@ -816,7 +816,7 @@ impl_operator_simd!{ } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{ [Simdf32x4]; Sub> for Vector4 { fn sub(lhs, rhs) -> Vector4 { @@ -825,7 +825,7 @@ impl_operator_simd!{ } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{@rs [Simdf32x4]; Mul for Vector4 { fn mul(lhs, rhs) -> Vector4 { @@ -834,7 +834,7 @@ impl_operator_simd!{@rs } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{@rs [Simdf32x4]; Div for Vector4 { fn div(lhs, rhs) -> Vector4 { @@ -845,7 +845,7 @@ impl_operator_simd!{@rs -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{ [Simdf32x4]; Neg for Vector4 { fn neg(lhs) -> Vector4 { @@ -854,7 +854,7 @@ impl_operator_simd!{ } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl AddAssign for Vector4 { #[inline] fn add_assign(&mut self, rhs: Self) { @@ -864,7 +864,7 @@ impl AddAssign for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl SubAssign for Vector4 { #[inline] fn sub_assign(&mut self, rhs: Self) { @@ -874,7 +874,7 @@ impl SubAssign for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl MulAssign for Vector4 { fn mul_assign(&mut self, other: f32) { let s: Simdf32x4 = (*self).into(); @@ -883,7 +883,7 @@ impl MulAssign for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl DivAssign for Vector4 { fn div_assign(&mut self, other: f32) { let s: Simdf32x4 = (*self).into(); @@ -892,7 +892,7 @@ impl DivAssign for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl ElementWise for Vector4 { #[inline] fn add_element_wise(self, rhs: Vector4) -> Vector4 { self + rhs } #[inline] fn sub_element_wise(self, rhs: Vector4) -> Vector4 { self - rhs } @@ -921,7 +921,7 @@ impl ElementWise for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl ElementWise for Vector4 { #[inline] fn add_element_wise(self, rhs: f32) -> Vector4 { let s: Simdf32x4 = self.into(); @@ -950,7 +950,7 @@ impl ElementWise for Vector4 { #[inline] fn div_assign_element_wise(&mut self, rhs: f32) { (*self) /= rhs; } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl From for Vector4 { #[inline] fn from(f: Simdi32x4) -> Self { @@ -965,7 +965,7 @@ impl From for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl Into for Vector4 { #[inline] fn into(self) -> Simdi32x4 { @@ -974,7 +974,7 @@ impl Into for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{ [Simdi32x4]; Add> for Vector4 { fn add(lhs, rhs) -> Vector4 { @@ -983,7 +983,7 @@ impl_operator_simd!{ } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{ [Simdi32x4]; Sub> for Vector4 { fn sub(lhs, rhs) -> Vector4 { @@ -992,7 +992,7 @@ impl_operator_simd!{ } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{@rs [Simdi32x4]; Mul for Vector4 { fn mul(lhs, rhs) -> Vector4 { @@ -1001,7 +1001,7 @@ impl_operator_simd!{@rs } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{ [Simdi32x4]; Neg for Vector4 { fn neg(lhs) -> Vector4 { @@ -1010,7 +1010,7 @@ impl_operator_simd!{ } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl AddAssign for Vector4 { #[inline] fn add_assign(&mut self, rhs: Self) { @@ -1020,7 +1020,7 @@ impl AddAssign for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl SubAssign for Vector4 { #[inline] fn sub_assign(&mut self, rhs: Self) { @@ -1030,7 +1030,7 @@ impl SubAssign for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl MulAssign for Vector4 { fn mul_assign(&mut self, other: i32) { let s: Simdi32x4 = (*self).into(); @@ -1039,7 +1039,7 @@ impl MulAssign for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl From for Vector4 { #[inline] fn from(f: Simdu32x4) -> Self { @@ -1054,7 +1054,7 @@ impl From for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl Into for Vector4 { #[inline] fn into(self) -> Simdu32x4 { @@ -1063,7 +1063,7 @@ impl Into for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{ [Simdu32x4]; Add> for Vector4 { fn add(lhs, rhs) -> Vector4 { @@ -1072,7 +1072,7 @@ impl_operator_simd!{ } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{ [Simdu32x4]; Sub> for Vector4 { fn sub(lhs, rhs) -> Vector4 { @@ -1081,7 +1081,7 @@ impl_operator_simd!{ } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl_operator_simd!{@rs [Simdu32x4]; Mul for Vector4 { fn mul(lhs, rhs) -> Vector4 { @@ -1090,7 +1090,7 @@ impl_operator_simd!{@rs } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl AddAssign for Vector4 { #[inline] fn add_assign(&mut self, rhs: Self) { @@ -1100,7 +1100,7 @@ impl AddAssign for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl SubAssign for Vector4 { #[inline] fn sub_assign(&mut self, rhs: Self) { @@ -1110,7 +1110,7 @@ impl SubAssign for Vector4 { } } -#[cfg(feature = "use_simd")] +#[cfg(feature = "simd")] impl MulAssign for Vector4 { fn mul_assign(&mut self, other: u32) { let s: Simdu32x4 = (*self).into(); diff --git a/tests/transform.rs b/tests/transform.rs index 0c1cfbf..b1362a3 100644 --- a/tests/transform.rs +++ b/tests/transform.rs @@ -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 { diff --git a/tests/vector4f32.rs b/tests/vector4f32.rs index 27c1180..28b07f3 100644 --- a/tests/vector4f32.rs +++ b/tests/vector4f32.rs @@ -146,7 +146,7 @@ mod test_magnitude { assert_eq!(a.magnitude(), a_res); assert_eq!(b.magnitude(), b_res); - #[cfg(feature = "use_simd")] + #[cfg(feature = "simd")] { let a = Vector4::new(1f32, 4f32, 9f32, 16f32); assert_ulps_eq!(a.sqrt_element_wide(), Vector4::new(1f32, 2f32, 3f32, 4f32));