Bug 1519639 - Update euclid. r=jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D16390
This commit is contained in:
Emilio Cobos Álvarez 2019-01-12 16:49:16 +01:00
parent 3870494408
commit f44aa80f85
21 changed files with 731 additions and 231 deletions

30
Cargo.lock generated
View file

@ -877,13 +877,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "euclid"
version = "0.19.4"
version = "0.19.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"euclid_macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "euclid_macros"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.24 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "failure"
version = "0.1.3"
@ -1464,7 +1475,7 @@ version = "0.0.1"
dependencies = [
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
"hashglobe 0.1.0",
"selectors 0.21.0",
"servo_arc 0.1.1",
@ -1926,7 +1937,7 @@ version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -2422,7 +2433,7 @@ dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
"fallible 0.0.1",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"hashglobe 0.1.0",
@ -2480,7 +2491,7 @@ dependencies = [
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
"malloc_size_of 0.0.1",
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.21.0",
@ -3022,7 +3033,7 @@ dependencies = [
"core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_bytes 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3040,7 +3051,7 @@ dependencies = [
"core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3118,7 +3129,7 @@ name = "wr_malloc_size_of"
version = "0.0.1"
dependencies = [
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -3273,7 +3284,8 @@ dependencies = [
"checksum encoding_rs 0.8.14 (registry+https://github.com/rust-lang/crates.io-index)" = "a69d152eaa438a291636c1971b0a370212165ca8a75759eb66818c5ce9b538f7"
"checksum env_logger 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0561146661ae44c579e993456bc76d11ce1e0c7d745e57b2fa7146b6e49fa2ad"
"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3"
"checksum euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)" = "dbbf962bb6f877239a34491f2e0a12c6b824f389bc789eb90f1d70d4780b0727"
"checksum euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a7698bdda3d7444a79d33bdc96e8b518d44ea3ff101d8492a6ca1207b886ea"
"checksum euclid_macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdcb84c18ea5037a1c5a23039b4ff29403abce2e0d6b1daa11cf0bde2b30be15"
"checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7"
"checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596"
"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"

View file

@ -1 +1 @@
{"files":{"COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"67de143fd7f5aa450d230b26c25cabccce0fc3c3512c47ff5d485f0329baeac1","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"625bec69c76ce5423fdd05cfe46922b2680ec517f97c5854ce34798d1d8a9541","src/approxeq.rs":"6594377e8f6c20f88f628520d8de9b9a59c5892a0ee9a6ccd13c8400c1499911","src/homogen.rs":"cb26346ad1ea2797bdc1cac7f532872becabf28a1f9c60792f86ad4a655582f9","src/length.rs":"3171315822707728b1bfbdd04a4190ffb7206b4bfc59e9dd072bb2caa05ff292","src/lib.rs":"f89c2b86cabae4431a956b88c630c5cbdf51f7329dfeb677ab4fd4ff02e7d53b","src/macros.rs":"d2b7b391f58fe9cedb426780cfa1d2771f9ac786a6237b0f89d3e5788f5ec1b7","src/num.rs":"4439479fad5729073e0bfe0b96b547672a237430d48e564519759b9550baa033","src/point.rs":"2c399e282c2e81528775a1fc6ee1a0f2f6f71ed4a14bbe426115ae78b4cf2149","src/rect.rs":"43aad88856645bb9601e076b9ddc3376ee71f59bb8fdb7839a17f0198121824a","src/rotation.rs":"982aaca640215bacc5d2dc60a8949bb2510d5b6d492975b8b6946a7c8f69b496","src/scale.rs":"fc07bcf47f3a1215023c830059f0d270e570cbd37fe8c367ef4a47b191f4ae3e","src/side_offsets.rs":"f114cb881256bbeff2ee2aa305d363e2dea65aa8535140f104f6fa9364bd02f5","src/size.rs":"1fe99377bee13835ca416adbccdb0d163091a3dcf2977c3222da2d6b22d70621","src/transform2d.rs":"2f9bafe40b9a6dd9c41747aabfdefbfc9ee48daf4f4297d2320ccbdac185a30d","src/transform3d.rs":"90decfc535c4b24199cab9614037f27f0cdefad82580fcd6d132f49dfa88f77d","src/translation.rs":"c835abaf167234b288e95323f9e693099be9fd992fc137cd6e692edbe4456f19","src/trig.rs":"97a263c4f178b0332501659ca8143f9f637a0755aca189dd31ac551bcd4cb73c","src/vector.rs":"b0b41eac9c823e05bf6357e69c71dac977db2d8ab27b25f80f1f44b056d15f6d"},"package":"dbbf962bb6f877239a34491f2e0a12c6b824f389bc789eb90f1d70d4780b0727"}
{"files":{"COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"4c50cb6cf03b2ab58cf9c017fdeee3f3d918b6143adeb529910f329bb07e7fd3","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"625bec69c76ce5423fdd05cfe46922b2680ec517f97c5854ce34798d1d8a9541","src/approxeq.rs":"6594377e8f6c20f88f628520d8de9b9a59c5892a0ee9a6ccd13c8400c1499911","src/homogen.rs":"7b02aa671fffcb554557ad790f598bd5d7440dc1aa4a6d1c5a97d8bc3c8f64d6","src/length.rs":"3171315822707728b1bfbdd04a4190ffb7206b4bfc59e9dd072bb2caa05ff292","src/lib.rs":"e8b1317127ec281fd42318f2c470558c2ecbb2e1459cebd4f9c63a2af807eb3d","src/macros.rs":"3b475e84d00cceee6c7e96e9f2c97ba15d8dc7f4094efb82c5ed10bd60d86a64","src/num.rs":"4439479fad5729073e0bfe0b96b547672a237430d48e564519759b9550baa033","src/point.rs":"689a8348428d12f6c5262965c505395bde37b4b1776369d93e93d73406d5344b","src/rect.rs":"ae16bb9ccb95cf329439d0ea4eb4c3821c4cd769cce4a544904b65d7e4af04b7","src/rotation.rs":"3d765a8e8e8c7181cc10d39be617779a8676d2611b408c69c841c3a10ce78a47","src/scale.rs":"fc07bcf47f3a1215023c830059f0d270e570cbd37fe8c367ef4a47b191f4ae3e","src/side_offsets.rs":"b79d43cca4c2e9fac7482a95661f72cb3ed51008f1d3e0c3f4fe608c68ef3658","src/size.rs":"49088bf3bf0e1ce740c1fe92761c18a43a6287d1d81a945bc92b21af63ef3416","src/transform2d.rs":"641acc1c9de9368bdbe0bb64b5ba4c1069ebeda6d6ad31463c81bdf85d678043","src/transform3d.rs":"c47dda0759629c1a836861fabf65e889001cf2d5ab59258544c1c04167cd7a67","src/translation.rs":"9787de1bccdd402774ba9a5bc55ec6d4b2ee36e0a146baecee417ee9cc753db5","src/trig.rs":"97a263c4f178b0332501659ca8143f9f637a0755aca189dd31ac551bcd4cb73c","src/vector.rs":"d57493649da9d8a728dcba49bb80c579a4d2bf6f3557dd4b4c770cfcef6ee395"},"package":"d1a7698bdda3d7444a79d33bdc96e8b518d44ea3ff101d8492a6ca1207b886ea"}

View file

@ -12,7 +12,7 @@
[package]
name = "euclid"
version = "0.19.4"
version = "0.19.5"
authors = ["The Servo Project Developers"]
description = "Geometry primitives"
documentation = "https://docs.rs/euclid/"
@ -20,6 +20,9 @@ keywords = ["matrix", "vector", "linear-algebra", "geometry"]
categories = ["science"]
license = "MIT / Apache-2.0"
repository = "https://github.com/servo/euclid"
[dependencies.euclid_macros]
version = "0.1"
[dependencies.mint]
version = "0.5.1"
optional = true

View file

@ -17,14 +17,16 @@ use core::marker::PhantomData;
use core::ops::Div;
define_matrix! {
/// Homogeneous vector in 3D space.
pub struct HomogeneousVector<T, U> {
pub x: T,
pub y: T,
pub z: T,
pub w: T,
}
/// Homogeneous vector in 3D space.
#[derive(EuclidMatrix)]
#[repr(C)]
pub struct HomogeneousVector<T, U> {
pub x: T,
pub y: T,
pub z: T,
pub w: T,
#[doc(hidden)]
pub _unit: PhantomData<U>,
}

View file

@ -62,6 +62,8 @@ extern crate serde;
#[cfg(feature = "mint")]
pub extern crate mint;
#[macro_use]
extern crate euclid_macros;
extern crate num_traits;
#[cfg(test)]
extern crate rand;

View file

@ -7,84 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
macro_rules! define_matrix {
(
$(#[$attr:meta])*
pub struct $name:ident<T, $($phantom:ident),+> {
$(pub $field:ident: T,)+
}
) => (
#[repr(C)]
$(#[$attr])*
pub struct $name<T, $($phantom),+> {
$(pub $field: T,)+
// Keep this (secretly) public for the few cases where we would like to
// create static constants which currently can't be initialized with a
// function.
#[doc(hidden)]
pub _unit: PhantomData<($($phantom),+)>
}
impl<T: Clone, $($phantom),+> Clone for $name<T, $($phantom),+> {
fn clone(&self) -> Self {
$name {
$($field: self.$field.clone(),)+
_unit: PhantomData,
}
}
}
impl<T: Copy, $($phantom),+> Copy for $name<T, $($phantom),+> {}
#[cfg(feature = "serde")]
impl<'de, T, $($phantom),+> ::serde::Deserialize<'de> for $name<T, $($phantom),+>
where T: ::serde::Deserialize<'de>
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: ::serde::Deserializer<'de>
{
let ($($field,)+) =
try!(::serde::Deserialize::deserialize(deserializer));
Ok($name {
$($field: $field,)+
_unit: PhantomData,
})
}
}
#[cfg(feature = "serde")]
impl<T, $($phantom),+> ::serde::Serialize for $name<T, $($phantom),+>
where T: ::serde::Serialize
{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: ::serde::Serializer
{
($(&self.$field,)+).serialize(serializer)
}
}
impl<T, $($phantom),+> ::core::cmp::Eq for $name<T, $($phantom),+>
where T: ::core::cmp::Eq {}
impl<T, $($phantom),+> ::core::cmp::PartialEq for $name<T, $($phantom),+>
where T: ::core::cmp::PartialEq
{
fn eq(&self, other: &Self) -> bool {
true $(&& self.$field == other.$field)+
}
}
impl<T, $($phantom),+> ::core::hash::Hash for $name<T, $($phantom),+>
where T: ::core::hash::Hash
{
fn hash<H: ::core::hash::Hasher>(&self, h: &mut H) {
$(self.$field.hash(h);)+
}
}
)
}
macro_rules! mint_vec {
($name:ident [ $($field:ident),* ] = $std_name:ident) => {
#[cfg(feature = "mint")]

View file

@ -21,13 +21,16 @@ use core::fmt;
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
use core::marker::PhantomData;
define_matrix! {
/// A 2d Point tagged with a unit.
pub struct TypedPoint2D<T, U> {
pub x: T,
pub y: T,
}
/// A 2d Point tagged with a unit.
#[derive(EuclidMatrix)]
#[repr(C)]
pub struct TypedPoint2D<T, U> {
pub x: T,
pub y: T,
#[doc(hidden)]
pub _unit: PhantomData<U>,
}
mint_vec!(TypedPoint2D[x, y] = Point2);
/// Default 2d point type with no unit.
@ -408,14 +411,17 @@ impl<T: Copy, U> From<[T; 2]> for TypedPoint2D<T, U> {
}
}
define_matrix! {
/// A 3d Point tagged with a unit.
pub struct TypedPoint3D<T, U> {
pub x: T,
pub y: T,
pub z: T,
}
/// A 3d Point tagged with a unit.
#[derive(EuclidMatrix)]
#[repr(C)]
pub struct TypedPoint3D<T, U> {
pub x: T,
pub y: T,
pub z: T,
#[doc(hidden)]
pub _unit: PhantomData<U>,
}
mint_vec!(TypedPoint3D[x, y, z] = Point3);
/// Default 3d point type with no unit.

View file

@ -24,7 +24,7 @@ use core::borrow::Borrow;
use core::cmp::PartialOrd;
use core::fmt;
use core::hash::{Hash, Hasher};
use core::ops::{Add, Div, Mul, Sub};
use core::ops::{Add, Div, Mul, Sub, Range};
/// A 2d Rectangle optionally tagged with a unit.
@ -168,6 +168,16 @@ where
Length::new(self.min_y())
}
#[inline]
pub fn x_range(&self) -> Range<T> {
self.min_x()..self.max_x()
}
#[inline]
pub fn y_range(&self) -> Range<T> {
self.min_y()..self.max_y()
}
#[inline]
pub fn intersection(&self, other: &Self) -> Option<Self> {
if !self.intersects(other) {

View file

@ -185,11 +185,13 @@ impl<T: Neg<Output = T>> Neg for Angle<T> {
}
}
define_matrix! {
/// A transform that can represent rotations in 2d, represented as an angle in radians.
pub struct TypedRotation2D<T, Src, Dst> {
pub angle : T,
}
/// A transform that can represent rotations in 2d, represented as an angle in radians.
#[derive(EuclidMatrix)]
#[repr(C)]
pub struct TypedRotation2D<T, Src, Dst> {
pub angle : T,
#[doc(hidden)]
pub _unit: PhantomData<(Src, Dst)>,
}
/// The default 2d rotation type with no units.
@ -311,26 +313,28 @@ where
}
}
define_matrix! {
/// A transform that can represent rotations in 3d, represented as a quaternion.
///
/// Most methods expect the quaternion to be normalized.
/// When in doubt, use `unit_quaternion` instead of `quaternion` to create
/// a rotation as the former will ensure that its result is normalized.
///
/// Some people use the `x, y, z, w` (or `w, x, y, z`) notations. The equivalence is
/// as follows: `x -> i`, `y -> j`, `z -> k`, `w -> r`.
/// The memory layout of this type corresponds to the `x, y, z, w` notation
pub struct TypedRotation3D<T, Src, Dst> {
// Component multiplied by the imaginary number `i`.
pub i: T,
// Component multiplied by the imaginary number `j`.
pub j: T,
// Component multiplied by the imaginary number `k`.
pub k: T,
// The real part.
pub r: T,
}
/// A transform that can represent rotations in 3d, represented as a quaternion.
///
/// Most methods expect the quaternion to be normalized.
/// When in doubt, use `unit_quaternion` instead of `quaternion` to create
/// a rotation as the former will ensure that its result is normalized.
///
/// Some people use the `x, y, z, w` (or `w, x, y, z`) notations. The equivalence is
/// as follows: `x -> i`, `y -> j`, `z -> k`, `w -> r`.
/// The memory layout of this type corresponds to the `x, y, z, w` notation
#[derive(EuclidMatrix)]
#[repr(C)]
pub struct TypedRotation3D<T, Src, Dst> {
/// Component multiplied by the imaginary number `i`.
pub i: T,
/// Component multiplied by the imaginary number `j`.
pub j: T,
/// Component multiplied by the imaginary number `k`.
pub k: T,
/// The real part.
pub r: T,
#[doc(hidden)]
pub _unit: PhantomData<(Src, Dst)>,
}
/// The default 3d rotation type with no units.

View file

@ -19,13 +19,15 @@ use core::marker::PhantomData;
/// A group of side offsets, which correspond to top/left/bottom/right for borders, padding,
/// and margins in CSS, optionally tagged with a unit.
define_matrix! {
pub struct TypedSideOffsets2D<T, U> {
pub top: T,
pub right: T,
pub bottom: T,
pub left: T,
}
#[derive(EuclidMatrix)]
#[repr(C)]
pub struct TypedSideOffsets2D<T, U> {
pub top: T,
pub right: T,
pub bottom: T,
pub left: T,
#[doc(hidden)]
pub _unit: PhantomData<U>,
}
impl<T: fmt::Debug, U> fmt::Debug for TypedSideOffsets2D<T, U> {

View file

@ -21,11 +21,13 @@ use core::ops::{Add, Div, Mul, Sub};
use core::marker::PhantomData;
/// A 2d size tagged with a unit.
define_matrix! {
pub struct TypedSize2D<T, U> {
pub width: T,
pub height: T,
}
#[derive(EuclidMatrix)]
#[repr(C)]
pub struct TypedSize2D<T, U> {
pub width: T,
pub height: T,
#[doc(hidden)]
pub _unit: PhantomData<U>,
}
/// Default 2d size type with no unit.

View file

@ -24,23 +24,25 @@ use trig::Trig;
use core::fmt;
use num_traits::NumCast;
define_matrix! {
/// A 2d transform stored as a 3 by 2 matrix in row-major order in memory.
///
/// Transforms can be parametrized over the source and destination units, to describe a
/// transformation from a space to another.
/// For example, `TypedTransform2D<f32, WorldSpace, ScreenSpace>::transform_point4d`
/// takes a `TypedPoint2D<f32, WorldSpace>` and returns a `TypedPoint2D<f32, ScreenSpace>`.
///
/// Transforms expose a set of convenience methods for pre- and post-transformations.
/// A pre-transformation corresponds to adding an operation that is applied before
/// the rest of the transformation, while a post-transformation adds an operation
/// that is applied after.
pub struct TypedTransform2D<T, Src, Dst> {
pub m11: T, pub m12: T,
pub m21: T, pub m22: T,
pub m31: T, pub m32: T,
}
/// A 2d transform stored as a 3 by 2 matrix in row-major order in memory.
///
/// Transforms can be parametrized over the source and destination units, to describe a
/// transformation from a space to another.
/// For example, `TypedTransform2D<f32, WorldSpace, ScreenSpace>::transform_point4d`
/// takes a `TypedPoint2D<f32, WorldSpace>` and returns a `TypedPoint2D<f32, ScreenSpace>`.
///
/// Transforms expose a set of convenience methods for pre- and post-transformations.
/// A pre-transformation corresponds to adding an operation that is applied before
/// the rest of the transformation, while a post-transformation adds an operation
/// that is applied after.
#[repr(C)]
#[derive(EuclidMatrix)]
pub struct TypedTransform2D<T, Src, Dst> {
pub m11: T, pub m12: T,
pub m21: T, pub m22: T,
pub m31: T, pub m32: T,
#[doc(hidden)]
pub _unit: PhantomData<(Src, Dst)>,
}
/// The default 2d transform type with no units.

View file

@ -26,24 +26,26 @@ use core::marker::PhantomData;
use core::fmt;
use num_traits::NumCast;
define_matrix! {
/// A 3d transform stored as a 4 by 4 matrix in row-major order in memory.
///
/// Transforms can be parametrized over the source and destination units, to describe a
/// transformation from a space to another.
/// For example, `TypedTransform3D<f32, WorldSpace, ScreenSpace>::transform_point3d`
/// takes a `TypedPoint3D<f32, WorldSpace>` and returns a `TypedPoint3D<f32, ScreenSpace>`.
///
/// Transforms expose a set of convenience methods for pre- and post-transformations.
/// A pre-transformation corresponds to adding an operation that is applied before
/// the rest of the transformation, while a post-transformation adds an operation
/// that is applied after.
pub struct TypedTransform3D<T, Src, Dst> {
pub m11: T, pub m12: T, pub m13: T, pub m14: T,
pub m21: T, pub m22: T, pub m23: T, pub m24: T,
pub m31: T, pub m32: T, pub m33: T, pub m34: T,
pub m41: T, pub m42: T, pub m43: T, pub m44: T,
}
/// A 3d transform stored as a 4 by 4 matrix in row-major order in memory.
///
/// Transforms can be parametrized over the source and destination units, to describe a
/// transformation from a space to another.
/// For example, `TypedTransform3D<f32, WorldSpace, ScreenSpace>::transform_point3d`
/// takes a `TypedPoint3D<f32, WorldSpace>` and returns a `TypedPoint3D<f32, ScreenSpace>`.
///
/// Transforms expose a set of convenience methods for pre- and post-transformations.
/// A pre-transformation corresponds to adding an operation that is applied before
/// the rest of the transformation, while a post-transformation adds an operation
/// that is applied after.
#[derive(EuclidMatrix)]
#[repr(C)]
pub struct TypedTransform3D<T, Src, Dst> {
pub m11: T, pub m12: T, pub m13: T, pub m14: T,
pub m21: T, pub m22: T, pub m23: T, pub m24: T,
pub m31: T, pub m32: T, pub m33: T, pub m34: T,
pub m41: T, pub m42: T, pub m43: T, pub m44: T,
#[doc(hidden)]
pub _unit: PhantomData<(Src, Dst)>,
}
/// The default 3d transform type with no units.

View file

@ -15,31 +15,33 @@ use core::ops::{Add, Sub, Neg, Mul, Div};
use core::marker::PhantomData;
use core::fmt;
define_matrix! {
/// A 2d transformation from a space to another that can only express translations.
///
/// The main benefit of this type over a TypedVector2D is the ability to cast
/// between a source and a destination spaces.
///
/// Example:
///
/// ```
/// use euclid::{TypedTranslation2D, TypedPoint2D, point2};
/// struct ParentSpace;
/// struct ChildSpace;
/// type ScrollOffset = TypedTranslation2D<i32, ParentSpace, ChildSpace>;
/// type ParentPoint = TypedPoint2D<i32, ParentSpace>;
/// type ChildPoint = TypedPoint2D<i32, ChildSpace>;
///
/// let scrolling = ScrollOffset::new(0, 100);
/// let p1: ParentPoint = point2(0, 0);
/// let p2: ChildPoint = scrolling.transform_point(&p1);
/// ```
///
pub struct TypedTranslation2D<T, Src, Dst> {
pub x: T,
pub y: T,
}
/// A 2d transformation from a space to another that can only express translations.
///
/// The main benefit of this type over a TypedVector2D is the ability to cast
/// between a source and a destination spaces.
///
/// Example:
///
/// ```
/// use euclid::{TypedTranslation2D, TypedPoint2D, point2};
/// struct ParentSpace;
/// struct ChildSpace;
/// type ScrollOffset = TypedTranslation2D<i32, ParentSpace, ChildSpace>;
/// type ParentPoint = TypedPoint2D<i32, ParentSpace>;
/// type ChildPoint = TypedPoint2D<i32, ChildSpace>;
///
/// let scrolling = ScrollOffset::new(0, 100);
/// let p1: ParentPoint = point2(0, 0);
/// let p2: ChildPoint = scrolling.transform_point(&p1);
/// ```
///
#[derive(EuclidMatrix)]
#[repr(C)]
pub struct TypedTranslation2D<T, Src, Dst> {
pub x: T,
pub y: T,
#[doc(hidden)]
pub _unit: PhantomData<(Src, Dst)>,
}
impl<T, Src, Dst> TypedTranslation2D<T, Src, Dst> {
@ -228,16 +230,18 @@ where T: Copy + fmt::Debug {
define_matrix! {
/// A 3d transformation from a space to another that can only express translations.
///
/// The main benefit of this type over a TypedVector3D is the ability to cast
/// between a source and a destination spaces.
pub struct TypedTranslation3D<T, Src, Dst> {
pub x: T,
pub y: T,
pub z: T,
}
/// A 3d transformation from a space to another that can only express translations.
///
/// The main benefit of this type over a TypedVector3D is the ability to cast
/// between a source and a destination spaces.
#[derive(EuclidMatrix)]
#[repr(C)]
pub struct TypedTranslation3D<T, Src, Dst> {
pub x: T,
pub y: T,
pub z: T,
#[doc(hidden)]
pub _unit: PhantomData<(Src, Dst)>,
}
impl<T, Src, Dst> TypedTranslation3D<T, Src, Dst> {

View file

@ -23,13 +23,16 @@ use core::fmt;
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
use core::marker::PhantomData;
define_matrix! {
/// A 2d Vector tagged with a unit.
pub struct TypedVector2D<T, U> {
pub x: T,
pub y: T,
}
/// A 2d Vector tagged with a unit.
#[derive(EuclidMatrix)]
#[repr(C)]
pub struct TypedVector2D<T, U> {
pub x: T,
pub y: T,
#[doc(hidden)]
pub _unit: PhantomData<U>,
}
mint_vec!(TypedVector2D[x, y] = Vector2);
/// Default 2d vector type with no unit.
@ -468,14 +471,17 @@ where
}
}
define_matrix! {
/// A 3d Vector tagged with a unit.
pub struct TypedVector3D<T, U> {
pub x: T,
pub y: T,
pub z: T,
}
/// A 3d Vector tagged with a unit.
#[derive(EuclidMatrix)]
#[repr(C)]
pub struct TypedVector3D<T, U> {
pub x: T,
pub y: T,
pub z: T,
#[doc(hidden)]
pub _unit: PhantomData<U>,
}
mint_vec!(TypedVector3D[x, y, z] = Vector3);
/// Default 3d vector type with no unit.

View file

@ -0,0 +1 @@
{"files":{"Cargo.toml":"12f4357876f09242153fbbd912c70861b03d5a8f983fce3de0d3696389452be6","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","euclid_matrix.rs":"0643b38d8284278c3d54a3791aa0eae7edd5f73a54e1edec38e1bcdb4af66e0b","lib.rs":"845b9a82365e06d51edce03560a5abe617f955c9c640e90140c87fb594c65fbd"},"package":"fdcb84c18ea5037a1c5a23039b4ff29403abce2e0d6b1daa11cf0bde2b30be15"}

View file

@ -0,0 +1,31 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g. crates.io) dependencies
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
[package]
name = "euclid_macros"
version = "0.1.0"
authors = ["Emilio Cobos Álvarez <emilio@crisal.io>", "The Servo project developers"]
description = "Euclid implementation detail"
license = "MIT / Apache-2.0"
[lib]
path = "lib.rs"
proc-macro = true
[dependencies.proc-macro2]
version = "0.4"
[dependencies.quote]
version = "0.6"
[dependencies.syn]
version = "0.15"
features = ["visit"]

View file

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -0,0 +1,25 @@
Copyright (c) 2012-2013 Mozilla Foundation
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,247 @@
use proc_macro2::TokenStream;
use syn::{self, DeriveInput};
type Fields = syn::punctuated::Punctuated<syn::Field, syn::token::Comma>;
fn derive_trait<F>(
input: &DeriveInput,
trait_name: TokenStream,
generics: &syn::Generics,
body: F
) -> TokenStream
where
F: FnOnce() -> TokenStream,
{
let struct_name = &input.ident;
let (impl_generics, _, where_clause) = generics.split_for_impl();
let (_, ty_generics, _) = input.generics.split_for_impl();
let body = body();
quote! {
impl #impl_generics #trait_name for #struct_name #ty_generics #where_clause {
#body
}
}
}
fn derive_simple_trait<F>(
input: &DeriveInput,
trait_name: TokenStream,
t: &syn::TypeParam,
body: F,
) -> TokenStream
where
F: FnOnce() -> TokenStream,
{
let mut generics = input.generics.clone();
generics
.make_where_clause()
.predicates
.push(parse_quote!(#t: #trait_name));
derive_trait(input, trait_name, &generics, body)
}
fn each_field_except_unit<F>(
fields: &Fields,
unit: &syn::Field,
mut field_expr: F,
) -> TokenStream
where
F: FnMut(&syn::Ident) -> TokenStream,
{
fields.iter().filter(|f| f.ident != unit.ident).fold(quote! {}, |body, field| {
let name = field.ident.as_ref().unwrap();
let expr = field_expr(name);
quote! {
#body
#expr
}
})
}
fn derive_struct_body<F>(
fields: &Fields,
unit: &syn::Field,
mut field_expr: F,
) -> TokenStream
where
F: FnMut(&syn::Ident) -> TokenStream,
{
let body = each_field_except_unit(fields, unit, |name| {
let expr = field_expr(name);
quote! {
#name: #expr,
}
});
let unit_name = unit.ident.as_ref().unwrap();
quote! {
Self {
#body
#unit_name: PhantomData,
}
}
}
fn clone_impl(input: &DeriveInput, fields: &Fields, unit: &syn::Field, t: &syn::TypeParam) -> TokenStream {
derive_simple_trait(input, quote! { Clone }, t, || {
let body = derive_struct_body(fields, unit, |name| {
quote! { self.#name.clone() }
});
quote! {
fn clone(&self) -> Self {
#body
}
}
})
}
fn copy_impl(input: &DeriveInput, t: &syn::TypeParam) -> TokenStream {
derive_simple_trait(input, quote!{ Copy }, t, || quote! {})
}
fn eq_impl(input: &DeriveInput, t: &syn::TypeParam) -> TokenStream {
derive_simple_trait(input, quote!{ ::core::cmp::Eq }, t, || quote! {})
}
fn partialeq_impl(input: &DeriveInput, fields: &Fields, unit: &syn::Field, t: &syn::TypeParam) -> TokenStream {
derive_simple_trait(input, quote!{ ::core::cmp::PartialEq }, t, || {
let body = each_field_except_unit(fields, unit, |name| {
quote! { && self.#name == other.#name }
});
quote! {
fn eq(&self, other: &Self) -> bool {
true #body
}
}
})
}
fn hash_impl(input: &DeriveInput, fields: &Fields, unit: &syn::Field, t: &syn::TypeParam) -> TokenStream {
derive_simple_trait(input, quote!{ ::core::hash::Hash }, t, || {
let body = each_field_except_unit(fields, unit, |name| {
quote! { self.#name.hash(h); }
});
quote! {
fn hash<H: ::core::hash::Hasher>(&self, h: &mut H) {
#body
}
}
})
}
fn serde_impl(
input: &DeriveInput,
fields: &Fields,
unit: &syn::Field,
t: &syn::TypeParam,
) -> TokenStream {
let deserialize_impl = {
let mut generics = input.generics.clone();
generics.params.insert(0, parse_quote!('de));
generics
.make_where_clause()
.predicates
.push(parse_quote!(#t: ::serde::Deserialize<'de>));
derive_trait(input, quote!{ ::serde::Deserialize<'de> }, &generics, || {
let tuple = each_field_except_unit(fields, unit, |name| {
quote! { #name, }
});
let body = derive_struct_body(fields, unit, |name| quote! { #name });
quote! {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
let (#tuple) = ::serde::Deserialize::deserialize(deserializer)?;
Ok(#body)
}
}
})
};
let serialize_impl = derive_simple_trait(input, quote! { ::serde::Serialize }, t, || {
let tuple = each_field_except_unit(fields, unit, |name| {
quote! { &self.#name, }
});
quote! {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: ::serde::Serializer,
{
(#tuple).serialize(serializer)
}
}
});
quote! {
#[cfg(feature = "serde")]
#serialize_impl
#[cfg(feature = "serde")]
#deserialize_impl
}
}
pub fn derive(input: DeriveInput) -> TokenStream {
let s = match input.data {
syn::Data::Struct(ref s) => s,
_ => panic!("Need to derive this on a struct"),
};
let fields = match s.fields {
syn::Fields::Named(ref named) => &named.named,
_ => panic!("Need to use named fields"),
};
assert!(!fields.is_empty());
let unit_field = fields.last().unwrap();
assert_eq!(
unit_field.value().ident.as_ref().unwrap().to_string(),
"_unit",
"You need to have a _unit field to derive this trait",
);
assert!(match unit_field.value().vis {
syn::Visibility::Public(..) => true,
_ => false,
}, "Unit field should be public");
assert!(input.attrs.iter().filter_map(|attr| attr.interpret_meta()).any(|attr| {
match attr {
syn::Meta::Word(..) |
syn::Meta::NameValue(..) => false,
syn::Meta::List(ref list) => {
list.ident == "repr" && list.nested.iter().any(|meta| {
match *meta {
syn::NestedMeta::Meta(syn::Meta::Word(ref w)) => w == "C",
_ => false,
}
})
}
}
}), "struct should be #[repr(C)]");
let type_param =
input.generics.type_params().next().cloned().expect("Need a T");
let clone = clone_impl(&input, fields, unit_field.value(), &type_param);
let copy = copy_impl(&input, &type_param);
let serde = serde_impl(&input, fields, unit_field.value(), &type_param);
let eq = eq_impl(&input, &type_param);
let partialeq = partialeq_impl(&input, fields, unit_field.value(), &type_param);
let hash = hash_impl(&input, fields, unit_field.value(), &type_param);
quote! {
#clone
#copy
#serde
#eq
#partialeq
#hash
}
}

16
third_party/rust/euclid_macros/lib.rs vendored Normal file
View file

@ -0,0 +1,16 @@
extern crate proc_macro;
extern crate proc_macro2;
#[macro_use]
extern crate quote;
#[macro_use]
extern crate syn;
use proc_macro::TokenStream;
mod euclid_matrix;
#[proc_macro_derive(EuclidMatrix)]
pub fn derive_euclid_matrix(input: TokenStream) -> TokenStream {
let input = syn::parse(input).unwrap();
euclid_matrix::derive(input).into()
}