Make Address::fmt prettier

This commit is contained in:
Sijmen 2018-07-29 17:59:29 +02:00
parent 91b05ddcf0
commit 0f49fb6c59

View file

@ -60,9 +60,9 @@ struct Address<'a> {
impl<'a> fmt::Display for Address<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.ip.is_ipv4() {
true => write!(f, "{} {}:{}", self.protocol, self.ip, self.port),
false => write!(f, "{} [{}]:{}", self.protocol, self.ip, self.port)
match self.ip {
IpAddr::V4(ip) => write!(f, "{} {}:{}", self.protocol, ip, self.port),
IpAddr::V6(ip) => write!(f, "{} [{}]:{}", self.protocol, ip, self.port)
}
}
}