Merge pull request #156 from csherratt/master

Update to latest rustc
This commit is contained in:
Colin Sherratt 2015-01-07 15:56:52 -07:00
commit c4e9857ef5
23 changed files with 49 additions and 58 deletions

View file

@ -13,8 +13,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![macro_escape]
macro_rules! bench_binop( macro_rules! bench_binop(
($name: ident, $t1: ty, $t2: ty, $binop: ident) => { ($name: ident, $t1: ty, $t2: ty, $binop: ident) => {
#[bench] #[bench]
@ -23,15 +21,15 @@ macro_rules! bench_binop(
let mut rng = IsaacRng::new_unseeded(); let mut rng = IsaacRng::new_unseeded();
let elems1 = Vec::from_fn(LEN, |_| rng.gen::<$t1>()); let elems1: Vec<$t1> = range(0, LEN).map(|_| rng.gen::<$t1>()).collect();
let elems2 = Vec::from_fn(LEN, |_| rng.gen::<$t2>()); let elems2: Vec<$t2> = range(0, LEN).map(|_| rng.gen::<$t2>()).collect();
let mut i = 0; let mut i = 0;
bh.iter(|| { bh.iter(|| {
i = (i + 1) & (LEN - 1); i = (i + 1) & (LEN - 1);
unsafe { unsafe {
test::black_box(elems1.unsafe_get(i).$binop(elems2.unsafe_get(i))) test::black_box(elems1.get_unchecked(i).$binop(elems2.get_unchecked(i)))
} }
}) })
} }
@ -46,15 +44,15 @@ macro_rules! bench_binop_deref(
let mut rng = IsaacRng::new_unseeded(); let mut rng = IsaacRng::new_unseeded();
let elems1 = Vec::from_fn(LEN, |_| rng.gen::<$t1>()); let elems1: Vec<$t1> = range(0, LEN).map(|_| rng.gen::<$t1>()).collect();
let elems2 = Vec::from_fn(LEN, |_| rng.gen::<$t2>()); let elems2: Vec<$t2> = range(0, LEN).map(|_| rng.gen::<$t2>()).collect();
let mut i = 0; let mut i = 0;
bh.iter(|| { bh.iter(|| {
i = (i + 1) & (LEN - 1); i = (i + 1) & (LEN - 1);
unsafe { unsafe {
test::black_box(elems1.unsafe_get(i).$binop(*elems2.unsafe_get(i))) test::black_box(elems1.get_unchecked(i).$binop(*elems2.get_unchecked(i)))
} }
}) })
} }
@ -69,14 +67,14 @@ macro_rules! bench_unop(
let mut rng = IsaacRng::new_unseeded(); let mut rng = IsaacRng::new_unseeded();
let mut elems = Vec::from_fn(LEN, |_| rng.gen::<$t>()); let mut elems: Vec<$t> = range(0, LEN).map(|_| rng.gen::<$t>()).collect();
let mut i = 0; let mut i = 0;
bh.iter(|| { bh.iter(|| {
i = (i + 1) & (LEN - 1); i = (i + 1) & (LEN - 1);
unsafe { unsafe {
test::black_box(elems.unchecked_mut(i).$unop()) test::black_box(elems.get_unchecked_mut(i).$unop())
} }
}) })
} }
@ -91,14 +89,14 @@ macro_rules! bench_construction(
let mut rng = IsaacRng::new_unseeded(); let mut rng = IsaacRng::new_unseeded();
$(let $args = Vec::from_fn(LEN, |_| rng.gen::<$types>());)* $(let $args: Vec<$types> = range(0, LEN).map(|_| rng.gen::<$types>()).collect();)*
let mut i = 0; let mut i = 0;
bh.iter(|| { bh.iter(|| {
i = (i + 1) & (LEN - 1); i = (i + 1) & (LEN - 1);
unsafe { unsafe {
let res: $t = $constructor($(*$args.unsafe_get(i),)*); let res: $t = $constructor($(*$args.get_unchecked(i),)*);
test::black_box(res) test::black_box(res)
} }
}) })

View file

@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![feature(macro_rules)]
extern crate test; extern crate test;
extern crate cgmath; extern crate cgmath;
@ -24,7 +24,7 @@ use test::Bencher;
use cgmath::{Quaternion, Basis2, Basis3, Vector3, Rotation2, Rotation3, Rad}; use cgmath::{Quaternion, Basis2, Basis3, Vector3, Rotation2, Rotation3, Rad};
#[path="common/macros.rs"] #[path="common/macros.rs"]
mod macros; #[macro_use] mod macros;
fn bench_from_axis_angle<T: Rotation3<f32>>(bh: &mut Bencher) { fn bench_from_axis_angle<T: Rotation3<f32>>(bh: &mut Bencher) {
const LEN: uint = 1 << 13; const LEN: uint = 1 << 13;

View file

@ -13,8 +13,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![feature(macro_rules)]
#![feature(globs)]
extern crate test; extern crate test;
extern crate cgmath; extern crate cgmath;
@ -24,7 +24,7 @@ use test::Bencher;
use cgmath::*; use cgmath::*;
#[path="common/macros.rs"] #[path="common/macros.rs"]
mod macros; #[macro_use] mod macros;
bench_binop!(_bench_matrix2_mul_m, Matrix2<f32>, Matrix2<f32>, mul_m); bench_binop!(_bench_matrix2_mul_m, Matrix2<f32>, Matrix2<f32>, mul_m);
bench_binop!(_bench_matrix3_mul_m, Matrix3<f32>, Matrix3<f32>, mul_m); bench_binop!(_bench_matrix3_mul_m, Matrix3<f32>, Matrix3<f32>, mul_m);

View file

@ -13,8 +13,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![feature(globs)]
#![feature(macro_rules)]
extern crate test; extern crate test;
extern crate cgmath; extern crate cgmath;
@ -24,7 +24,7 @@ use test::Bencher;
use cgmath::*; use cgmath::*;
#[path="common/macros.rs"] #[path="common/macros.rs"]
mod macros; #[macro_use] mod macros;
bench_binop!(_bench_quat_add_q, Quaternion<f32>, Quaternion<f32>, add_q); bench_binop!(_bench_quat_add_q, Quaternion<f32>, Quaternion<f32>, add_q);
bench_binop!(_bench_quat_sub_q, Quaternion<f32>, Quaternion<f32>, sub_q); bench_binop!(_bench_quat_sub_q, Quaternion<f32>, Quaternion<f32>, sub_q);

View file

@ -13,8 +13,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![feature(globs)]
#![feature(macro_rules)]
extern crate test; extern crate test;
extern crate cgmath; extern crate cgmath;
@ -24,7 +24,7 @@ use test::Bencher;
use cgmath::*; use cgmath::*;
#[path="common/macros.rs"] #[path="common/macros.rs"]
mod macros; #[macro_use] mod macros;
bench_binop!(_bench_vector2_add_v, Vector2<f32>, Vector2<f32>, add_v); bench_binop!(_bench_vector2_add_v, Vector2<f32>, Vector2<f32>, add_v);
bench_binop!(_bench_vector3_add_v, Vector3<f32>, Vector3<f32>, add_v); bench_binop!(_bench_vector3_add_v, Vector3<f32>, Vector3<f32>, add_v);

View file

@ -43,7 +43,8 @@ pub trait Array1<Element: Copy>: Index<uint, Output=Element> + IndexMut<uint, Ou
} }
/// Apply a function to each element. /// Apply a function to each element.
fn map(&mut self, op: |Element| -> Element) -> Self; fn map<F>(&mut self, op: F) -> Self
where F: FnMut(Element) -> Element;
} }
/// A column-major array /// A column-major array
@ -86,7 +87,8 @@ pub trait Array2<Column: Array1<Element>+'static, Row: Array1<Element>, Element:
} }
/// Apply a function to each column. /// Apply a function to each column.
fn map(&mut self, op: |&Column| -> Column) -> Self; fn map<F>(&mut self, op: F) -> Self
where F: FnMut(&Column) -> Column;
} }
/// Homogeneous arrays of elements that can be converted to and from `[T, ..N]` /// Homogeneous arrays of elements that can be converted to and from `[T, ..N]`

