Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-utils/src/priority.rs
6939 views
1
use std::cmp::Ordering;
2
3
/// A pair which is ordered exclusively by the first element.
4
#[derive(Copy, Clone, Debug)]
5
pub struct Priority<P, T>(pub P, pub T);
6
7
impl<P: Ord + Eq, T> Ord for Priority<P, T> {
8
fn cmp(&self, other: &Self) -> Ordering {
9
self.0.cmp(&other.0)
10
}
11
}
12
13
impl<P: Ord + Eq, T> PartialOrd for Priority<P, T> {
14
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
15
Some(self.cmp(other))
16
}
17
}
18
19
impl<P: Eq, T> PartialEq for Priority<P, T> {
20
fn eq(&self, other: &Self) -> bool {
21
self.0 == other.0
22
}
23
}
24
25
impl<P: Eq, T> Eq for Priority<P, T> {}
26
27