From 3e72c195815c603b257d32ea406f9df479015eac Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Tue, 10 Nov 2015 21:05:28 +0100 Subject: [PATCH] Manually impl Ord, PartialOrd --- src/lib.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 03e7c59ca..08d32ef55 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -138,6 +138,7 @@ use std::str; use std::path::{Path, PathBuf}; use std::borrow::Borrow; use std::hash::{Hash, Hasher}; +use std::cmp::Ordering; #[cfg(feature="serde_serialization")] use std::str::FromStr; @@ -227,7 +228,7 @@ pub enum SchemeData { } /// Components for URLs in a *relative* scheme such as HTTP. -#[derive(Clone, Debug, PartialOrd, Ord)] +#[derive(Clone, Debug)] #[cfg_attr(feature="heap_size", derive(HeapSizeOf))] pub struct RelativeSchemeData { /// The username of the URL, as a possibly empty, percent-encoded string. @@ -295,6 +296,18 @@ impl Hash for RelativeSchemeData { } } +impl PartialOrd for RelativeSchemeData { + fn partial_cmp(&self, other: &RelativeSchemeData) -> Option { + self.get_identity_key().partial_cmp(&other.get_identity_key()) + } +} + +impl Ord for RelativeSchemeData { + fn cmp(&self, other: &Self) -> Ordering { + self.get_identity_key().cmp(&other.get_identity_key()) + } +} + impl str::FromStr for Url { type Err = ParseError;