Skip to main content

polars_utils/
priority.rs

1use std::cmp::Ordering;
2
3/// A pair which is ordered exclusively by the first element.
4#[derive(Copy, Clone, Debug)]
5pub struct Priority<P, T>(pub P, pub T);
6
7impl<P: Ord + Eq, T> Ord for Priority<P, T> {
8    #[inline]
9    fn cmp(&self, other: &Self) -> Ordering {
10        self.0.cmp(&other.0)
11    }
12}
13
14impl<P: Ord + Eq, T> PartialOrd for Priority<P, T> {
15    #[inline]
16    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
17        Some(self.cmp(other))
18    }
19}
20
21impl<P: Eq, T> PartialEq for Priority<P, T> {
22    #[inline]
23    fn eq(&self, other: &Self) -> bool {
24        self.0 == other.0
25    }
26}
27
28impl<P: Eq, T> Eq for Priority<P, T> {}