From 89e656b1f6cd9ad1eb283a2cb6273fc71e29c53b Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Tue, 3 Nov 2015 15:40:52 +1100 Subject: [PATCH] Add comments noting rust bugs --- src/array.rs | 2 ++ src/matrix.rs | 2 ++ src/point.rs | 4 +++- src/rotation.rs | 4 +++- src/transform.rs | 3 +++ src/vector.rs | 7 ++++++- 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/array.rs b/src/array.rs index 0bbfd32..ba8fb55 100644 --- a/src/array.rs +++ b/src/array.rs @@ -19,6 +19,7 @@ use std::ops::*; /// An array containing elements of type `Element` pub trait Array1 where + // FIXME: Ugly type signatures - blocked by rust-lang/rust#24092 Self: Index::Element>, Self: IndexMut::Element>, { @@ -50,6 +51,7 @@ pub trait Array1 where /// A column-major array pub trait Array2 where + // FIXME: Ugly type signatures - blocked by rust-lang/rust#24092 Self: Index::Column>, Self: IndexMut::Column>, { diff --git a/src/matrix.rs b/src/matrix.rs index 3dbbc38..bc34d41 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -250,6 +250,7 @@ impl> Matrix4 { } pub trait Matrix where + // FIXME: Ugly type signatures - blocked by rust-lang/rust#24092 Self: Array2< Element = <::ColumnRow as Vector>::Scalar, Column = ::ColumnRow, @@ -268,6 +269,7 @@ pub trait Matrix where // for<'a> &'a Self: Div, // for<'a> &'a Self: Rem, { + // FIXME: Will not be needed once equality constraints in where clauses is implemented type ColumnRow: Vector; /// Create a new diagonal matrix using the supplied value. diff --git a/src/point.rs b/src/point.rs index a40d967..2b21109 100644 --- a/src/point.rs +++ b/src/point.rs @@ -66,7 +66,9 @@ impl Point3 { } /// Specifies the numeric operations for point types. -pub trait Point: Array1::Vector as Vector>::Scalar> + Clone // where +pub trait Point: Clone where + // FIXME: Ugly type signatures - blocked by rust-lang/rust#24092 + Self: Array1::Vector as Vector>::Scalar>, // FIXME: blocked by rust-lang/rust#20671 // // for<'a, 'b> &'a Self: Add<&'b V, Output = Self>, diff --git a/src/rotation.rs b/src/rotation.rs index b2c7c42..7e1fed6 100644 --- a/src/rotation.rs +++ b/src/rotation.rs @@ -25,7 +25,9 @@ use vector::{Vector, Vector2, Vector3}; /// A trait for a generic rotation. A rotation is a transformation that /// creates a circular motion, and preserves at least one point in the space. -pub trait Rotation: PartialEq + ApproxEq::Vector as Vector>::Scalar> + Sized where +pub trait Rotation: PartialEq + Sized where + // FIXME: Ugly type signatures - blocked by rust-lang/rust#24092 + Self: ApproxEq::Vector as Vector>::Scalar>, <

::Vector as Vector>::Scalar: BaseFloat, { /// Create the identity transform (causes no transformation). diff --git a/src/transform.rs b/src/transform.rs index d732b24..5a0e2fb 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -79,6 +79,7 @@ pub struct Decomposed { } impl> Transform

for Decomposed where + // FIXME: Ugly type signatures - blocked by rust-lang/rust#24092 <

::Vector as Vector>::Scalar: BaseFloat, { #[inline] @@ -224,6 +225,7 @@ pub trait ToComponents2>: ToComponents, pub trait ToComponents3>: ToComponents, R> {} pub trait CompositeTransform>: Transform

+ ToComponents where + // FIXME: Ugly type signatures - blocked by rust-lang/rust#24092 <

::Vector as Vector>::Scalar: BaseFloat, {} @@ -231,6 +233,7 @@ pub trait CompositeTransform2>: Transform2 + To pub trait CompositeTransform3>: Transform3 + ToComponents3 {} impl + Clone> ToComponents for Decomposed where + // FIXME: Ugly type signatures - blocked by rust-lang/rust#24092 <

::Vector as Vector>::Scalar: BaseFloat, { fn decompose(&self) -> (P::Vector, R, P::Vector) { diff --git a/src/vector.rs b/src/vector.rs index 73a092b..2b11b16 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -111,7 +111,9 @@ use num::{BaseNum, BaseFloat}; /// A trait that specifies a range of numeric operations for vectors. Not all /// of these make sense from a linear algebra point of view, but are included /// for pragmatic reasons. -pub trait Vector: Array1::Scalar> + Clone // where +pub trait Vector: Clone where + // FIXME: Ugly type signatures - blocked by rust-lang/rust#24092 + Self: Array1::Scalar>, // FIXME: blocked by rust-lang/rust#20671 // // for<'a, 'b> &'a Self: Add<&'b Self, Output = Self>, @@ -627,6 +629,7 @@ impl Vector4 { /// Specifies geometric operations for vectors. This is only implemented for /// 2-dimensional and 3-dimensional vectors. pub trait EuclideanVector: Vector + Sized where + // FIXME: Ugly type signatures - blocked by rust-lang/rust#24092 ::Scalar: BaseFloat, Self: ApproxEq::Scalar>, { @@ -647,6 +650,7 @@ pub trait EuclideanVector: Vector + Sized where /// The norm of the vector. #[inline] fn length(&self) -> Self::Scalar { + // Not sure why these annotations are needed <::Scalar as ::rust_num::Float>::sqrt(self.dot(self)) } @@ -679,6 +683,7 @@ pub trait EuclideanVector: Vector + Sized where /// Normalises the vector to a length of `1`. #[inline] fn normalize_self(&mut self) { + // Not sure why these annotations are needed let rlen = <::Scalar as ::rust_num::Float>::recip(self.length()); self.mul_self_s(rlen); }