diff --git a/src/mac.rs b/src/mac.rs index b87ae88..8f61141 100644 --- a/src/mac.rs +++ b/src/mac.rs @@ -37,6 +37,7 @@ impl error::Error for ParseError { } +#[derive(Debug)] pub struct MacAddress { addr: [u8; 6], } @@ -67,6 +68,17 @@ impl MacAddress { } +impl fmt::Display for MacAddress { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let s = self.addr.iter() + .map(|b| format!("{:x}", b)) + .collect::>() + .join(":"); + write!(f, "{}", s) + } +} + + #[cfg(test)] mod test { use super::*;