View file

@ -16,11 +16,6 @@
#![crate_type = "rlib"] #![crate_type = "rlib"]
#![crate_type = "dylib"] #![crate_type = "dylib"]
#![feature(globs)]
#![feature(macro_rules)]
#![feature(old_orphan_check)]
#![feature(associated_types)]
//! Computer graphics-centric math. //! Computer graphics-centric math.
//! //!
//! This crate provides useful mathematical primitives and operations on them. //! This crate provides useful mathematical primitives and operations on them.

View file

@ -563,7 +563,7 @@ impl<S: Copy + 'static> Array2<Vector2<S>, Vector2<S>, S> for Matrix2<S> {
} }
#[inline] #[inline]
fn map(&mut self, op: |&Vector2<S>| -> Vector2<S>) -> Matrix2<S> { fn map<F>(&mut self, mut op: F) -> Matrix2<S> where F: FnMut(&Vector2<S>) -> Vector2<S> {
self.x = op(&self.x); self.x = op(&self.x);
self.y = op(&self.y); self.y = op(&self.y);
*self *self
@ -649,7 +649,7 @@ impl<S: Copy + 'static> Array2<Vector3<S>, Vector3<S>, S> for Matrix3<S> {
} }
#[inline] #[inline]
fn map(&mut self, op: |&Vector3<S>| -> Vector3<S>) -> Matrix3<S> { fn map<F>(&mut self, mut op: F) -> Matrix3<S> where F: FnMut(&Vector3<S>) -> Vector3<S> {
self.x = op(&self.x); self.x = op(&self.x);
self.y = op(&self.y); self.y = op(&self.y);
self.z = op(&self.z); self.z = op(&self.z);
@ -740,7 +740,7 @@ impl<S: Copy + 'static> Array2<Vector4<S>, Vector4<S>, S> for Matrix4<S> {
} }
#[inline] #[inline]
fn map(&mut self, op: |&Vector4<S>| -> Vector4<S>) -> Matrix4<S> { fn map<F>(&mut self, mut op: F) -> Matrix4<S> where F: FnMut(&Vector4<S>) -> Vector4<S> {
self.x = op(&self.x); self.x = op(&self.x);
self.y = op(&self.y); self.y = op(&self.y);
self.z = op(&self.z); self.z = op(&self.z);
@ -1188,7 +1188,7 @@ impl<S: BaseFloat + 'static> Matrix<S, Vector4<S>> for Matrix4<S> {
let one: S = one(); let one: S = one();
let inv_det = one / det; let inv_det = one / det;
let t = self.transpose(); let t = self.transpose();
let cf = |i, j| { let cf = |&: i, j| {
let mat = match i { let mat = match i {
0 => Matrix3::from_cols(t.y.truncate_n(j), 0 => Matrix3::from_cols(t.y.truncate_n(j),
t.z.truncate_n(j), t.z.truncate_n(j),

View file

@ -17,7 +17,7 @@ use approx::ApproxEq;
use std::cmp; use std::cmp;
use std::fmt; use std::fmt;
use std::num::{FloatMath, Int, NumCast, Float}; use std::num::{Float, Int, NumCast};
use std::ops::*; use std::ops::*;
/// A trait providing a [partial ordering](http://mathworld.wolfram.com/PartialOrder.html). /// A trait providing a [partial ordering](http://mathworld.wolfram.com/PartialOrder.html).
@ -158,7 +158,7 @@ impl BaseInt for u64 {}
impl BaseInt for uint {} impl BaseInt for uint {}
/// Base floating point types /// Base floating point types
pub trait BaseFloat : BaseNum + FloatMath + ApproxEq<Self> {} pub trait BaseFloat : BaseNum + Float + ApproxEq<Self> {}
impl BaseFloat for f32 {} impl BaseFloat for f32 {}
impl BaseFloat for f64 {} impl BaseFloat for f64 {}

View file

@ -153,7 +153,7 @@ impl<S: BaseNum> IndexMut<uint> for Point2<S> {
impl<S: BaseNum> Array1<S> for Point2<S> { impl<S: BaseNum> Array1<S> for Point2<S> {
#[inline] #[inline]
fn map(&mut self, op: |S| -> S) -> Point2<S> { fn map<F>(&mut self, mut op: F) -> Point2<S> where F: FnMut(S) -> S {
self.x = op(self.x); self.x = op(self.x);
self.y = op(self.y); self.y = op(self.y);
*self *self
@ -311,7 +311,7 @@ impl<S: BaseNum> IndexMut<uint> for Point3<S> {
impl<S: BaseNum> Array1<S> for Point3<S> { impl<S: BaseNum> Array1<S> for Point3<S> {
#[inline] #[inline]
fn map(&mut self, op: |S| -> S) -> Point3<S> { fn map<F>(&mut self, mut op: F) -> Point3<S> where F: FnMut(S) -> S {
self.x = op(self.x); self.x = op(self.x);
self.y = op(self.y); self.y = op(self.y);
self.z = op(self.z); self.z = op(self.z);

View file

@ -41,7 +41,7 @@ pub trait ToQuaternion<S: BaseFloat> {
impl<S: Copy + BaseFloat> Array1<S> for Quaternion<S> { impl<S: Copy + BaseFloat> Array1<S> for Quaternion<S> {
#[inline] #[inline]
fn map(&mut self, op: |S| -> S) -> Quaternion<S> { fn map<F>(&mut self, mut op: F) -> Quaternion<S> where F: FnMut(S) -> S {
self.s = op(self.s); self.s = op(self.s);
self.v.x = op(self.v.x); self.v.x = op(self.v.x);
self.v.y = op(self.v.y); self.v.y = op(self.v.y);

View file

@ -271,7 +271,7 @@ macro_rules! vec(
impl<$S: Copy> Array1<$S> for $Self<$S> { impl<$S: Copy> Array1<$S> for $Self<$S> {
#[inline] #[inline]
fn map(&mut self, op: |$S| -> $S) -> $Self<$S> { fn map<F>(&mut self, mut op: F) -> $Self<$S> where F: FnMut($S) -> $S {
$(self.$field = op(self.$field);)+ *self $(self.$field = op(self.$field);)+ *self
} }
} }

View file

@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![feature(globs)]
extern crate cgmath; extern crate cgmath;

View file

@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![feature(globs)]
extern crate cgmath; extern crate cgmath;

View file

@ -13,10 +13,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![feature(globs)]
#![feature(phase)] #![feature(phase)]
#[phase(plugin, link)] #[macro_use]
extern crate cgmath; extern crate cgmath;
use cgmath::*; use cgmath::*;

View file

@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![feature(globs)]
extern crate cgmath; extern crate cgmath;

View file

@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![feature(globs)]
extern crate cgmath; extern crate cgmath;

View file

@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![feature(globs)]
extern crate cgmath; extern crate cgmath;

View file

@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![feature(globs)]
extern crate cgmath; extern crate cgmath;

View file

@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![feature(globs)]
extern crate cgmath; extern crate cgmath;

View file

@ -13,12 +13,12 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![feature(globs)]
extern crate cgmath; extern crate cgmath;
use cgmath::*; use cgmath::*;
use std::num::FloatMath; use std::num::Float;
#[test] #[test]
fn test_intersection() { fn test_intersection() {

View file

@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![feature(globs)]
extern crate cgmath; extern crate cgmath;

View file

@ -13,16 +13,12 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#![feature(globs)] #[macro_use]
#![feature(phase)]
#[phase(plugin)]
extern crate cgmath;
extern crate cgmath; extern crate cgmath;
use cgmath::*; use cgmath::*;
use std::f64; use std::f64;
use std::num::{Float, FloatMath}; use std::num::Float;
#[test] #[test]
fn test_from_value() { fn test_from_value() {