Fix warnings related to the POrd implementation.
This commit is contained in:
parent
e6e099b7c4
commit
2d4e1bfc95
|
@ -41,7 +41,7 @@ pub struct Pnt1<N> {
|
||||||
|
|
||||||
new_impl!(Pnt1, x);
|
new_impl!(Pnt1, x);
|
||||||
orig_impl!(Pnt1, x);
|
orig_impl!(Pnt1, x);
|
||||||
ord_impl!(Pnt1, x);
|
ord_impl!(Pnt1, x,);
|
||||||
scalar_mul_impl!(Pnt1, x);
|
scalar_mul_impl!(Pnt1, x);
|
||||||
scalar_div_impl!(Pnt1, x);
|
scalar_div_impl!(Pnt1, x);
|
||||||
scalar_add_impl!(Pnt1, x);
|
scalar_add_impl!(Pnt1, x);
|
||||||
|
|
|
@ -41,7 +41,7 @@ pub struct Vec1<N> {
|
||||||
}
|
}
|
||||||
|
|
||||||
new_impl!(Vec1, x);
|
new_impl!(Vec1, x);
|
||||||
ord_impl!(Vec1, x);
|
ord_impl!(Vec1, x,);
|
||||||
vec_axis_impl!(Vec1, x);
|
vec_axis_impl!(Vec1, x);
|
||||||
vec_cast_impl!(Vec1, x);
|
vec_cast_impl!(Vec1, x);
|
||||||
as_array_impl!(Vec1, 1);
|
as_array_impl!(Vec1, 1);
|
||||||
|
|
|
@ -78,74 +78,73 @@ macro_rules! at_fast_impl(
|
||||||
// FIXME: N should be bounded by Ord instead of BaseFloat…
|
// FIXME: N should be bounded by Ord instead of BaseFloat…
|
||||||
// However, f32/f64 does not implement Ord…
|
// However, f32/f64 does not implement Ord…
|
||||||
macro_rules! ord_impl(
|
macro_rules! ord_impl(
|
||||||
($t: ident, $($compN: ident),+) => (
|
($t: ident, $comp0: ident, $($compN: ident),*) => (
|
||||||
impl<N: BaseFloat + Copy> POrd for $t<N> {
|
impl<N: BaseFloat + Copy> POrd for $t<N> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn inf(&self, other: &$t<N>) -> $t<N> {
|
fn inf(&self, other: &$t<N>) -> $t<N> {
|
||||||
$t::new($(self.$compN.min(other.$compN)),+)
|
$t::new(self.$comp0.min(other.$comp0)
|
||||||
|
$(, self.$compN.min(other.$compN))*)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sup(&self, other: &$t<N>) -> $t<N> {
|
fn sup(&self, other: &$t<N>) -> $t<N> {
|
||||||
$t::new($(self.$compN.max(other.$compN)),+)
|
$t::new(self.$comp0.max(other.$comp0)
|
||||||
|
$(, self.$compN.max(other.$compN))*)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unused_mut)] // otherwise there will be a warning for is_eq or Vec1.
|
#[allow(unused_mut)] // otherwise there will be a warning for is_eq or Vec1.
|
||||||
fn partial_cmp(&self, other: &$t<N>) -> POrdering {
|
fn partial_cmp(&self, other: &$t<N>) -> POrdering {
|
||||||
let mut first = true;
|
let is_lt = self.$comp0 < other.$comp0;
|
||||||
let mut is_lt = false;
|
let mut is_eq = self.$comp0 == other.$comp0;
|
||||||
let mut is_eq = false;
|
|
||||||
$(
|
if is_lt { // <
|
||||||
if first {
|
$(
|
||||||
is_lt = self.$compN < other.$compN;
|
|
||||||
is_eq = self.$compN == other.$compN;
|
|
||||||
first = false;
|
|
||||||
}
|
|
||||||
else if is_lt { // <
|
|
||||||
if self.$compN > other.$compN {
|
if self.$compN > other.$compN {
|
||||||
return POrdering::NotComparable
|
return POrdering::NotComparable
|
||||||
}
|
}
|
||||||
}
|
)*
|
||||||
else { // >=
|
|
||||||
|
POrdering::PartialLess
|
||||||
|
}
|
||||||
|
else { // >=
|
||||||
|
$(
|
||||||
if self.$compN < other.$compN {
|
if self.$compN < other.$compN {
|
||||||
return POrdering::NotComparable
|
return POrdering::NotComparable
|
||||||
}
|
}
|
||||||
else if self.$compN > other.$compN {
|
else if self.$compN > other.$compN {
|
||||||
is_eq = false;
|
is_eq = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
)+
|
|
||||||
|
|
||||||
if is_lt {
|
)*
|
||||||
POrdering::PartialLess
|
|
||||||
}
|
if is_eq {
|
||||||
else if is_eq {
|
POrdering::PartialEqual
|
||||||
POrdering::PartialEqual
|
}
|
||||||
}
|
else {
|
||||||
else {
|
POrdering::PartialGreater
|
||||||
POrdering::PartialGreater
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn partial_lt(&self, other: &$t<N>) -> bool {
|
fn partial_lt(&self, other: &$t<N>) -> bool {
|
||||||
$(self.$compN < other.$compN)&&+
|
self.$comp0 < other.$comp0 $(&& self.$compN < other.$compN)*
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn partial_le(&self, other: &$t<N>) -> bool {
|
fn partial_le(&self, other: &$t<N>) -> bool {
|
||||||
$(self.$compN <= other.$compN)&&+
|
self.$comp0 <= other.$comp0 $(&& self.$compN <= other.$compN)*
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn partial_gt(&self, other: &$t<N>) -> bool {
|
fn partial_gt(&self, other: &$t<N>) -> bool {
|
||||||
$(self.$compN > other.$compN)&&+
|
self.$comp0 > other.$comp0 $(&& self.$compN > other.$compN)*
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn partial_ge(&self, other: &$t<N>) -> bool {
|
fn partial_ge(&self, other: &$t<N>) -> bool {
|
||||||
$(self.$compN >= other.$compN)&&+
|
self.$comp0 >= other.$comp0 $(&& self.$compN >= other.$compN)*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue