feat: internationalization #43

Merged
matous-volf merged 8 commits from feat/internationalization into main 2024-09-10 14:44:47 +00:00
Showing only changes of commit 1c6d735d52 - Show all commits

View File

@ -1,10 +1,18 @@
use std::cmp::Ordering;
use std::ops::Deref;
/* The default ordering of `Option`s is `None` being less than `Some`. The purpose of this struct is
to reverse that. */
#[derive(PartialEq)]
pub(crate) struct ReverseOrdOption<'a, T>(&'a Option<T>);
impl<'a, T> Deref for ReverseOrdOption<'a, T> {
type Target = Option<T>;
fn deref(&self) -> &Self::Target {
self.0
}
}
impl<'a, T: Ord> Eq for ReverseOrdOption<'a, T> {}
impl<'a, T: Ord> PartialOrd<Self> for ReverseOrdOption<'a, T> {
@ -15,7 +23,7 @@ impl<'a, T: Ord> PartialOrd<Self> for ReverseOrdOption<'a, T> {
impl<'a, T: Ord> Ord for ReverseOrdOption<'a, T> {
fn cmp(&self, other: &Self) -> Ordering {
match (self.0.as_ref(), other.0.as_ref()) {
match (self.as_ref(), other.as_ref()) {
(None, None) => Ordering::Equal,
(None, Some(_)) => Ordering::Greater,
(Some(_), None) => Ordering::Less,