From 10a7865428c03613fa510951f22e00a024a472f6 Mon Sep 17 00:00:00 2001 From: "Brian J. Burg" Date: Mon, 10 Sep 2012 14:07:25 -0700 Subject: [PATCH] Provide naive implementations of cmp::Eq and to_bytes::IterBytes for net::url::Url --- src/libstd/net_url.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index a0eab69fb3569..cef29bbef2a91 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -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; @@ -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]