diff --git a/benches/common/macros.rs b/benches/common/macros.rs index 2ab9d0a..7c36b75 100644 --- a/benches/common/macros.rs +++ b/benches/common/macros.rs @@ -82,7 +82,7 @@ macro_rules! bench_unop( ); macro_rules! bench_construction( - ($name: ident, $t: ty, $constructor: path $(, $args: ident: $types: ty)*) => { + ($name: ident, $t: ty, $constructor: path [ $($args: ident: $types: ty),+ ]) => { #[bench] fn $name(bh: &mut Bencher) { const LEN: uint = 1 << 13; diff --git a/benches/construction.rs b/benches/construction.rs index c02554e..159562d 100644 --- a/benches/construction.rs +++ b/benches/construction.rs @@ -55,7 +55,7 @@ fn _bench_rot3_from_axisangle(bh: &mut Bencher) { bench_from_axis_angle::>(bh) } -bench_construction!(_bench_rot2_from_axisangle, Basis2, Rotation2::from_angle, angle: Rad); +bench_construction!(_bench_rot2_from_axisangle, Basis2, Rotation2::from_angle [ angle: Rad ]); -bench_construction!(_bench_quat_from_euler_angles, Quaternion, Rotation3::from_euler, roll: Rad, pitch: Rad, yaw: Rad); -bench_construction!(_bench_rot3_from_euler_angles, Basis3, Rotation3::from_euler, roll: Rad, pitch: Rad, yaw: Rad); +bench_construction!(_bench_quat_from_euler_angles, Quaternion, Rotation3::from_euler [roll: Rad, pitch: Rad, yaw: Rad]); +bench_construction!(_bench_rot3_from_euler_angles, Basis3, Rotation3::from_euler [roll: Rad, pitch: Rad, yaw: Rad]); diff --git a/src/aabb.rs b/src/aabb.rs index c232701..2fae234 100644 --- a/src/aabb.rs +++ b/src/aabb.rs @@ -124,7 +124,7 @@ impl Aabb, Point2> for Aabb2 { impl fmt::Show for Aabb2 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "[{} - {}]", self.min, self.max) + write!(f, "[{:?} - {:?}]", self.min, self.max) } } @@ -171,7 +171,7 @@ impl Aabb, Point3> for Aabb3 { impl fmt::Show for Aabb3 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "[{} - {}]", self.min, self.max) + write!(f, "[{:?} - {:?}]", self.min, self.max) } } diff --git a/src/angle.rs b/src/angle.rs index 9b6f819..dc54bb0 100644 --- a/src/angle.rs +++ b/src/angle.rs @@ -284,14 +284,14 @@ Angle for Deg { impl fmt::Show for Rad { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{} rad", self.s) + write!(f, "{:?} rad", self.s) } } impl fmt::Show for Deg { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}°", self.s) + write!(f, "{:?}°", self.s) } } diff --git a/src/approx.rs b/src/approx.rs index e07c276..fd5c89e 100644 --- a/src/approx.rs +++ b/src/approx.rs @@ -50,7 +50,7 @@ macro_rules! assert_approx_eq_eps( let eps = &($eps); let (given_val, expected_val) = (&($given), &($expected)); if !given_val.approx_eq_eps(expected_val, eps) { - panic!("assertion failed: `left ≈ right` (left: `{}`, right: `{}`, tolerance: `{}`)", + panic!("assertion failed: `left ≈ right` (left: `{:?}`, right: `{:?}`, tolerance: `{:?}`)", *given_val, *expected_val, *eps ); } @@ -62,7 +62,7 @@ macro_rules! assert_approx_eq( ($given: expr, $expected: expr) => ({ let (given_val, expected_val) = (&($given), &($expected)); if !given_val.approx_eq(expected_val) { - panic!("assertion failed: `left ≈ right` (left: `{}`, right: `{}`, tolerance: `{}`)", + panic!("assertion failed: `left ≈ right` (left: `{:?}`, right: `{:?}`, tolerance: `{:?}`)", *given_val, *expected_val, ApproxEq::approx_epsilon(Some(*given_val)) ); diff --git a/src/cgmath.rs b/src/cgmath.rs index cddc016..06d14bd 100644 --- a/src/cgmath.rs +++ b/src/cgmath.rs @@ -15,6 +15,7 @@ #![crate_type = "rlib"] #![crate_type = "dylib"] +#![feature(old_impl_check)] //! Computer graphics-centric math. //! diff --git a/src/line.rs b/src/line.rs index 13eae20..f225071 100644 --- a/src/line.rs +++ b/src/line.rs @@ -28,6 +28,7 @@ pub struct Line

{ pub dest: P, } +#[old_impl_check] impl, P: Point> Line

{ pub fn new(origin: P, dest: P) -> Line

{ Line { origin:origin, dest:dest } diff --git a/src/matrix.rs b/src/matrix.rs index 3cdfa6f..c259046 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -1383,7 +1383,7 @@ impl ToQuaternion for Matrix3 { impl fmt::Show for Matrix2 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "[[{}, {}], [{}, {}]]", + write!(f, "[[{:?}, {:?}], [{:?}, {:?}]]", self[0][0], self[0][1], self[1][0], self[1][1]) } @@ -1391,7 +1391,7 @@ impl fmt::Show for Matrix2 { impl fmt::Show for Matrix3 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "[[{}, {}, {}], [{}, {}, {}], [{}, {}, {}]]", + write!(f, "[[{:?}, {:?}, {:?}], [{:?}, {:?}, {:?}], [{:?}, {:?}, {:?}]]", self[0][0], self[0][1], self[0][2], self[1][0], self[1][1], self[1][2], self[2][0], self[2][1], self[2][2]) @@ -1400,7 +1400,7 @@ impl fmt::Show for Matrix3 { impl fmt::Show for Matrix4 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "[[{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}]]", + write!(f, "[[{:?}, {:?}, {:?}, {:?}], [{:?}, {:?}, {:?}, {:?}], [{:?}, {:?}, {:?}, {:?}], [{:?}, {:?}, {:?}, {:?}]]", self[0][0], self[0][1], self[0][2], self[0][3], self[1][0], self[1][1], self[1][2], self[1][3], self[2][0], self[2][1], self[2][2], self[2][3], diff --git a/src/plane.rs b/src/plane.rs index a1314b1..5d4d739 100644 --- a/src/plane.rs +++ b/src/plane.rs @@ -131,7 +131,7 @@ ApproxEq for Plane { impl fmt::Show for Plane { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}x + {}y + {}z - {} = 0", + write!(f, "{:?}x + {:?}y + {:?}z - {:?} = 0", self.n.x, self.n.y, self.n.z, self.d) } } diff --git a/src/point.rs b/src/point.rs index b5c5f3f..1e0744e 100644 --- a/src/point.rs +++ b/src/point.rs @@ -433,12 +433,12 @@ impl ApproxEq for Point3 { impl fmt::Show for Point2 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "[{}, {}]", self.x, self.y) + write!(f, "[{:?}, {:?}]", self.x, self.y) } } impl fmt::Show for Point3 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "[{}, {}, {}]", self.x, self.y, self.z) + write!(f, "[{:?}, {:?}, {:?}]", self.x, self.y, self.z) } } diff --git a/src/projection.rs b/src/projection.rs index 999fdcf..51bf6a8 100644 --- a/src/projection.rs +++ b/src/projection.rs @@ -105,12 +105,12 @@ impl> ToMatrix4 for PerspectiveFov { fn to_matrix4(&self) -> Matrix4 { let half_turn: A = Angle::turn_div_2(); - assert!(self.fovy > zero(), "The vertical field of view cannot be below zero, found: {}", self.fovy); - assert!(self.fovy < half_turn, "The vertical field of view cannot be greater than a half turn, found: {}", self.fovy); - assert!(self.aspect > zero(), "The aspect ratio cannot be below zero, found: {}", self.aspect); - assert!(self.near > zero(), "The near plane distance cannot be below zero, found: {}", self.near); - assert!(self.far > zero(), "The far plane distance cannot be below zero, found: {}", self.far); - assert!(self.far > self.near, "The far plane cannot be closer than the near plane, found: far: {}, near: {}", self.far, self.near); + assert!(self.fovy > zero(), "The vertical field of view cannot be below zero, found: {:?}", self.fovy); + assert!(self.fovy < half_turn, "The vertical field of view cannot be greater than a half turn, found: {:?}", self.fovy); + assert!(self.aspect > zero(), "The aspect ratio cannot be below zero, found: {:?}", self.aspect); + assert!(self.near > zero(), "The near plane distance cannot be below zero, found: {:?}", self.near); + assert!(self.far > zero(), "The far plane distance cannot be below zero, found: {:?}", self.far); + assert!(self.far > self.near, "The far plane cannot be closer than the near plane, found: far: {:?}, near: {:?}", self.far, self.near); let f = cot(self.fovy.div_s(cast(2i).unwrap()).to_rad()); let two: S = cast(2i).unwrap(); @@ -159,9 +159,9 @@ impl Projection for Perspective { impl ToMatrix4 for Perspective { fn to_matrix4(&self) -> Matrix4 { - assert!(self.left <= self.right, "`left` cannot be greater than `right`, found: left: {} right: {}", self.left, self.right); - assert!(self.bottom <= self.top, "`bottom` cannot be greater than `top`, found: bottom: {} top: {}", self.bottom, self.top); - assert!(self.near <= self.far, "`near` cannot be greater than `far`, found: near: {} far: {}", self.near, self.far); + assert!(self.left <= self.right, "`left` cannot be greater than `right`, found: left: {:?} right: {:?}", self.left, self.right); + assert!(self.bottom <= self.top, "`bottom` cannot be greater than `top`, found: bottom: {:?} top: {:?}", self.bottom, self.top); + assert!(self.near <= self.far, "`near` cannot be greater than `far`, found: near: {:?} far: {:?}", self.near, self.far); let two: S = cast(2i).unwrap(); diff --git a/src/quaternion.rs b/src/quaternion.rs index 0a762a2..69c5013 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -372,7 +372,7 @@ impl Neg for Quaternion { impl fmt::Show for Quaternion { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{} + {}i + {}j + {}k", + write!(f, "{:?} + {:?}i + {:?}j + {:?}k", self.s, self.v.x, self.v.y, diff --git a/src/ray.rs b/src/ray.rs index a86b608..4d4e28d 100644 --- a/src/ray.rs +++ b/src/ray.rs @@ -25,6 +25,7 @@ pub struct Ray { pub direction: V, } +#[old_impl_check] impl, P: Point> Ray { pub fn new(origin: P, direction: V) -> Ray { Ray { origin: origin, direction: direction } diff --git a/src/rotation.rs b/src/rotation.rs index 4c0ce2a..efb2d11 100644 --- a/src/rotation.rs +++ b/src/rotation.rs @@ -132,7 +132,7 @@ pub trait Rotation3: Rotation, Point3> /// angle. We can accomplish this quite easily with a two-dimensional rotation /// matrix: /// -/// ```rust +/// ~~~ignore /// use cgmath::rad; /// use cgmath::Vector2; /// use cgmath::{Matrix, ToMatrix2}; @@ -160,7 +160,7 @@ pub trait Rotation3: Rotation, Point3> /// let rot_half: Basis2 = Rotation2::from_angle(rad(0.25f64 * f64::consts::PI)); /// let unit_y3 = rot_half.concat(&rot_half).rotate_vector(&unit_x); /// assert!(unit_y3.approx_eq(&unit_y2)); -/// ``` +/// ~~~ #[derive(PartialEq, Copy, Clone, RustcEncodable, RustcDecodable)] pub struct Basis2 { mat: Matrix2 diff --git a/src/transform.rs b/src/transform.rs index 9038431..d76dc03 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -153,7 +153,7 @@ impl> Transform3 for Decomposed,R> impl> fmt::Show for Decomposed,R> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "(scale({}), rot({}), disp{})", + write!(f, "(scale({:?}), rot({:?}), disp{:?})", self.scale, self.rot, self.disp) } } diff --git a/src/vector.rs b/src/vector.rs index c3ae121..76fa4c2 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -457,7 +457,7 @@ impl Vector4 { 1 => Vector3::new(self.x, self.z, self.w), 2 => Vector3::new(self.x, self.y, self.w), 3 => Vector3::new(self.x, self.y, self.z), - _ => panic!("{} is out of range", n) + _ => panic!("{:?} is out of range", n) } } } @@ -555,18 +555,18 @@ impl EuclideanVector for Vector4 { impl fmt::Show for Vector2 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "[{}, {}]", self.x, self.y) + write!(f, "[{:?}, {:?}]", self.x, self.y) } } impl fmt::Show for Vector3 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "[{}, {}, {}]", self.x, self.y, self.z) + write!(f, "[{:?}, {:?}, {:?}]", self.x, self.y, self.z) } } impl fmt::Show for Vector4 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "[{}, {}, {}, {}]", self.x, self.y, self.z, self.w) + write!(f, "[{:?}, {:?}, {:?}, {:?}]", self.x, self.y, self.z, self.w) } } diff --git a/tests/approx.rs b/tests/approx.rs index 72619b0..c4964f7 100644 --- a/tests/approx.rs +++ b/tests/approx.rs @@ -14,8 +14,6 @@ // limitations under the License. -#![feature(phase)] - #[macro_use] extern crate cgmath; diff --git a/tests/quaternion.rs b/tests/quaternion.rs index 1a1506f..6440ed1 100644 --- a/tests/quaternion.rs +++ b/tests/quaternion.rs @@ -45,7 +45,7 @@ fn to_and_from_quaternion() if !(ax.approx_eq_eps(&bx, &0.001) && ay.approx_eq_eps(&by, &0.001) && az.approx_eq_eps(&bz, &0.001)) { - panic!("{} != {}", a, b) + panic!("{:?} != {:?}", a, b) } }