Skip to content

Commit 49abb42

Browse files
committed
Merge pull request #114 from andersk/neg
Remove Neg from BaseNum
2 parents 78b211f + d47cdb5 commit 49abb42

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

src/structs/iso.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#![allow(missing_docs)]
44

5-
use std::ops::{Add, Sub, Mul};
5+
use std::ops::{Add, Sub, Mul, Neg};
66

77
use rand::{Rand, Rng};
88
use structs::mat::{Mat3, Mat4, Mat5};

src/structs/iso_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ macro_rules! transform_impl(
278278

279279
macro_rules! inv_impl(
280280
($t: ident) => (
281-
impl<N: BaseNum> Inv for $t<N> {
281+
impl<N: BaseNum + Neg<Output = N>> Inv for $t<N> {
282282
#[inline]
283283
fn inv_mut(&mut self) -> bool {
284284
self.rotation.inv_mut();

src/structs/quat.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ impl<N: BaseNum> Mul<Pnt3<N>> for UnitQuat<N> {
364364
}
365365
}
366366

367-
impl<N: BaseNum> Mul<UnitQuat<N>> for Vec3<N> {
367+
impl<N: BaseNum + Neg<Output = N>> Mul<UnitQuat<N>> for Vec3<N> {
368368
type Output = Vec3<N>;
369369

370370
#[inline]
@@ -377,7 +377,7 @@ impl<N: BaseNum> Mul<UnitQuat<N>> for Vec3<N> {
377377
}
378378
}
379379

380-
impl<N: BaseNum> Mul<UnitQuat<N>> for Pnt3<N> {
380+
impl<N: BaseNum + Neg<Output = N>> Mul<UnitQuat<N>> for Pnt3<N> {
381381
type Output = Pnt3<N>;
382382

383383
#[inline]
@@ -432,7 +432,7 @@ impl<N: BaseFloat> Rotation<Vec3<N>> for UnitQuat<N> {
432432
}
433433
}
434434

435-
impl<N: BaseNum> Rotate<Vec3<N>> for UnitQuat<N> {
435+
impl<N: BaseNum + Neg<Output = N>> Rotate<Vec3<N>> for UnitQuat<N> {
436436
#[inline]
437437
fn rotate(&self, v: &Vec3<N>) -> Vec3<N> {
438438
*self * *v
@@ -444,7 +444,7 @@ impl<N: BaseNum> Rotate<Vec3<N>> for UnitQuat<N> {
444444
}
445445
}
446446

447-
impl<N: BaseNum> Rotate<Pnt3<N>> for UnitQuat<N> {
447+
impl<N: BaseNum + Neg<Output = N>> Rotate<Pnt3<N>> for UnitQuat<N> {
448448
#[inline]
449449
fn rotate(&self, p: &Pnt3<N>) -> Pnt3<N> {
450450
*self * *p
@@ -456,7 +456,7 @@ impl<N: BaseNum> Rotate<Pnt3<N>> for UnitQuat<N> {
456456
}
457457
}
458458

459-
impl<N: BaseNum> Transform<Vec3<N>> for UnitQuat<N> {
459+
impl<N: BaseNum + Neg<Output = N>> Transform<Vec3<N>> for UnitQuat<N> {
460460
#[inline]
461461
fn transform(&self, v: &Vec3<N>) -> Vec3<N> {
462462
*self * *v
@@ -468,7 +468,7 @@ impl<N: BaseNum> Transform<Vec3<N>> for UnitQuat<N> {
468468
}
469469
}
470470

471-
impl<N: BaseNum> Transform<Pnt3<N>> for UnitQuat<N> {
471+
impl<N: BaseNum + Neg<Output = N>> Transform<Pnt3<N>> for UnitQuat<N> {
472472
#[inline]
473473
fn transform(&self, p: &Pnt3<N>) -> Pnt3<N> {
474474
*self * *p

src/structs/spec/mat.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::ops::{Add, Mul};
1+
use std::ops::{Add, Mul, Neg};
22
use structs::vec::{Vec2, Vec3};
33
use structs::pnt::{Pnt2, Pnt3};
44
use structs::mat::{Mat1, Mat2, Mat3};
@@ -32,7 +32,7 @@ impl<N: BaseNum + ApproxEq<N>> Inv for Mat1<N> {
3232
}
3333
}
3434

35-
impl<N: BaseNum + ApproxEq<N>> Inv for Mat2<N> {
35+
impl<N: BaseNum + Neg<Output = N> + ApproxEq<N>> Inv for Mat2<N> {
3636
#[inline]
3737
fn inv(&self) -> Option<Mat2<N>> {
3838
let mut res = *self;
@@ -61,7 +61,7 @@ impl<N: BaseNum + ApproxEq<N>> Inv for Mat2<N> {
6161
}
6262
}
6363

64-
impl<N: BaseNum + ApproxEq<N>> Inv for Mat3<N> {
64+
impl<N: BaseNum + Neg<Output = N> + ApproxEq<N>> Inv for Mat3<N> {
6565
#[inline]
6666
fn inv(&self) -> Option<Mat3<N>> {
6767
let mut res = *self;

src/traits/structure.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
use std::{f32, f64, i8, i16, i32, i64, u8, u16, u32, u64, isize, usize};
44
use std::num::Float;
55
use std::slice::{Iter, IterMut};
6-
use std::ops::{Add, Sub, Mul, Div, Neg, Rem, Index, IndexMut};
6+
use std::ops::{Add, Sub, Mul, Div, Rem, Index, IndexMut};
77
use traits::operations::{RMul, LMul, Axpy, Transpose, Inv, Absolute};
88
use traits::geometry::{Dot, Norm, Orig};
99

1010
/// Basic integral numeric trait.
1111
pub trait BaseNum: Copy + Zero + One +
1212
Add<Self, Output = Self> + Sub<Self, Output = Self> +
1313
Mul<Self, Output = Self> + Div<Self, Output = Self> +
14-
Rem<Self, Output = Self> + Neg<Output = Self> + PartialEq +
14+
Rem<Self, Output = Self> + PartialEq +
1515
Absolute<Self> + Axpy<Self> {
1616
}
1717

@@ -239,7 +239,6 @@ pub trait VecAsPnt<P> {
239239
pub trait NumVec<N>: Dim +
240240
Sub<Self, Output = Self> + Add<Self, Output = Self> +
241241
Mul<N, Output = Self> + Div<N, Output = Self> +
242-
Neg<Output = Self> +
243242
Index<usize, Output = N> +
244243
Zero + PartialEq + Dot<N> + Axpy<N> {
245244
}
@@ -276,7 +275,6 @@ pub trait NumPnt<N, V>:
276275
PartialEq +
277276
Axpy<N> +
278277
Sub<Self, Output = V> +
279-
Neg<Output = Self> +
280278
Mul<N, Output = Self> +
281279
Div<N, Output = Self> +
282280
Add<V, Output = Self> +

0 commit comments

Comments
 (0)