Skip to content

Instantly share code, notes, and snippets.

@mitsuhiko
Created March 21, 2017 09:13
Show Gist options
  • Save mitsuhiko/c9cf5ed5abf05a6f8e215949e2d65db6 to your computer and use it in GitHub Desktop.
Save mitsuhiko/c9cf5ed5abf05a6f8e215949e2d65db6 to your computer and use it in GitHub Desktop.
use std::cmp::Ordering;
#[derive(PartialEq, Eq)]
pub struct Rev<T: Ord + PartialOrd + Eq + PartialEq>(pub T);
impl<T: Ord + PartialOrd + Eq + PartialEq> PartialOrd for Rev<T> {
fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
other.0.partial_cmp(&self.0)
}
}
impl<T: Ord+PartialOrd+Eq+PartialEq> Ord for Rev<T> {
fn cmp(&self, other: &Rev<T>) -> Ordering {
other.0.cmp(&self.0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment