Skip to content

Commit

Permalink
Make port: None equal to port: default_port
Browse files Browse the repository at this point in the history
Fix #132
  • Loading branch information
untitaker committed Nov 2, 2015
1 parent a3cd772 commit 355375f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/lib.rs
Expand Up @@ -226,7 +226,7 @@ pub enum SchemeData {
}

/// Components for URLs in a *relative* scheme such as HTTP.
#[derive(PartialEq, Eq, Clone, Debug, Hash, PartialOrd, Ord)]
#[derive(Clone, Debug, Hash, PartialOrd, Ord)]
#[cfg_attr(feature="heap_size", derive(HeapSizeOf))]
pub struct RelativeSchemeData {
/// The username of the URL, as a possibly empty, percent-encoded string.
Expand Down Expand Up @@ -266,6 +266,20 @@ pub struct RelativeSchemeData {
pub path: Vec<String>,
}

impl PartialEq for RelativeSchemeData {
fn eq(&self, other: &RelativeSchemeData) -> bool {
(
self.username == other.username &&
self.password == other.password &&
self.host == other.host &&
self.port.or(self.default_port) == other.port.or(self.default_port) &&
self.default_port == other.default_port &&
self.path == other.path
)
}
}

impl Eq for RelativeSchemeData {}

impl str::FromStr for Url {
type Err = ParseError;
Expand Down

0 comments on commit 355375f

Please sign in to comment.