use super::Quantity;
use crate::{dimension::*, scalar::Scalar};
use core::cmp::Ordering;
impl<S: Scalar, D: Dimensions, K> PartialEq for Quantity<S, D, K> {
#[inline(always)]
fn eq(&self, other: &Self) -> bool {
self.value == other.value
}
}
impl<S: Scalar, D: Dimensions, K> PartialOrd for Quantity<S, D, K> {
#[inline(always)]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.value.partial_cmp(&other.value)
}
}
macro_rules! dimensionless_cmp {
($($fl:ty : $feature:literal),*) => {
$(
#[cfg(feature = $feature)]
impl PartialEq<$fl> for Quantity<$fl, Dimensionless> {
#[inline(always)]
fn eq(&self, other: &$fl) -> bool {
self.value == *other
}
}
#[cfg(feature = $feature)]
impl PartialEq<Quantity<$fl, Dimensionless>> for $fl {
#[inline(always)]
fn eq(&self, other: &Quantity<$fl, Dimensionless>) -> bool {
*self == other.value
}
}
#[cfg(feature = $feature)]
impl PartialOrd<$fl> for Quantity<$fl, Dimensionless> {
#[inline(always)]
fn partial_cmp(&self, other: &$fl) -> Option<Ordering> {
self.value.partial_cmp(other)
}
}
#[cfg(feature = $feature)]
impl PartialOrd<Quantity<$fl, Dimensionless>> for $fl {
#[inline(always)]
fn partial_cmp(&self, other: &Quantity<$fl, Dimensionless>) -> Option<Ordering> {
self.partial_cmp(&other.value)
}
}
)*
};
}
dimensionless_cmp!(f32: "f32", f64: "f64");