aboutsummaryrefslogtreecommitdiff
path: root/common/src/helpers.rs
blob: 515066708800e0c8842d08628beea3c2b697ffee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use std::ops::Deref;

#[derive(PartialEq, PartialOrd)]
pub struct SortAnyway<T>(pub T);

impl<T: PartialEq> Eq for SortAnyway<T> {
    fn assert_receiver_is_total_eq(&self) {}
}
impl<T: PartialOrd> Ord for SortAnyway<T> {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        self.partial_cmp(&other).unwrap()
    }
}

impl<T> Deref for SortAnyway<T> {
    type Target = T;
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}