Skip to content

Instantly share code, notes, and snippets.

@hatoo
Created December 24, 2017 02:40
Show Gist options
  • Save hatoo/4e56d5e69d7a9e64be0a5b8ea3743564 to your computer and use it in GitHub Desktop.
Save hatoo/4e56d5e69d7a9e64be0a5b8ea3743564 to your computer and use it in GitHub Desktop.
#[derive(PartialEq, PartialOrd)]
struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
fn cmp(&self, other: &Total<T>) -> Ordering {
self.0.partial_cmp(&other.0).unwrap()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment