This commit is contained in:
Dimitri Sabadie 2016-08-26 10:06:10 +02:00
parent 26f58a89a8
commit a90c2c23fa
9 changed files with 47 additions and 47 deletions

View File

@ -873,13 +873,13 @@ macro_rules! dmat_impl(
impl<N: ApproxEq<N>> ApproxEq<N> for $dmatrix<N> { impl<N: ApproxEq<N>> ApproxEq<N> for $dmatrix<N> {
#[inline] #[inline]
fn approx_epsilon(_: Option<$dmatrix<N>>) -> N { fn approx_epsilon() -> N {
ApproxEq::approx_epsilon(None::<N>) <N as ApproxEq<N>>::approx_epsilon()
} }
#[inline] #[inline]
fn approx_ulps(_: Option<$dmatrix<N>>) -> u32 { fn approx_ulps() -> u32 {
ApproxEq::approx_ulps(None::<N>) <N as ApproxEq<N>>::approx_ulps()
} }
#[inline] #[inline]

View File

@ -378,13 +378,13 @@ macro_rules! isometry_impl(
*/ */
impl<N: ApproxEq<N>> ApproxEq<N> for $t<N> { impl<N: ApproxEq<N>> ApproxEq<N> for $t<N> {
#[inline] #[inline]
fn approx_epsilon(_: Option<$t<N>>) -> N { fn approx_epsilon() -> N {
ApproxEq::approx_epsilon(None::<N>) <N as ApproxEq<N>>::approx_epsilon()
} }
#[inline] #[inline]
fn approx_ulps(_: Option<$t<N>>) -> u32 { fn approx_ulps() -> u32 {
ApproxEq::approx_ulps(None::<N>) <N as ApproxEq<N>>::approx_ulps()
} }
#[inline] #[inline]

View File

@ -277,13 +277,13 @@ macro_rules! matrix_impl(
*/ */
impl<N: ApproxEq<N>> ApproxEq<N> for $t<N> { impl<N: ApproxEq<N>> ApproxEq<N> for $t<N> {
#[inline] #[inline]
fn approx_epsilon(_: Option<$t<N>>) -> N { fn approx_epsilon() -> N {
ApproxEq::approx_epsilon(None::<N>) <N as ApproxEq<N>>::approx_epsilon()
} }
#[inline] #[inline]
fn approx_ulps(_: Option<$t<N>>) -> u32 { fn approx_ulps() -> u32 {
ApproxEq::approx_ulps(None::<N>) <N as ApproxEq<N>>::approx_ulps()
} }
#[inline] #[inline]

View File

@ -389,13 +389,13 @@ impl<N: Rand + BaseFloat> Rand for UnitQuaternion<N> {
impl<N: ApproxEq<N>> ApproxEq<N> for UnitQuaternion<N> { impl<N: ApproxEq<N>> ApproxEq<N> for UnitQuaternion<N> {
#[inline] #[inline]
fn approx_epsilon(_: Option<UnitQuaternion<N>>) -> N { fn approx_epsilon() -> N {
ApproxEq::approx_epsilon(None::<N>) <N as ApproxEq<N>>::approx_epsilon()
} }
#[inline] #[inline]
fn approx_ulps(_: Option<UnitQuaternion<N>>) -> u32 { fn approx_ulps() -> u32 {
ApproxEq::approx_ulps(None::<N>) <N as ApproxEq<N>>::approx_ulps()
} }
#[inline] #[inline]

View File

@ -341,13 +341,13 @@ macro_rules! rotation_impl(
*/ */
impl<N: ApproxEq<N>> ApproxEq<N> for $t<N> { impl<N: ApproxEq<N>> ApproxEq<N> for $t<N> {
#[inline] #[inline]
fn approx_epsilon(_: Option<$t<N>>) -> N { fn approx_epsilon() -> N {
ApproxEq::approx_epsilon(None::<N>) <N as ApproxEq<N>>::approx_epsilon()
} }
#[inline] #[inline]
fn approx_ulps(_: Option<$t<N>>) -> u32 { fn approx_ulps() -> u32 {
ApproxEq::approx_ulps(None::<N>) <N as ApproxEq<N>>::approx_ulps()
} }
#[inline] #[inline]

View File

@ -353,13 +353,13 @@ macro_rules! similarity_impl(
*/ */
impl<N: ApproxEq<N>> ApproxEq<N> for $t<N> { impl<N: ApproxEq<N>> ApproxEq<N> for $t<N> {
#[inline] #[inline]
fn approx_epsilon(_: Option<$t<N>>) -> N { fn approx_epsilon() -> N {
ApproxEq::approx_epsilon(None::<N>) <N as ApproxEq<N>>::approx_epsilon()
} }
#[inline] #[inline]
fn approx_ulps(_: Option<$t<N>>) -> u32 { fn approx_ulps() -> u32 {
ApproxEq::approx_ulps(None::<N>) <N as ApproxEq<N>>::approx_ulps()
} }
#[inline] #[inline]

View File

@ -34,13 +34,13 @@ macro_rules! vectorlike_impl(
*/ */
impl<N: ApproxEq<N>> ApproxEq<N> for $t<N> { impl<N: ApproxEq<N>> ApproxEq<N> for $t<N> {
#[inline] #[inline]
fn approx_epsilon(_: Option<$t<N>>) -> N { fn approx_epsilon() -> N {
ApproxEq::approx_epsilon(None::<N>) <N as ApproxEq<N>>::approx_epsilon()
} }
#[inline] #[inline]
fn approx_ulps(_: Option<$t<N>>) -> u32 { fn approx_ulps() -> u32 {
ApproxEq::approx_ulps(None::<N>) <N as ApproxEq<N>>::approx_ulps()
} }
#[inline] #[inline]

View File

@ -582,13 +582,13 @@ macro_rules! vecn_dvec_common_impl(
*/ */
impl<N: ApproxEq<N> $(, $param : ArrayLength<N>)*> ApproxEq<N> for $vecn<N $(, $param)*> { impl<N: ApproxEq<N> $(, $param : ArrayLength<N>)*> ApproxEq<N> for $vecn<N $(, $param)*> {
#[inline] #[inline]
fn approx_epsilon(_: Option<$vecn<N $(, $param)*>>) -> N { fn approx_epsilon() -> N {
ApproxEq::approx_epsilon(None::<N>) <N as ApproxEq<N>>::approx_epsilon()
} }
#[inline] #[inline]
fn approx_ulps(_: Option<$vecn<N $(, $param)*>>) -> u32 { fn approx_ulps() -> u32 {
ApproxEq::approx_ulps(None::<N>) <N as ApproxEq<N>>::approx_ulps()
} }
#[inline] #[inline]

View File

@ -152,13 +152,13 @@ pub trait PartialOrder {
/// Trait for testing approximate equality /// Trait for testing approximate equality
pub trait ApproxEq<Eps>: Sized { pub trait ApproxEq<Eps>: Sized {
/// Default epsilon for approximation. /// Default epsilon for approximation.
fn approx_epsilon(unused_mut: Option<Self>) -> Eps; fn approx_epsilon() -> Eps;
/// Tests approximate equality using a custom epsilon. /// Tests approximate equality using a custom epsilon.
fn approx_eq_eps(&self, other: &Self, epsilon: &Eps) -> bool; fn approx_eq_eps(&self, other: &Self, epsilon: &Eps) -> bool;
/// Default ULPs for approximation. /// Default ULPs for approximation.
fn approx_ulps(unused_mut: Option<Self>) -> u32; fn approx_ulps() -> u32;
/// Tests approximate equality using units in the last place (ULPs) /// Tests approximate equality using units in the last place (ULPs)
fn approx_eq_ulps(&self, other: &Self, ulps: u32) -> bool; fn approx_eq_ulps(&self, other: &Self, ulps: u32) -> bool;
@ -166,13 +166,13 @@ pub trait ApproxEq<Eps>: Sized {
/// Tests approximate equality. /// Tests approximate equality.
#[inline] #[inline]
fn approx_eq(&self, other: &Self) -> bool { fn approx_eq(&self, other: &Self) -> bool {
self.approx_eq_eps(other, &ApproxEq::approx_epsilon(None::<Self>)) self.approx_eq_eps(other, &Self::approx_epsilon())
} }
} }
impl ApproxEq<f32> for f32 { impl ApproxEq<f32> for f32 {
#[inline] #[inline]
fn approx_epsilon(_: Option<f32>) -> f32 { fn approx_epsilon() -> f32 {
1.0e-6 1.0e-6
} }
@ -181,7 +181,7 @@ impl ApproxEq<f32> for f32 {
::abs(&(*self - *other)) < *epsilon ::abs(&(*self - *other)) < *epsilon
} }
fn approx_ulps(_: Option<f32>) -> u32 { fn approx_ulps() -> u32 {
8 8
} }
@ -203,7 +203,7 @@ impl ApproxEq<f32> for f32 {
impl ApproxEq<f64> for f64 { impl ApproxEq<f64> for f64 {
#[inline] #[inline]
fn approx_epsilon(_: Option<f64>) -> f64 { fn approx_epsilon() -> f64 {
1.0e-6 1.0e-6
} }
@ -212,7 +212,7 @@ impl ApproxEq<f64> for f64 {
::abs(&(*self - *other)) < *approx_epsilon ::abs(&(*self - *other)) < *approx_epsilon
} }
fn approx_ulps(_: Option<f64>) -> u32 { fn approx_ulps() -> u32 {
8 8
} }
@ -231,16 +231,16 @@ impl ApproxEq<f64> for f64 {
} }
impl<'a, N, T: ApproxEq<N>> ApproxEq<N> for &'a T { impl<'a, N, T: ApproxEq<N>> ApproxEq<N> for &'a T {
fn approx_epsilon(_: Option<&'a T>) -> N { fn approx_epsilon() -> N {
ApproxEq::approx_epsilon(None::<T>) <T as ApproxEq<N>>::approx_epsilon()
} }
fn approx_eq_eps(&self, other: &&'a T, approx_epsilon: &N) -> bool { fn approx_eq_eps(&self, other: &&'a T, approx_epsilon: &N) -> bool {
ApproxEq::approx_eq_eps(*self, *other, approx_epsilon) ApproxEq::approx_eq_eps(*self, *other, approx_epsilon)
} }
fn approx_ulps(_: Option<&'a T>) -> u32 { fn approx_ulps() -> u32 {
ApproxEq::approx_ulps(None::<T>) <T as ApproxEq<N>>::approx_ulps()
} }
fn approx_eq_ulps(&self, other: &&'a T, ulps: u32) -> bool { fn approx_eq_ulps(&self, other: &&'a T, ulps: u32) -> bool {
@ -249,16 +249,16 @@ impl<'a, N, T: ApproxEq<N>> ApproxEq<N> for &'a T {
} }
impl<'a, N, T: ApproxEq<N>> ApproxEq<N> for &'a mut T { impl<'a, N, T: ApproxEq<N>> ApproxEq<N> for &'a mut T {
fn approx_epsilon(_: Option<&'a mut T>) -> N { fn approx_epsilon() -> N {
ApproxEq::approx_epsilon(None::<T>) <T as ApproxEq<N>>::approx_epsilon()
} }
fn approx_eq_eps(&self, other: &&'a mut T, approx_epsilon: &N) -> bool { fn approx_eq_eps(&self, other: &&'a mut T, approx_epsilon: &N) -> bool {
ApproxEq::approx_eq_eps(*self, *other, approx_epsilon) ApproxEq::approx_eq_eps(*self, *other, approx_epsilon)
} }
fn approx_ulps(_: Option<&'a mut T>) -> u32 { fn approx_ulps() -> u32 {
ApproxEq::approx_ulps(None::<T>) <T as ApproxEq<N>>::approx_ulps()
} }
fn approx_eq_ulps(&self, other: &&'a mut T, ulps: u32) -> bool { fn approx_eq_ulps(&self, other: &&'a mut T, ulps: u32) -> bool {