raddy/
compare.rs

1use crate::Ad;
2use std::cmp::Ordering;
3
4impl<const N: usize> PartialEq for Ad<N> {
5    fn eq(&self, other: &Self) -> bool {
6        self.value == other.value
7    }
8}
9
10impl<const N: usize> PartialOrd for Ad<N> {
11    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
12        self.value.partial_cmp(&other.value)
13    }
14}
15
16impl<const N: usize> PartialEq<f64> for Ad<N> {
17    fn eq(&self, other: &f64) -> bool {
18        self.value == *other
19    }
20}
21
22impl<const N: usize> PartialOrd<f64> for Ad<N> {
23    fn partial_cmp(&self, other: &f64) -> Option<Ordering> {
24        self.value.partial_cmp(other)
25    }
26}
27
28impl<const N: usize> PartialEq<Ad<N>> for f64 {
29    fn eq(&self, other: &Ad<N>) -> bool {
30        *self == other.value
31    }
32}
33
34impl<const N: usize> PartialOrd<Ad<N>> for f64 {
35    fn partial_cmp(&self, other: &Ad<N>) -> Option<Ordering> {
36        self.partial_cmp(&other.value)
37    }
38}