use crate::natural::Natural;
use core::cmp::Ordering;
use malachite_base::num::comparison::traits::PartialOrdAbs;
macro_rules! impl_unsigned {
($t: ident) => {
impl PartialOrdAbs<$t> for Natural {
#[inline]
fn partial_cmp_abs(&self, other: &$t) -> Option<Ordering> {
self.partial_cmp(other)
}
}
impl PartialOrdAbs<Natural> for $t {
#[inline]
fn partial_cmp_abs(&self, other: &Natural) -> Option<Ordering> {
self.partial_cmp(other)
}
}
};
}
apply_to_unsigneds!(impl_unsigned);
macro_rules! impl_signed {
($t: ident) => {
impl PartialOrdAbs<$t> for Natural {
fn partial_cmp_abs(&self, other: &$t) -> Option<Ordering> {
self.partial_cmp(&other.unsigned_abs())
}
}
impl PartialOrdAbs<Natural> for $t {
#[inline]
fn partial_cmp_abs(&self, other: &Natural) -> Option<Ordering> {
other.partial_cmp_abs(self).map(Ordering::reverse)
}
}
};
}
apply_to_signeds!(impl_signed);