|
@@ -38,7 +38,7 @@ impl From<Host<String>> for HostInternal {
|
|
|
|
|
|
|
|
/// The host name of an URL.
|
|
/// The host name of an URL.
|
|
|
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
|
|
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
|
|
|
-#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
|
|
|
|
|
|
+#[derive(Clone, Debug, Eq, Ord, PartialOrd, Hash)]
|
|
|
pub enum Host<S = String> {
|
|
pub enum Host<S = String> {
|
|
|
/// A DNS domain name, as '.' dot-separated labels.
|
|
/// A DNS domain name, as '.' dot-separated labels.
|
|
|
/// Non-ASCII labels are encoded in punycode per IDNA if this is the host of
|
|
/// Non-ASCII labels are encoded in punycode per IDNA if this is the host of
|
|
@@ -172,6 +172,20 @@ impl<S: AsRef<str>> fmt::Display for Host<S> {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+impl<S, T> PartialEq<Host<T>> for Host<S>
|
|
|
|
|
+where
|
|
|
|
|
+ S: PartialEq<T>,
|
|
|
|
|
+{
|
|
|
|
|
+ fn eq(&self, other: &Host<T>) -> bool {
|
|
|
|
|
+ match (self, other) {
|
|
|
|
|
+ (Host::Domain(a), Host::Domain(b)) => a == b,
|
|
|
|
|
+ (Host::Ipv4(a), Host::Ipv4(b)) => a == b,
|
|
|
|
|
+ (Host::Ipv6(a), Host::Ipv6(b)) => a == b,
|
|
|
|
|
+ (_, _) => false,
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
fn write_ipv6(addr: &Ipv6Addr, f: &mut Formatter<'_>) -> fmt::Result {
|
|
fn write_ipv6(addr: &Ipv6Addr, f: &mut Formatter<'_>) -> fmt::Result {
|
|
|
let segments = addr.segments();
|
|
let segments = addr.segments();
|
|
|
let (compress_start, compress_end) = longest_zero_sequence(&segments);
|
|
let (compress_start, compress_end) = longest_zero_sequence(&segments);
|