From f6a27cddba3adbc13b7a11edf0cb706c50e2df29 Mon Sep 17 00:00:00 2001 From: ozkriff Date: Sat, 17 May 2014 00:11:27 +0400 Subject: [PATCH] Updated for latest Rust --- src/cgmath/aabb.rs | 4 ++-- src/cgmath/angle.rs | 26 +++++++++++++------------- src/cgmath/matrix.rs | 6 +++--- src/cgmath/partial_ord.rs | 2 +- src/cgmath/plane.rs | 2 +- src/cgmath/point.rs | 4 ++-- src/cgmath/projection.rs | 6 +++--- src/cgmath/quaternion.rs | 2 +- src/cgmath/transform.rs | 2 +- src/cgmath/vector.rs | 6 +++--- 10 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/cgmath/aabb.rs b/src/cgmath/aabb.rs index 878b8f5..abb46ed 100644 --- a/src/cgmath/aabb.rs +++ b/src/cgmath/aabb.rs @@ -97,7 +97,7 @@ impl Aabb, Point2, [S, ..2]> for Aabb2 { impl fmt::Show for Aabb2 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f.buf, "[{} - {}]", self.min, self.max) + write!(f, "[{} - {}]", self.min, self.max) } } @@ -130,6 +130,6 @@ impl Aabb, Point3, [S, ..3]> for Aabb3 { impl fmt::Show for Aabb3 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f.buf, "[{} - {}]", self.min, self.max) + write!(f, "[{} - {}]", self.min, self.max) } } diff --git a/src/cgmath/angle.rs b/src/cgmath/angle.rs index a2d5b60..bdba0e1 100644 --- a/src/cgmath/angle.rs +++ b/src/cgmath/angle.rs @@ -187,31 +187,31 @@ Angle for Deg { #[inline] fn full_turn() -> Deg { deg(cast(360).unwrap()) } } -#[inline] pub fn sin(theta: Rad) -> S { theta.s.sin() } -#[inline] pub fn cos(theta: Rad) -> S { theta.s.cos() } -#[inline] pub fn tan(theta: Rad) -> S { theta.s.tan() } -#[inline] pub fn sin_cos(theta: Rad) -> (S, S) { theta.s.sin_cos() } +#[inline] pub fn sin(theta: Rad) -> S { theta.s.sin() } +#[inline] pub fn cos(theta: Rad) -> S { theta.s.cos() } +#[inline] pub fn tan(theta: Rad) -> S { theta.s.tan() } +#[inline] pub fn sin_cos(theta: Rad) -> (S, S) { theta.s.sin_cos() } -#[inline] pub fn cot(theta: Rad) -> S { tan(theta).recip() } -#[inline] pub fn sec(theta: Rad) -> S { cos(theta).recip() } -#[inline] pub fn csc(theta: Rad) -> S { sin(theta).recip() } +#[inline] pub fn cot(theta: Rad) -> S { tan(theta).recip() } +#[inline] pub fn sec(theta: Rad) -> S { cos(theta).recip() } +#[inline] pub fn csc(theta: Rad) -> S { sin(theta).recip() } -#[inline] pub fn asin(s: S) -> Rad { rad(s.asin()) } -#[inline] pub fn acos(s: S) -> Rad { rad(s.acos()) } -#[inline] pub fn atan(s: S) -> Rad { rad(s.atan()) } -#[inline] pub fn atan2(a: S, b: S) -> Rad { rad(a.atan2(b)) } +#[inline] pub fn asin(s: S) -> Rad { rad(s.asin()) } +#[inline] pub fn acos(s: S) -> Rad { rad(s.acos()) } +#[inline] pub fn atan(s: S) -> Rad { rad(s.atan()) } +#[inline] pub fn atan2(a: S, b: S) -> Rad { rad(a.atan2(b)) } impl fmt::Show for Rad { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f.buf, "{} rad", self.s) + write!(f, "{} rad", self.s) } } impl fmt::Show for Deg { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f.buf, "{}°", self.s) + write!(f, "{}°", self.s) } } diff --git a/src/cgmath/matrix.rs b/src/cgmath/matrix.rs index 2c4eab9..0fe6a65 100644 --- a/src/cgmath/matrix.rs +++ b/src/cgmath/matrix.rs @@ -725,7 +725,7 @@ ToQuaternion for Matrix3 { impl + fmt::Show> fmt::Show for Matrix2 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f.buf, "[[{}, {}], [{}, {}]]", + write!(f, "[[{}, {}], [{}, {}]]", self.cr(0, 0), self.cr(0, 1), self.cr(1, 0), self.cr(1, 1)) } @@ -733,7 +733,7 @@ impl + fmt::Show> fmt::Show for Matrix2 { impl + fmt::Show> fmt::Show for Matrix3 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f.buf, "[[{}, {}, {}], [{}, {}, {}], [{}, {}, {}]]", + write!(f, "[[{}, {}, {}], [{}, {}, {}], [{}, {}, {}]]", self.cr(0, 0), self.cr(0, 1), self.cr(0, 2), self.cr(1, 0), self.cr(1, 1), self.cr(1, 2), self.cr(2, 0), self.cr(2, 1), self.cr(2, 2)) @@ -742,7 +742,7 @@ impl + fmt::Show> fmt::Show for Matrix3 { impl + fmt::Show> fmt::Show for Matrix4 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f.buf, "[[{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}]]", + write!(f, "[[{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}]]", self.cr(0, 0), self.cr(0, 1), self.cr(0, 2), self.cr(0, 3), self.cr(1, 0), self.cr(1, 1), self.cr(1, 2), self.cr(1, 3), self.cr(2, 0), self.cr(2, 1), self.cr(2, 2), self.cr(2, 3), diff --git a/src/cgmath/partial_ord.rs b/src/cgmath/partial_ord.rs index 37e24b9..5a04524 100644 --- a/src/cgmath/partial_ord.rs +++ b/src/cgmath/partial_ord.rs @@ -46,7 +46,7 @@ macro_rules! gen_minmax_for_not_floats ( gen_minmax_for_floats!(f32, f64) gen_minmax_for_not_floats!(int, i8, i16, i32, i64, uint, u8, u16, u32, u64) -pub trait PartOrdFloat : Float + ApproxEq + PartOrdPrim {} +pub trait PartOrdFloat : FloatMath + ApproxEq + PartOrdPrim {} impl PartOrdFloat for f32 {} impl PartOrdFloat for f64 {} diff --git a/src/cgmath/plane.rs b/src/cgmath/plane.rs index 70552e1..eb3b5fa 100644 --- a/src/cgmath/plane.rs +++ b/src/cgmath/plane.rs @@ -124,7 +124,7 @@ ApproxEq for Plane { impl fmt::Show for Plane { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f.buf, "{:f}x + {:f}y + {:f}z - {:f} = 0", + write!(f, "{:f}x + {:f}y + {:f}z - {:f} = 0", self.n.x, self.n.y, self.n.z, self.d) } } diff --git a/src/cgmath/point.rs b/src/cgmath/point.rs index b6bcf9e..f54e6f7 100644 --- a/src/cgmath/point.rs +++ b/src/cgmath/point.rs @@ -102,12 +102,12 @@ impl Point, [S, ..3]> for Point3 {} impl fmt::Show for Point2 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f.buf, "[{}, {}]", 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.buf, "[{}, {}, {}]", self.x, self.y, self.z) + write!(f, "[{}, {}, {}]", self.x, self.y, self.z) } } diff --git a/src/cgmath/projection.rs b/src/cgmath/projection.rs index 5edd636..5cdf168 100644 --- a/src/cgmath/projection.rs +++ b/src/cgmath/projection.rs @@ -25,7 +25,7 @@ use partial_ord::PartOrdFloat; /// /// This is the equivalent to the [gluPerspective] /// (http://www.opengl.org/sdk/docs/man2/xhtml/gluPerspective.xml) function. -pub fn perspective>(fovy: A, aspect: S, near: S, far: S) -> Matrix4 { +pub fn perspective>(fovy: A, aspect: S, near: S, far: S) -> Matrix4 { PerspectiveFov { fovy: fovy, aspect: aspect, @@ -77,7 +77,7 @@ pub struct PerspectiveFov { pub far: S, } -impl> PerspectiveFov { +impl> PerspectiveFov { pub fn to_perspective(&self) -> Perspective { let angle = self.fovy.div_s(cast(2).unwrap()); let ymax = self.near * tan(angle.to_rad()); @@ -102,7 +102,7 @@ Projection for PerspectiveFov { } } -impl> ToMatrix4 for PerspectiveFov { +impl> ToMatrix4 for PerspectiveFov { fn to_matrix4(&self) -> Matrix4 { let half_turn: A = Angle::turn_div_2(); diff --git a/src/cgmath/quaternion.rs b/src/cgmath/quaternion.rs index 097a3e6..e793eb5 100644 --- a/src/cgmath/quaternion.rs +++ b/src/cgmath/quaternion.rs @@ -290,7 +290,7 @@ Neg> for Quaternion { impl fmt::Show for Quaternion { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f.buf, "{} + {}i + {}j + {}k", + write!(f, "{} + {}i + {}j + {}k", self.s, self.v.x, self.v.y, diff --git a/src/cgmath/transform.rs b/src/cgmath/transform.rs index a9c47de..57e3bbe 100644 --- a/src/cgmath/transform.rs +++ b/src/cgmath/transform.rs @@ -161,7 +161,7 @@ Transform3 for Decomposed,R> {} impl> fmt::Show for Decomposed,R> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f.buf, "(scale({}), rot({}), disp{})", + write!(f, "(scale({}), rot({}), disp{})", self.scale, self.rot, self.disp) } } diff --git a/src/cgmath/vector.rs b/src/cgmath/vector.rs index a80c1ae..1a22e16 100644 --- a/src/cgmath/vector.rs +++ b/src/cgmath/vector.rs @@ -304,18 +304,18 @@ EuclideanVector for Vector4 { impl fmt::Show for Vector2 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f.buf, "[{}, {}]", 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.buf, "[{}, {}, {}]", 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.buf, "[{}, {}, {}, {}]", self.x, self.y, self.z, self.w) + write!(f, "[{}, {}, {}, {}]", self.x, self.y, self.z, self.w) } }