From 0f49fb6c59f0298877f72e4bdaae25016e5b6d15 Mon Sep 17 00:00:00 2001 From: Sijmen Schoon Date: Sun, 29 Jul 2018 17:59:29 +0200 Subject: [PATCH] Make Address::fmt prettier --- src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 880350a..bf34874 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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) } } }