Created
March 21, 2017 09:13
-
-
Save mitsuhiko/c9cf5ed5abf05a6f8e215949e2d65db6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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