Skip to content

Provide naive implementations of Eq and IterBytes for net::Url #3451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/libstd/net_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use dvec::DVec;
use from_str::FromStr;
use result::{Err, Ok};
use to_str::ToStr;
use to_bytes::IterBytes;

export Url, Query;
export from_str, to_str;
Expand Down Expand Up @@ -718,6 +719,28 @@ impl Url: to_str::ToStr {
}
}

impl Url: Eq {
pure fn eq(&&other: Url) -> bool {
self.scheme == other.scheme
&& self.user == other.user
&& self.host == other.host
&& self.port == other.port
&& self.path == other.path
&& self.query == other.query
&& self.fragment == other.fragment
}

pure fn ne(&&other: Url) -> bool {
!self.eq(other)
}
}

impl Url: IterBytes {
fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
self.to_str().iter_bytes(lsb0, f)
}
}

#[cfg(test)]
mod tests {
#[test]
Expand Down