Update to the last Rust.
Version of rustc: 0.10-pre (d4640f9 2014-01-20 11:41:29 -0800) This also removes the `PVec` type due to lack of use-case.
This commit is contained in:
parent
9dd8bb4ea2
commit
8de8c94b45
|
@ -45,7 +45,7 @@ pub use structs::{
|
|||
Mat1, Mat2, Mat3, Mat4,
|
||||
Mat5, Mat6,
|
||||
Rot2, Rot3, Rot4,
|
||||
Vec0, Vec1, Vec2, Vec3, PVec3, Vec4, Vec5, Vec6
|
||||
Vec0, Vec1, Vec2, Vec3, Vec4, Vec5, Vec6
|
||||
};
|
||||
|
||||
//
|
||||
|
|
|
@ -296,7 +296,7 @@ macro_rules! inv_impl(
|
|||
|
||||
macro_rules! to_homogeneous_impl(
|
||||
($t: ident, $th: ident) => (
|
||||
impl<N: One + Zero + Clone> ToHomogeneous<$th<N>> for $t<N> {
|
||||
impl<N: Num + Clone> ToHomogeneous<$th<N>> for $t<N> {
|
||||
fn to_homogeneous(m: &$t<N>) -> $th<N> {
|
||||
let mut res = ToHomogeneous::to_homogeneous(&m.rotation);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ mod metal;
|
|||
mod mat_macros;
|
||||
|
||||
/// Special identity matrix. All its operation are no-ops.
|
||||
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Rand, Zero, ToStr)]
|
||||
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Rand, ToStr)]
|
||||
pub struct Identity;
|
||||
|
||||
impl Identity {
|
||||
|
|
|
@ -45,7 +45,7 @@ macro_rules! mat_cast_impl(
|
|||
|
||||
macro_rules! add_impl(
|
||||
($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
|
||||
impl<N: Clone + Add<N, N>> $trhs<N, $t<N>> for $t<N> {
|
||||
impl<N: Add<N, N>> $trhs<N, $t<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn binop(left: &$t<N>, right: &$t<N>) -> $t<N> {
|
||||
$t::new(left.$comp0 + right.$comp0 $(, left.$compN + right.$compN)*)
|
||||
|
@ -56,7 +56,7 @@ macro_rules! add_impl(
|
|||
|
||||
macro_rules! sub_impl(
|
||||
($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
|
||||
impl<N: Clone + Sub<N, N>> $trhs<N, $t<N>> for $t<N> {
|
||||
impl<N: Sub<N, N>> $trhs<N, $t<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn binop(left: &$t<N>, right: &$t<N>) -> $t<N> {
|
||||
$t::new(left.$comp0 - right.$comp0 $(, left.$compN - right.$compN)*)
|
||||
|
@ -148,7 +148,7 @@ macro_rules! iterable_mut_impl(
|
|||
|
||||
macro_rules! one_impl(
|
||||
($t: ident, $value0: expr $(, $valueN: expr)* ) => (
|
||||
impl<N: Clone + One + Zero> One for $t<N> {
|
||||
impl<N: Clone + Num> One for $t<N> {
|
||||
#[inline]
|
||||
fn one() -> $t<N> {
|
||||
$t::new($value0() $(, $valueN() )*)
|
||||
|
@ -472,7 +472,7 @@ macro_rules! approx_eq_impl(
|
|||
|
||||
macro_rules! to_homogeneous_impl(
|
||||
($t: ident, $t2: ident, $dim: expr, $dim2: expr) => (
|
||||
impl<N: One + Zero + Clone> ToHomogeneous<$t2<N>> for $t<N> {
|
||||
impl<N: Num + Clone> ToHomogeneous<$t2<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn to_homogeneous(m: &$t<N>) -> $t2<N> {
|
||||
let mut res: $t2<N> = One::one();
|
||||
|
@ -491,7 +491,7 @@ macro_rules! to_homogeneous_impl(
|
|||
|
||||
macro_rules! from_homogeneous_impl(
|
||||
($t: ident, $t2: ident, $dim: expr, $dim2: expr) => (
|
||||
impl<N: One + Zero + Clone> FromHomogeneous<$t2<N>> for $t<N> {
|
||||
impl<N: Num + Clone> FromHomogeneous<$t2<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn from(m: &$t2<N>) -> $t<N> {
|
||||
let mut res: $t<N> = One::one();
|
||||
|
@ -513,7 +513,7 @@ macro_rules! from_homogeneous_impl(
|
|||
|
||||
macro_rules! outer_impl(
|
||||
($t: ident, $m: ident) => (
|
||||
impl<N: Mul<N, N> + Zero + Clone> Outer<$m<N>> for $t<N> {
|
||||
impl<N: Clone + Mul<N, N> + Zero> Outer<$m<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn outer(a: &$t<N>, b: &$t<N>) -> $m<N> {
|
||||
let mut res: $m<N> = Zero::zero();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
pub use self::dmat::DMat;
|
||||
pub use self::dvec::DVec;
|
||||
pub use self::vec::{Vec0, Vec1, Vec2, Vec3, PVec3, Vec4, Vec5, Vec6};
|
||||
pub use self::vec::{Vec0, Vec1, Vec2, Vec3, Vec4, Vec5, Vec6};
|
||||
pub use self::mat::{Identity, Mat1, Mat2, Mat3, Mat4, Mat5, Mat6};
|
||||
pub use self::rot::{Rot2, Rot3, Rot4};
|
||||
pub use self::iso::{Iso2, Iso3, Iso4};
|
||||
|
|
|
@ -68,7 +68,7 @@ macro_rules! rotation_matrix_impl(
|
|||
|
||||
macro_rules! one_impl(
|
||||
($t: ident) => (
|
||||
impl<N: One + Zero + Clone> One for $t<N> {
|
||||
impl<N: Num + Clone> One for $t<N> {
|
||||
#[inline]
|
||||
fn one() -> $t<N> {
|
||||
$t { submat: One::one() }
|
||||
|
@ -188,7 +188,7 @@ macro_rules! col_impl(
|
|||
|
||||
macro_rules! to_homogeneous_impl(
|
||||
($t: ident, $tm: ident) => (
|
||||
impl<N: One + Zero + Clone> ToHomogeneous<$tm<N>> for $t<N> {
|
||||
impl<N: Num + Clone> ToHomogeneous<$tm<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn to_homogeneous(m: &$t<N>) -> $tm<N> {
|
||||
ToHomogeneous::to_homogeneous(&m.submat)
|
||||
|
|
|
@ -97,7 +97,7 @@ impl<N: Neg<N>> Neg<vec::Vec0<N>> for vec::Vec0<N> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<N: Num + Clone> Dot<N> for vec::Vec0<N> {
|
||||
impl<N: Num> Dot<N> for vec::Vec0<N> {
|
||||
#[inline]
|
||||
fn dot(_: &vec::Vec0<N>, _: &vec::Vec0<N>) -> N {
|
||||
Zero::zero()
|
||||
|
@ -159,7 +159,7 @@ impl<N: Clone + Add<N, N> + Neg<N>> Translation<vec::Vec0<N>> for vec::Vec0<N> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<N: Clone + Num + Real> Norm<N> for vec::Vec0<N> {
|
||||
impl<N: Num + Real> Norm<N> for vec::Vec0<N> {
|
||||
#[inline]
|
||||
fn sqnorm(_: &vec::Vec0<N>) -> N {
|
||||
Zero::zero()
|
||||
|
@ -198,7 +198,7 @@ impl<N: ApproxEq<N>> ApproxEq<N> for vec::Vec0<N> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<N: Clone + One> One for vec::Vec0<N> {
|
||||
impl<N: One> One for vec::Vec0<N> {
|
||||
#[inline]
|
||||
fn one() -> vec::Vec0<N> {
|
||||
vec::Vec0
|
||||
|
@ -212,7 +212,7 @@ impl<N> FromIterator<N> for vec::Vec0<N> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<N: Bounded + Clone> Bounded for vec::Vec0<N> {
|
||||
impl<N: Bounded> Bounded for vec::Vec0<N> {
|
||||
#[inline]
|
||||
fn max_value() -> vec::Vec0<N> {
|
||||
vec::Vec0
|
||||
|
|
|
@ -105,9 +105,9 @@ translation_impl!(Vec1)
|
|||
norm_impl!(Vec1, x)
|
||||
approx_eq_impl!(Vec1, x)
|
||||
round_impl!(Vec1, x)
|
||||
one_impl!(Vec1)
|
||||
one_impl!(Vec1, x)
|
||||
from_iterator_impl!(Vec1, iterator)
|
||||
bounded_impl!(Vec1)
|
||||
bounded_impl!(Vec1, x)
|
||||
iterable_impl!(Vec1, 1)
|
||||
iterable_mut_impl!(Vec1, 1)
|
||||
to_homogeneous_impl!(Vec1, Vec2, y, x)
|
||||
|
@ -204,9 +204,9 @@ translation_impl!(Vec2)
|
|||
norm_impl!(Vec2, x, y)
|
||||
approx_eq_impl!(Vec2, x, y)
|
||||
round_impl!(Vec2, x, y)
|
||||
one_impl!(Vec2)
|
||||
one_impl!(Vec2, x, y)
|
||||
from_iterator_impl!(Vec2, iterator, iterator)
|
||||
bounded_impl!(Vec2)
|
||||
bounded_impl!(Vec2, x, y)
|
||||
iterable_impl!(Vec2, 2)
|
||||
iterable_mut_impl!(Vec2, 2)
|
||||
to_homogeneous_impl!(Vec2, Vec3, z, x, y)
|
||||
|
@ -308,9 +308,9 @@ translation_impl!(Vec3)
|
|||
norm_impl!(Vec3, x, y ,z)
|
||||
approx_eq_impl!(Vec3, x, y, z)
|
||||
round_impl!(Vec3, x, y, z)
|
||||
one_impl!(Vec3)
|
||||
one_impl!(Vec3, x, y, z)
|
||||
from_iterator_impl!(Vec3, iterator, iterator, iterator)
|
||||
bounded_impl!(Vec3)
|
||||
bounded_impl!(Vec3, x, y, z)
|
||||
iterable_impl!(Vec3, 3)
|
||||
iterable_mut_impl!(Vec3, 3)
|
||||
to_homogeneous_impl!(Vec3, Vec4, w, x, y, z)
|
||||
|
@ -320,117 +320,6 @@ rotate_impl!(Vec3)
|
|||
transform_impl!(Vec3)
|
||||
|
||||
|
||||
/// Vector of dimension 3 with an extra component for padding.
|
||||
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)]
|
||||
pub struct PVec3<N> {
|
||||
/// First component of the vector.
|
||||
x: N,
|
||||
/// Second component of the vector.
|
||||
y: N,
|
||||
/// Third component of the vector.
|
||||
z: N,
|
||||
// Unused component, for padding
|
||||
priv _unused: N
|
||||
}
|
||||
|
||||
impl<N: Clone> PVec3<N> {
|
||||
/// Creates a new 3d vector.
|
||||
pub fn new(x: N, y: N, z: N) -> PVec3<N> {
|
||||
PVec3 { x: x.clone(), y: y, z: z, _unused: x }
|
||||
}
|
||||
}
|
||||
|
||||
double_dispatch_binop_decl_trait!(PVec3, PVec3MulRhs)
|
||||
double_dispatch_binop_decl_trait!(PVec3, PVec3DivRhs)
|
||||
double_dispatch_binop_decl_trait!(PVec3, PVec3AddRhs)
|
||||
double_dispatch_binop_decl_trait!(PVec3, PVec3SubRhs)
|
||||
double_dispatch_cast_decl_trait!(PVec3, PVec3Cast)
|
||||
mul_redispatch_impl!(PVec3, PVec3MulRhs)
|
||||
div_redispatch_impl!(PVec3, PVec3DivRhs)
|
||||
add_redispatch_impl!(PVec3, PVec3AddRhs)
|
||||
sub_redispatch_impl!(PVec3, PVec3SubRhs)
|
||||
cast_redispatch_impl!(PVec3, PVec3Cast)
|
||||
ord_impl!(PVec3, x, y, z)
|
||||
orderable_impl!(PVec3, x, y, z)
|
||||
vec_axis_impl!(PVec3, x, y, z)
|
||||
vec_cast_impl!(PVec3, PVec3Cast, x, y, z)
|
||||
indexable_impl!(PVec3, 3)
|
||||
at_fast_impl!(PVec3, 3)
|
||||
new_repeat_impl!(PVec3, val, x, y, z, _unused)
|
||||
dim_impl!(PVec3, 3)
|
||||
container_impl!(PVec3)
|
||||
// (specialized) basis_impl!(PVec3, 1)
|
||||
add_impl!(PVec3, PVec3AddRhs, x, y, z)
|
||||
sub_impl!(PVec3, PVec3SubRhs, x, y, z)
|
||||
mul_impl!(PVec3, PVec3MulRhs, x, y, z)
|
||||
div_impl!(PVec3, PVec3DivRhs, x, y, z)
|
||||
neg_impl!(PVec3, x, y, z)
|
||||
dot_impl!(PVec3, x, y, z)
|
||||
scalar_mul_impl!(PVec3, f64, PVec3MulRhs, x, y, z)
|
||||
scalar_mul_impl!(PVec3, f32, PVec3MulRhs, x, y, z)
|
||||
scalar_mul_impl!(PVec3, u64, PVec3MulRhs, x, y, z)
|
||||
scalar_mul_impl!(PVec3, u32, PVec3MulRhs, x, y, z)
|
||||
scalar_mul_impl!(PVec3, u16, PVec3MulRhs, x, y, z)
|
||||
scalar_mul_impl!(PVec3, u8, PVec3MulRhs, x, y, z)
|
||||
scalar_mul_impl!(PVec3, i64, PVec3MulRhs, x, y, z)
|
||||
scalar_mul_impl!(PVec3, i32, PVec3MulRhs, x, y, z)
|
||||
scalar_mul_impl!(PVec3, i16, PVec3MulRhs, x, y, z)
|
||||
scalar_mul_impl!(PVec3, i8, PVec3MulRhs, x, y, z)
|
||||
scalar_mul_impl!(PVec3, uint, PVec3MulRhs, x, y, z)
|
||||
scalar_mul_impl!(PVec3, int, PVec3MulRhs, x, y, z)
|
||||
scalar_div_impl!(PVec3, f64, PVec3DivRhs, x, y, z)
|
||||
scalar_div_impl!(PVec3, f32, PVec3DivRhs, x, y, z)
|
||||
scalar_div_impl!(PVec3, u64, PVec3DivRhs, x, y, z)
|
||||
scalar_div_impl!(PVec3, u32, PVec3DivRhs, x, y, z)
|
||||
scalar_div_impl!(PVec3, u16, PVec3DivRhs, x, y, z)
|
||||
scalar_div_impl!(PVec3, u8, PVec3DivRhs, x, y, z)
|
||||
scalar_div_impl!(PVec3, i64, PVec3DivRhs, x, y, z)
|
||||
scalar_div_impl!(PVec3, i32, PVec3DivRhs, x, y, z)
|
||||
scalar_div_impl!(PVec3, i16, PVec3DivRhs, x, y, z)
|
||||
scalar_div_impl!(PVec3, i8, PVec3DivRhs, x, y, z)
|
||||
scalar_div_impl!(PVec3, uint, PVec3DivRhs, x, y, z)
|
||||
scalar_div_impl!(PVec3, int, PVec3DivRhs, x, y, z)
|
||||
scalar_add_impl!(PVec3, f64, PVec3AddRhs, x, y, z)
|
||||
scalar_add_impl!(PVec3, f32, PVec3AddRhs, x, y, z)
|
||||
scalar_add_impl!(PVec3, u64, PVec3AddRhs, x, y, z)
|
||||
scalar_add_impl!(PVec3, u32, PVec3AddRhs, x, y, z)
|
||||
scalar_add_impl!(PVec3, u16, PVec3AddRhs, x, y, z)
|
||||
scalar_add_impl!(PVec3, u8, PVec3AddRhs, x, y, z)
|
||||
scalar_add_impl!(PVec3, i64, PVec3AddRhs, x, y, z)
|
||||
scalar_add_impl!(PVec3, i32, PVec3AddRhs, x, y, z)
|
||||
scalar_add_impl!(PVec3, i16, PVec3AddRhs, x, y, z)
|
||||
scalar_add_impl!(PVec3, i8, PVec3AddRhs, x, y, z)
|
||||
scalar_add_impl!(PVec3, uint, PVec3AddRhs, x, y, z)
|
||||
scalar_add_impl!(PVec3, int, PVec3AddRhs, x, y, z)
|
||||
scalar_sub_impl!(PVec3, f64, PVec3SubRhs, x, y, z)
|
||||
scalar_sub_impl!(PVec3, f32, PVec3SubRhs, x, y, z)
|
||||
scalar_sub_impl!(PVec3, u64, PVec3SubRhs, x, y, z)
|
||||
scalar_sub_impl!(PVec3, u32, PVec3SubRhs, x, y, z)
|
||||
scalar_sub_impl!(PVec3, u16, PVec3SubRhs, x, y, z)
|
||||
scalar_sub_impl!(PVec3, u8, PVec3SubRhs, x, y, z)
|
||||
scalar_sub_impl!(PVec3, i64, PVec3SubRhs, x, y, z)
|
||||
scalar_sub_impl!(PVec3, i32, PVec3SubRhs, x, y, z)
|
||||
scalar_sub_impl!(PVec3, i16, PVec3SubRhs, x, y, z)
|
||||
scalar_sub_impl!(PVec3, i8, PVec3SubRhs, x, y, z)
|
||||
scalar_sub_impl!(PVec3, uint, PVec3SubRhs, x, y, z)
|
||||
scalar_sub_impl!(PVec3, int, PVec3SubRhs, x, y, z)
|
||||
translation_impl!(PVec3)
|
||||
norm_impl!(PVec3, x, y, z)
|
||||
approx_eq_impl!(PVec3, x, y, z)
|
||||
round_impl!(PVec3, x, y, z)
|
||||
one_impl!(PVec3)
|
||||
from_iterator_impl!(PVec3, iterator, iterator, iterator)
|
||||
bounded_impl!(PVec3)
|
||||
iterable_impl!(PVec3, 3)
|
||||
iterable_mut_impl!(PVec3, 3)
|
||||
to_homogeneous_impl!(PVec3, Vec4, w, x, y, z)
|
||||
from_homogeneous_impl!(PVec3, Vec4, w, x, y, z)
|
||||
translate_impl!(PVec3)
|
||||
rotate_impl!(PVec3)
|
||||
transform_impl!(PVec3)
|
||||
|
||||
|
||||
|
||||
/// Vector of dimension 4.
|
||||
#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)]
|
||||
pub struct Vec4<N> {
|
||||
|
@ -523,9 +412,9 @@ translation_impl!(Vec4)
|
|||
norm_impl!(Vec4, x, y, z, w)
|
||||
approx_eq_impl!(Vec4, x, y, z, w)
|
||||
round_impl!(Vec4, x, y, z, w)
|
||||
one_impl!(Vec4)
|
||||
one_impl!(Vec4, x, y, z, w)
|
||||
from_iterator_impl!(Vec4, iterator, iterator, iterator, iterator)
|
||||
bounded_impl!(Vec4)
|
||||
bounded_impl!(Vec4, x, y, z, w)
|
||||
iterable_impl!(Vec4, 4)
|
||||
iterable_mut_impl!(Vec4, 4)
|
||||
to_homogeneous_impl!(Vec4, Vec5, a, x, y, z, w)
|
||||
|
@ -628,9 +517,9 @@ translation_impl!(Vec5)
|
|||
norm_impl!(Vec5, x, y, z, w, a)
|
||||
approx_eq_impl!(Vec5, x, y, z, w, a)
|
||||
round_impl!(Vec5, x, y, z, w, a)
|
||||
one_impl!(Vec5)
|
||||
one_impl!(Vec5, x, y, z, w, a)
|
||||
from_iterator_impl!(Vec5, iterator, iterator, iterator, iterator, iterator)
|
||||
bounded_impl!(Vec5)
|
||||
bounded_impl!(Vec5, x, y, z, w, a)
|
||||
iterable_impl!(Vec5, 5)
|
||||
iterable_mut_impl!(Vec5, 5)
|
||||
to_homogeneous_impl!(Vec5, Vec6, b, x, y, z, w, a)
|
||||
|
@ -735,9 +624,9 @@ translation_impl!(Vec6)
|
|||
norm_impl!(Vec6, x, y, z, w, a, b)
|
||||
approx_eq_impl!(Vec6, x, y, z, w, a, b)
|
||||
round_impl!(Vec6, x, y, z, w, a, b)
|
||||
one_impl!(Vec6)
|
||||
one_impl!(Vec6, x, y, z, w, a, b)
|
||||
from_iterator_impl!(Vec6, iterator, iterator, iterator, iterator, iterator, iterator)
|
||||
bounded_impl!(Vec6)
|
||||
bounded_impl!(Vec6, x, y, z, w, a, b)
|
||||
iterable_impl!(Vec6, 6)
|
||||
iterable_mut_impl!(Vec6, 6)
|
||||
translate_impl!(Vec6)
|
||||
|
|
|
@ -277,7 +277,7 @@ macro_rules! basis_impl(
|
|||
|
||||
macro_rules! add_impl(
|
||||
($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
|
||||
impl<N: Clone + Add<N, N>> $trhs<N, $t<N>> for $t<N> {
|
||||
impl<N: Add<N, N>> $trhs<N, $t<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn binop(left: &$t<N>, right: &$t<N>) -> $t<N> {
|
||||
$t::new(left.$comp0 + right.$comp0 $(, left.$compN + right.$compN)*)
|
||||
|
@ -288,7 +288,7 @@ macro_rules! add_impl(
|
|||
|
||||
macro_rules! sub_impl(
|
||||
($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
|
||||
impl<N: Clone + Sub<N, N>> $trhs<N, $t<N>> for $t<N> {
|
||||
impl<N: Sub<N, N>> $trhs<N, $t<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn binop(left: &$t<N>, right: &$t<N>) -> $t<N> {
|
||||
$t::new(left.$comp0 - right.$comp0 $(, left.$compN - right.$compN)*)
|
||||
|
@ -299,7 +299,7 @@ macro_rules! sub_impl(
|
|||
|
||||
macro_rules! mul_impl(
|
||||
($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
|
||||
impl<N: Clone + Mul<N, N>> $trhs<N, $t<N>> for $t<N> {
|
||||
impl<N: Mul<N, N>> $trhs<N, $t<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn binop(left: &$t<N>, right: &$t<N>) -> $t<N> {
|
||||
$t::new(left.$comp0 * right.$comp0 $(, left.$compN * right.$compN)*)
|
||||
|
@ -310,7 +310,7 @@ macro_rules! mul_impl(
|
|||
|
||||
macro_rules! div_impl(
|
||||
($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => (
|
||||
impl<N: Clone + Div<N, N>> $trhs<N, $t<N>> for $t<N> {
|
||||
impl<N: Div<N, N>> $trhs<N, $t<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn binop(left: &$t<N>, right: &$t<N>) -> $t<N> {
|
||||
$t::new(left.$comp0 / right.$comp0 $(, left.$compN / right.$compN)*)
|
||||
|
@ -321,7 +321,7 @@ macro_rules! div_impl(
|
|||
|
||||
macro_rules! neg_impl(
|
||||
($t: ident, $comp0: ident $(,$compN: ident)*) => (
|
||||
impl<N: Clone + Neg<N>> Neg<$t<N>> for $t<N> {
|
||||
impl<N: Neg<N>> Neg<$t<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn neg(&self) -> $t<N> {
|
||||
$t::new(-self.$comp0 $(, -self.$compN )*)
|
||||
|
@ -332,7 +332,7 @@ macro_rules! neg_impl(
|
|||
|
||||
macro_rules! dot_impl(
|
||||
($t: ident, $comp0: ident $(,$compN: ident)*) => (
|
||||
impl<N: Num + Clone> Dot<N> for $t<N> {
|
||||
impl<N: Num> Dot<N> for $t<N> {
|
||||
#[inline]
|
||||
fn dot(a: &$t<N>, b: &$t<N>) -> N {
|
||||
a.$comp0 * b.$comp0 $(+ a.$compN * b.$compN )*
|
||||
|
@ -468,7 +468,7 @@ macro_rules! norm_impl(
|
|||
|
||||
macro_rules! round_impl(
|
||||
($t: ident, $comp0: ident $(,$compN: ident)*) => (
|
||||
impl<N: Clone + Round> Round for $t<N> {
|
||||
impl<N: Round> Round for $t<N> {
|
||||
fn floor(&self) -> $t<N> {
|
||||
$t::new(self.$comp0.floor() $(, self.$compN.floor())*)
|
||||
}
|
||||
|
@ -516,11 +516,14 @@ macro_rules! approx_eq_impl(
|
|||
)
|
||||
|
||||
macro_rules! one_impl(
|
||||
($t: ident) => (
|
||||
impl<N: Clone + One> One for $t<N> {
|
||||
($t: ident, $comp0: ident $(,$compN: ident)*) => (
|
||||
impl<N: One> One for $t<N> {
|
||||
#[inline]
|
||||
fn one() -> $t<N> {
|
||||
$t::new_repeat(One::one())
|
||||
$t {
|
||||
$comp0: One::one()
|
||||
$(, $compN: One::one() )*
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -528,7 +531,7 @@ macro_rules! one_impl(
|
|||
|
||||
macro_rules! from_iterator_impl(
|
||||
($t: ident, $param0: ident $(, $paramN: ident)*) => (
|
||||
impl<N: Clone> FromIterator<N> for $t<N> {
|
||||
impl<N> FromIterator<N> for $t<N> {
|
||||
#[inline]
|
||||
fn from_iterator<I: Iterator<N>>($param0: &mut I) -> $t<N> {
|
||||
$t::new($param0.next().unwrap() $(, $paramN.next().unwrap())*)
|
||||
|
@ -538,16 +541,22 @@ macro_rules! from_iterator_impl(
|
|||
)
|
||||
|
||||
macro_rules! bounded_impl(
|
||||
($t: ident) => (
|
||||
impl<N: Bounded + Clone> Bounded for $t<N> {
|
||||
($t: ident, $comp0: ident $(,$compN: ident)*) => (
|
||||
impl<N: Bounded> Bounded for $t<N> {
|
||||
#[inline]
|
||||
fn max_value() -> $t<N> {
|
||||
$t::new_repeat(Bounded::max_value())
|
||||
$t {
|
||||
$comp0: Bounded::max_value()
|
||||
$(, $compN: Bounded::max_value() )*
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn min_value() -> $t<N> {
|
||||
$t::new_repeat(Bounded::min_value())
|
||||
$t {
|
||||
$comp0: Bounded::min_value()
|
||||
$(, $compN: Bounded::min_value() )*
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -585,7 +594,7 @@ macro_rules! from_homogeneous_impl(
|
|||
|
||||
macro_rules! translate_impl(
|
||||
($t: ident) => (
|
||||
impl<N: Clone + Add<N, N> + Sub<N, N>> Translate<$t<N>> for $t<N> {
|
||||
impl<N: Add<N, N> + Sub<N, N>> Translate<$t<N>> for $t<N> {
|
||||
fn translate(&self, other: &$t<N>) -> $t<N> {
|
||||
*other + *self
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue