aboutsummaryrefslogtreecommitdiff
path: root/common/src/helpers.rs
blob: 86072cc13a28f8ce029c85718c8af90b0d3ab15a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2023 metamuffin <metamuffin.org>
*/
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
    }
}