use crate::float::kdtree::Axis;
use std::cmp::Ordering;
#[derive(Debug)]
pub struct Neighbour<A, T> {
pub distance: A,
pub item: T,
}
impl<A: Axis, T> Ord for Neighbour<A, T> {
fn cmp(&self, other: &Self) -> Ordering {
self.partial_cmp(other).unwrap_or(Ordering::Equal)
}
}
#[allow(renamed_and_removed_lints)]
#[allow(unknown_lints)]
#[allow(clippy::incorrect_partial_ord_impl_on_ord_type)]
#[allow(clippy::non_canonical_partial_ord_impl)]
impl<A: Axis, T> PartialOrd for Neighbour<A, T> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.distance.partial_cmp(&other.distance)
}
}
impl<A: Axis, T> Eq for Neighbour<A, T> {}
impl<A: Axis, T> PartialEq for Neighbour<A, T> {
fn eq(&self, other: &Self) -> bool {
self.distance == other.distance
}
}
impl<A: Axis, T> PartialEq<A> for Neighbour<A, T> {
fn eq(&self, other: &A) -> bool {
self.distance == *other
}
}
impl<A: Axis, T> From<Neighbour<A, T>> for (A, T) {
fn from(elem: Neighbour<A, T>) -> Self {
(elem.distance, elem.item)
}
}