diff options
author | metamuffin <metamuffin@disroot.org> | 2023-08-07 13:46:22 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-08-07 13:46:22 +0200 |
commit | a2e557e648cf253d47e9f4b9dd99ee657610f294 (patch) | |
tree | 350fe5868c9f7d890c79b2489b307c263ed7c307 /common/src/helpers.rs | |
parent | 908db5458b07d7a13f24c755d340ab3c1917e8a8 (diff) | |
download | jellything-a2e557e648cf253d47e9f4b9dd99ee657610f294.tar jellything-a2e557e648cf253d47e9f4b9dd99ee657610f294.tar.bz2 jellything-a2e557e648cf253d47e9f4b9dd99ee657610f294.tar.zst |
extend sort and filter
Diffstat (limited to 'common/src/helpers.rs')
-rw-r--r-- | common/src/helpers.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/common/src/helpers.rs b/common/src/helpers.rs new file mode 100644 index 0000000..5150667 --- /dev/null +++ b/common/src/helpers.rs @@ -0,0 +1,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 + } +} |