Skip to content

Commit 89e656b

Browse files
committed
Add comments noting rust bugs
1 parent cda76e3 commit 89e656b

File tree

6 files changed

+19
-3
lines changed

6 files changed

+19
-3
lines changed

src/array.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::ops::*;
1919

2020
/// An array containing elements of type `Element`
2121
pub trait Array1 where
22+
// FIXME: Ugly type signatures - blocked by rust-lang/rust#24092
2223
Self: Index<usize, Output = <Self as Array1>::Element>,
2324
Self: IndexMut<usize, Output = <Self as Array1>::Element>,
2425
{
@@ -50,6 +51,7 @@ pub trait Array1 where
5051

5152
/// A column-major array
5253
pub trait Array2 where
54+
// FIXME: Ugly type signatures - blocked by rust-lang/rust#24092
5355
Self: Index<usize, Output = <Self as Array2>::Column>,
5456
Self: IndexMut<usize, Output = <Self as Array2>::Column>,
5557
{

src/matrix.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ impl<S: Copy + Neg<Output = S>> Matrix4<S> {
250250
}
251251

252252
pub trait Matrix where
253+
// FIXME: Ugly type signatures - blocked by rust-lang/rust#24092
253254
Self: Array2<
254255
Element = <<Self as Matrix>::ColumnRow as Vector>::Scalar,
255256
Column = <Self as Matrix>::ColumnRow,
@@ -268,6 +269,7 @@ pub trait Matrix where
268269
// for<'a> &'a Self: Div<S, Output = Self>,
269270
// for<'a> &'a Self: Rem<S, Output = Self>,
270271
{
272+
// FIXME: Will not be needed once equality constraints in where clauses is implemented
271273
type ColumnRow: Vector;
272274

273275
/// Create a new diagonal matrix using the supplied value.

src/point.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ impl<S: BaseNum> Point3<S> {
6666
}
6767

6868
/// Specifies the numeric operations for point types.
69-
pub trait Point: Array1<Element = <<Self as Point>::Vector as Vector>::Scalar> + Clone // where
69+
pub trait Point: Clone where
70+
// FIXME: Ugly type signatures - blocked by rust-lang/rust#24092
71+
Self: Array1<Element = <<Self as Point>::Vector as Vector>::Scalar>,
7072
// FIXME: blocked by rust-lang/rust#20671
7173
//
7274
// for<'a, 'b> &'a Self: Add<&'b V, Output = Self>,

src/rotation.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ use vector::{Vector, Vector2, Vector3};
2525

2626
/// A trait for a generic rotation. A rotation is a transformation that
2727
/// creates a circular motion, and preserves at least one point in the space.
28-
pub trait Rotation<P: Point>: PartialEq + ApproxEq<Epsilon = <<P as Point>::Vector as Vector>::Scalar> + Sized where
28+
pub trait Rotation<P: Point>: PartialEq + Sized where
29+
// FIXME: Ugly type signatures - blocked by rust-lang/rust#24092
30+
Self: ApproxEq<Epsilon = <<P as Point>::Vector as Vector>::Scalar>,
2931
<<P as Point>::Vector as Vector>::Scalar: BaseFloat,
3032
{
3133
/// Create the identity transform (causes no transformation).

src/transform.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub struct Decomposed<V: Vector, R> {
7979
}
8080

8181
impl<P: Point, R: Rotation<P>> Transform<P> for Decomposed<P::Vector, R> where
82+
// FIXME: Ugly type signatures - blocked by rust-lang/rust#24092
8283
<<P as Point>::Vector as Vector>::Scalar: BaseFloat,
8384
{
8485
#[inline]
@@ -224,13 +225,15 @@ pub trait ToComponents2<S: BaseFloat, R: Rotation2<S>>: ToComponents<Point2<S>,
224225
pub trait ToComponents3<S: BaseFloat, R: Rotation3<S>>: ToComponents<Point3<S>, R> {}
225226

226227
pub trait CompositeTransform<P: Point, R: Rotation<P>>: Transform<P> + ToComponents<P, R> where
228+
// FIXME: Ugly type signatures - blocked by rust-lang/rust#24092
227229
<<P as Point>::Vector as Vector>::Scalar: BaseFloat,
228230
{}
229231

230232
pub trait CompositeTransform2<S: BaseFloat, R: Rotation2<S>>: Transform2<S> + ToComponents2<S, R> {}
231233
pub trait CompositeTransform3<S: BaseFloat, R: Rotation3<S>>: Transform3<S> + ToComponents3<S, R> {}
232234

233235
impl<P: Point, R: Rotation<P> + Clone> ToComponents<P, R> for Decomposed<P::Vector, R> where
236+
// FIXME: Ugly type signatures - blocked by rust-lang/rust#24092
234237
<<P as Point>::Vector as Vector>::Scalar: BaseFloat,
235238
{
236239
fn decompose(&self) -> (P::Vector, R, P::Vector) {

src/vector.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ use num::{BaseNum, BaseFloat};
111111
/// A trait that specifies a range of numeric operations for vectors. Not all
112112
/// of these make sense from a linear algebra point of view, but are included
113113
/// for pragmatic reasons.
114-
pub trait Vector: Array1<Element = <Self as Vector>::Scalar> + Clone // where
114+
pub trait Vector: Clone where
115+
// FIXME: Ugly type signatures - blocked by rust-lang/rust#24092
116+
Self: Array1<Element = <Self as Vector>::Scalar>,
115117
// FIXME: blocked by rust-lang/rust#20671
116118
//
117119
// for<'a, 'b> &'a Self: Add<&'b Self, Output = Self>,
@@ -627,6 +629,7 @@ impl<S: BaseNum> Vector4<S> {
627629
/// Specifies geometric operations for vectors. This is only implemented for
628630
/// 2-dimensional and 3-dimensional vectors.
629631
pub trait EuclideanVector: Vector + Sized where
632+
// FIXME: Ugly type signatures - blocked by rust-lang/rust#24092
630633
<Self as Vector>::Scalar: BaseFloat,
631634
Self: ApproxEq<Epsilon = <Self as Vector>::Scalar>,
632635
{
@@ -647,6 +650,7 @@ pub trait EuclideanVector: Vector + Sized where
647650
/// The norm of the vector.
648651
#[inline]
649652
fn length(&self) -> Self::Scalar {
653+
// Not sure why these annotations are needed
650654
<<Self as Vector>::Scalar as ::rust_num::Float>::sqrt(self.dot(self))
651655
}
652656

@@ -679,6 +683,7 @@ pub trait EuclideanVector: Vector + Sized where
679683
/// Normalises the vector to a length of `1`.
680684
#[inline]
681685
fn normalize_self(&mut self) {
686+
// Not sure why these annotations are needed
682687
let rlen = <<Self as Vector>::Scalar as ::rust_num::Float>::recip(self.length());
683688
self.mul_self_s(rlen);
684689
}

0 commit comments

Comments
 (0)