From b795267632e92cd7b8fdd0907202add60bd85294 Mon Sep 17 00:00:00 2001 From: nsmryan Date: Sun, 30 Sep 2018 10:31:08 -0400 Subject: [PATCH] matrix implementation compiles with new type variable bounds and dependance on generic_array --- Cargo.toml | 6 +++++- src/lib.rs | 14 ++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ff3517d..60d8e1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,12 +22,16 @@ default = ["std", "impl-cgmath"] serialization = ["serde", "serde_derive"] std = [] impl-cgmath = ["cgmath"] -impl-nalgebra = ["nalgebra"] +impl-nalgebra = ["nalgebra", "generic-array"] [dependencies.nalgebra] version = "0.14" optional = true +[dependencies.generic-array] +version = "^0.8" +optional = true + [dependencies.cgmath] version = "0.16" optional = true diff --git a/src/lib.rs b/src/lib.rs index e7cb84b..f904e0c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -102,6 +102,7 @@ #[cfg(feature = "impl-cgmath")] extern crate cgmath; #[cfg(feature = "impl-nalgebra")] extern crate nalgebra; +#[cfg(feature = "impl-nalgebra")] extern crate generic_array; #[cfg(feature = "serialization")] extern crate serde; #[cfg(feature = "serialization")] #[macro_use] extern crate serde_derive; @@ -113,6 +114,7 @@ #[cfg(feature = "impl-nalgebra")] use nalgebra::core::allocator::Allocator; #[cfg(feature = "impl-nalgebra")] use nalgebra::core::{DimName, DefaultAllocator, Scalar}; #[cfg(feature = "impl-nalgebra")] use nalgebra::storage::Storage; +#[cfg(feature = "impl-nalgebra")] use generic_array::ArrayLength; #[cfg(feature = "std")] use std::cmp::Ordering; #[cfg(feature = "std")] use std::f32::consts; @@ -406,22 +408,22 @@ impl Interpolate for na::Point let lerp = |c1 : N, c2 : N| { Interpolate::lerp(c1, c2, t) }; let coords = Matrix::zip_map(&a.coords, &b.coords, lerp); na::Point::from_coordinates(coords) + } } #[cfg(feature = "impl-nalgebra")] -impl Interpolate for na::Matrix>::Buffer> - where N : Interpolate, - N : Scalar, - R : DimName, +impl Interpolate for na::Matrix>::Buffer> + where R : DimName, C : DimName, ::Value : Mul<::Value>, ::Value : Mul<::Value>, - <::Value as Mul<::Value>>::Output : generic_array::ArrayLengh + <::Value as Mul<::Value>>::Output : generic_array::ArrayLength, + <<::Value as Mul<::Value>>::Output as generic_array::ArrayLength>::ArrayType : Copy, { fn lerp(a: Self, b: Self, t: f32) -> Self { - let lerp = |c1 : N, c2 : N| Interpolate::lerp(c1, c2, t); + let lerp = |c1 : f32, c2 : f32| Interpolate::lerp(c1, c2, t); Matrix::zip_map(&a, &b, lerp) } }