Skip to content

Commit 2708038

Browse files
committed
Merge pull request #3451 from burg/url-eq-iterbytes
Provide naive implementations of Eq and IterBytes for net::Url
2 parents a07ea73 + 10a7865 commit 2708038

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/libstd/net_url.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use dvec::DVec;
99
use from_str::FromStr;
1010
use result::{Err, Ok};
1111
use to_str::ToStr;
12+
use to_bytes::IterBytes;
1213

1314
export Url, Query;
1415
export from_str, to_str;
@@ -718,6 +719,28 @@ impl Url: to_str::ToStr {
718719
}
719720
}
720721

722+
impl Url: Eq {
723+
pure fn eq(&&other: Url) -> bool {
724+
self.scheme == other.scheme
725+
&& self.user == other.user
726+
&& self.host == other.host
727+
&& self.port == other.port
728+
&& self.path == other.path
729+
&& self.query == other.query
730+
&& self.fragment == other.fragment
731+
}
732+
733+
pure fn ne(&&other: Url) -> bool {
734+
!self.eq(other)
735+
}
736+
}
737+
738+
impl Url: IterBytes {
739+
fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
740+
self.to_str().iter_bytes(lsb0, f)
741+
}
742+
}
743+
721744
#[cfg(test)]
722745
mod tests {
723746
#[test]

0 commit comments

Comments
 (0)