Skip to content

Commit 3e72c19

Browse files
committed
Manually impl Ord, PartialOrd
1 parent b999b7d commit 3e72c19

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/lib.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ use std::str;
138138
use std::path::{Path, PathBuf};
139139
use std::borrow::Borrow;
140140
use std::hash::{Hash, Hasher};
141+
use std::cmp::Ordering;
141142

142143
#[cfg(feature="serde_serialization")]
143144
use std::str::FromStr;
@@ -227,7 +228,7 @@ pub enum SchemeData {
227228
}
228229

229230
/// Components for URLs in a *relative* scheme such as HTTP.
230-
#[derive(Clone, Debug, PartialOrd, Ord)]
231+
#[derive(Clone, Debug)]
231232
#[cfg_attr(feature="heap_size", derive(HeapSizeOf))]
232233
pub struct RelativeSchemeData {
233234
/// The username of the URL, as a possibly empty, percent-encoded string.
@@ -295,6 +296,18 @@ impl Hash for RelativeSchemeData {
295296
}
296297
}
297298

299+
impl PartialOrd for RelativeSchemeData {
300+
fn partial_cmp(&self, other: &RelativeSchemeData) -> Option<Ordering> {
301+
self.get_identity_key().partial_cmp(&other.get_identity_key())
302+
}
303+
}
304+
305+
impl Ord for RelativeSchemeData {
306+
fn cmp(&self, other: &Self) -> Ordering {
307+
self.get_identity_key().cmp(&other.get_identity_key())
308+
}
309+
}
310+
298311
impl str::FromStr for Url {
299312
type Err = ParseError;
300313

0 commit comments

Comments
 (0)