1pub mod by_dist_sq {
2 use derive_more::Constructor;
3
4 #[derive(Constructor)]
5 pub struct ComparedByDistSq<T> {
6 pub val: T,
7 pub dist_sq: f32,
8 }
9 impl<T> PartialEq for ComparedByDistSq<T> {
10 fn eq(&self, other: &Self) -> bool {
11 self.dist_sq == other.dist_sq
12 }
13 }
14 impl<T> PartialOrd for ComparedByDistSq<T> {
15 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
16 self.dist_sq.partial_cmp(&other.dist_sq)
17 }
18 }
19 impl<T> Eq for ComparedByDistSq<T> {}
20 impl<T> Ord for ComparedByDistSq<T> {
21 fn cmp(&self, other: &Self) -> std::cmp::Ordering {
22 self.partial_cmp(other).unwrap()
23 }
24 }
25}