Merge pull request #57 from tomaka/master

Update for rustc
This commit is contained in:
Sébastien Crozet 2014-12-23 20:20:46 +01:00
commit bcd425e12a
13 changed files with 30 additions and 30 deletions

View File

@ -576,7 +576,7 @@ pub fn inv_rotate<V, M: Rotate<V>>(m: &M, v: &V) -> V {
/// Rotates a copy of `m` by `amount` using `center` as the pivot point.
#[inline(always)]
pub fn append_rotation_wrt_point<LV: Neg<LV>,
pub fn append_rotation_wrt_point<LV: Neg<LV> + Copy,
AV,
M: RotationWithTranslation<LV, AV>>(
m: &M,
@ -587,7 +587,7 @@ pub fn append_rotation_wrt_point<LV: Neg<LV>,
/// Rotates a copy of `m` by `amount` using `m.translation()` as the pivot point.
#[inline(always)]
pub fn append_rotation_wrt_center<LV: Neg<LV>,
pub fn append_rotation_wrt_center<LV: Neg<LV> + Copy,
AV,
M: RotationWithTranslation<LV, AV>>(
m: &M,

View File

@ -4,7 +4,7 @@
use std::rand::Rand;
use std::rand;
use std::slice::{Items, MutItems};
use std::slice::{Iter, IterMut};
use std::iter::FromIterator;
use traits::operations::{ApproxEq, Axpy};
use traits::geometry::{Dot, Norm};

View File

@ -110,14 +110,14 @@ macro_rules! dvec_impl(
impl<N> Iterable<N> for $dvec<N> {
#[inline]
fn iter<'l>(&'l self) -> Items<'l, N> {
fn iter<'l>(&'l self) -> Iter<'l, N> {
self.as_slice().iter()
}
}
impl<N> IterableMut<N> for $dvec<N> {
#[inline]
fn iter_mut<'l>(&'l mut self) -> MutItems<'l, N> {
fn iter_mut<'l>(&'l mut self) -> IterMut<'l, N> {
self.as_mut_slice().iter_mut()
}
}
@ -250,9 +250,9 @@ macro_rules! dvec_impl(
}
}
impl<N: Neg<N> + Zero> Neg<$dvec<N>> for $dvec<N> {
impl<N: Neg<N> + Zero + Copy> Neg<$dvec<N>> for $dvec<N> {
#[inline]
fn neg(&self) -> $dvec<N> {
fn neg(self) -> $dvec<N> {
FromIterator::from_iter(self.as_slice().iter().map(|a| -*a))
}
}

View File

@ -4,7 +4,7 @@
use std::mem;
use traits::operations::ApproxEq;
use std::slice::{Items, MutItems};
use std::slice::{Iter, IterMut};
use structs::vec::{Vec1, Vec2, Vec3, Vec4, Vec5, Vec6};
use structs::pnt::{Pnt1, Pnt4, Pnt5, Pnt6};
use structs::dvec::{DVec1, DVec2, DVec3, DVec4, DVec5, DVec6};

View File

@ -181,7 +181,7 @@ macro_rules! iterable_impl(
($t: ident, $dim: expr) => (
impl<N> Iterable<N> for $t<N> {
#[inline]
fn iter<'l>(&'l self) -> Items<'l, N> {
fn iter<'l>(&'l self) -> Iter<'l, N> {
unsafe {
mem::transmute::<&'l $t<N>, &'l [N, ..$dim * $dim]>(self).iter()
}
@ -194,7 +194,7 @@ macro_rules! iterable_mut_impl(
($t: ident, $dim: expr) => (
impl<N> IterableMut<N> for $t<N> {
#[inline]
fn iter_mut<'l>(&'l mut self) -> MutItems<'l, N> {
fn iter_mut<'l>(&'l mut self) -> IterMut<'l, N> {
unsafe {
mem::transmute::<&'l mut $t<N>, &'l mut [N, ..$dim * $dim]>(self).iter_mut()
}

View File

@ -3,7 +3,7 @@
#![allow(missing_docs)] // we allow missing to avoid having to document the point components.
use std::mem;
use std::slice::{Items, MutItems};
use std::slice::{Iter, IterMut};
use std::iter::{Iterator, FromIterator};
use traits::operations::{ApproxEq, POrd, POrdering, Axpy, ScalarAdd, ScalarSub, ScalarMul,
ScalarDiv};

View File

@ -5,7 +5,7 @@
use std::mem;
use std::num;
use std::rand::{Rand, Rng};
use std::slice::{Items, MutItems};
use std::slice::{Iter, IterMut};
use structs::{Vec3, Pnt3, Rot3, Mat3};
use traits::operations::{ApproxEq, Inv, POrd, POrdering, Axpy, ScalarAdd, ScalarSub, ScalarMul,
ScalarDiv};
@ -54,7 +54,7 @@ impl<N> Quat<N> {
}
}
impl<N: Neg<N>> Quat<N> {
impl<N: Neg<N> + Copy> Quat<N> {
/// Replaces this quaternion by its conjugate.
#[inline]
pub fn conjugate(&mut self) {

View File

@ -18,7 +18,7 @@ pub struct Rot2<N> {
submat: Mat2<N>
}
impl<N: Clone + BaseFloat + Neg<N>> Rot2<N> {
impl<N: Clone + BaseFloat + Neg<N> + Copy> Rot2<N> {
/// Builds a 2 dimensional rotation matrix from an angle in radian.
pub fn new(angle: Vec1<N>) -> Rot2<N> {
let (sia, coa) = angle.x.sin_cos();
@ -66,7 +66,7 @@ impl<N: BaseFloat + Clone> Rotation<Vec1<N>> for Rot2<N> {
}
}
impl<N: Clone + Rand + BaseFloat + Neg<N>> Rand for Rot2<N> {
impl<N: Clone + Rand + BaseFloat + Neg<N> + Copy> Rand for Rot2<N> {
#[inline]
fn rand<R: Rng>(rng: &mut R) -> Rot2<N> {
Rot2::new(rng.gen())

View File

@ -1,5 +1,5 @@
use std::mem;
use std::slice::{Items, MutItems};
use std::slice::{Iter, IterMut};
use std::iter::{Iterator, FromIterator};
use traits::operations::ApproxEq;
use traits::structure::{Iterable, IterableMut, Indexable, Basis, Dim, Shape, BaseFloat, BaseNum,
@ -66,14 +66,14 @@ impl<N> Indexable<uint, N> for vec::Vec0<N> {
impl<N: 'static> Iterable<N> for vec::Vec0<N> {
#[inline]
fn iter<'l>(&'l self) -> Items<'l, N> {
fn iter<'l>(&'l self) -> Iter<'l, N> {
unsafe { mem::transmute::<&'l vec::Vec0<N>, &'l [N, ..0]>(self).iter() }
}
}
impl<N: 'static> IterableMut<N> for vec::Vec0<N> {
#[inline]
fn iter_mut<'l>(&'l mut self) -> MutItems<'l, N> {
fn iter_mut<'l>(&'l mut self) -> IterMut<'l, N> {
unsafe { mem::transmute::<&'l mut vec::Vec0<N>, &'l mut [N, ..0]>(self).iter_mut() }
}
}
@ -112,9 +112,9 @@ impl<N, T> Sub<T, vec::Vec0<N>> for vec::Vec0<N> {
}
}
impl<N: Neg<N>> Neg<vec::Vec0<N>> for vec::Vec0<N> {
impl<N: Neg<N> + Copy> Neg<vec::Vec0<N>> for vec::Vec0<N> {
#[inline]
fn neg(&self) -> vec::Vec0<N> {
fn neg(self) -> vec::Vec0<N> {
vec::Vec0
}
}

View File

@ -3,7 +3,7 @@
#![allow(missing_docs)] // we allow missing to avoid having to document the dispatch traits.
use std::mem;
use std::slice::{Items, MutItems};
use std::slice::{Iter, IterMut};
use std::iter::{Iterator, FromIterator};
use traits::operations::{ApproxEq, POrd, POrdering, Axpy, ScalarAdd, ScalarSub, ScalarMul,
ScalarDiv, Absolute};

View File

@ -269,7 +269,7 @@ macro_rules! iterable_impl(
($t: ident, $dim: expr) => (
impl<N> Iterable<N> for $t<N> {
#[inline]
fn iter<'l>(&'l self) -> Items<'l, N> {
fn iter<'l>(&'l self) -> Iter<'l, N> {
unsafe {
mem::transmute::<&'l $t<N>, &'l [N, ..$dim]>(self).iter()
}
@ -282,7 +282,7 @@ macro_rules! iterable_mut_impl(
($t: ident, $dim: expr) => (
impl<N> IterableMut<N> for $t<N> {
#[inline]
fn iter_mut<'l>(&'l mut self) -> MutItems<'l, N> {
fn iter_mut<'l>(&'l mut self) -> IterMut<'l, N> {
unsafe {
mem::transmute::<&'l mut $t<N>, &'l mut [N, ..$dim]>(self).iter_mut()
}
@ -480,9 +480,9 @@ macro_rules! scalar_div_impl(
macro_rules! neg_impl(
($t: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Neg<N>> Neg<$t<N>> for $t<N> {
impl<N: Neg<N> + Copy> Neg<$t<N>> for $t<N> {
#[inline]
fn neg(&self) -> $t<N> {
fn neg(self) -> $t<N> {
$t::new(-self.$comp0 $(, -self.$compN )*)
}
}

View File

@ -82,7 +82,7 @@ pub trait Rotate<V> {
///
/// Those operations are automatically implemented in term of the `Rotation` and `Translation`
/// traits.
pub trait RotationWithTranslation<LV: Neg<LV>, AV>: Rotation<AV> + Translation<LV> {
pub trait RotationWithTranslation<LV: Neg<LV> + Copy, AV>: Rotation<AV> + Translation<LV> {
/// Applies a rotation centered on a specific point.
///
/// # Arguments
@ -136,7 +136,7 @@ pub trait RotationWithTranslation<LV: Neg<LV>, AV>: Rotation<AV> + Translation<L
}
}
impl<LV: Neg<LV>, AV, M: Rotation<AV> + Translation<LV>> RotationWithTranslation<LV, AV> for M {
impl<LV: Neg<LV> + Copy, AV, M: Rotation<AV> + Translation<LV>> RotationWithTranslation<LV, AV> for M {
}
/// Trait of transformation having a rotation extractable as a rotation matrix. This can typically

View File

@ -3,7 +3,7 @@
use std::f32;
use std::f64;
use std::num::{Int, Float, FloatMath};
use std::slice::{Items, MutItems};
use std::slice::{Iter, IterMut};
use traits::operations::{RMul, LMul, Axpy, Transpose, Inv, Absolute};
use traits::geometry::{Dot, Norm, Orig};
@ -209,7 +209,7 @@ pub trait Indexable<I, Res>: Shape<I, Res> + IndexMut<I, Res> {
/// Traits of objects which can be iterated through like a vector.
pub trait Iterable<N> {
/// Gets a vector-like read-only iterator.
fn iter<'l>(&'l self) -> Items<'l, N>;
fn iter<'l>(&'l self) -> Iter<'l, N>;
}
/// This is a workaround of current Rust limitations.
@ -217,7 +217,7 @@ pub trait Iterable<N> {
/// Traits of mutable objects which can be iterated through like a vector.
pub trait IterableMut<N> {
/// Gets a vector-like read-write iterator.
fn iter_mut<'l>(&'l mut self) -> MutItems<'l, N>;
fn iter_mut<'l>(&'l mut self) -> IterMut<'l, N>;
}
/*