diff --git a/src/lib.rs b/src/lib.rs index 64def08..0a09254 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,6 +5,7 @@ #![cfg_attr(feature = "dev", plugin(clippy))] #![crate_type = "lib"] +use std::fmt; use std::net::IpAddr; mod ipv4; @@ -158,6 +159,15 @@ impl From for IpNetwork { } } +impl fmt::Display for IpNetwork { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + IpNetwork::V4(net) => net.fmt(f), + IpNetwork::V6(net) => net.fmt(f), + } + } +} + /// Converts a `IpAddr` network mask into a prefix. /// If the mask is invalid this will return an `IpNetworkError::InvalidPrefix`. pub fn ip_mask_to_prefix(mask: IpAddr) -> Result {