diff --git a/src/client/connect/dns.rs b/src/client/connect/dns.rs index ea05c726e6..127cd72836 100644 --- a/src/client/connect/dns.rs +++ b/src/client/connect/dns.rs @@ -35,6 +35,7 @@ pub trait Resolve { } /// A domain name to resolve into IP addresses. +#[derive(Clone, Hash, Eq, PartialEq)] pub struct Name { host: String, } @@ -74,6 +75,12 @@ impl fmt::Debug for Name { } } +impl fmt::Display for Name { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&self.host, f) + } +} + impl FromStr for Name { type Err = InvalidNameError; @@ -348,7 +355,9 @@ mod tests { #[test] fn test_name_from_str() { - let name = Name::from_str("test.example.com").expect("Should be a valid domain"); - assert_eq!(name.as_str(), "test.example.com"); + const DOMAIN: &str = "test.example.com"; + let name = Name::from_str(DOMAIN).expect("Should be a valid domain"); + assert_eq!(name.as_str(), DOMAIN); + assert_eq!(name.to_string(), DOMAIN); } }