From 823cfc259321e30920df258d7eca21a9f11ed4be Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sat, 29 Sep 2018 11:40:55 -0500 Subject: [PATCH] mac: Support parsing hyphen-separated addresses Windows utilities typically display MAC addresses formatted with hyphens separating the octets. Natively supporting parsing these representations makes it easier for users to simply paste them, without having to manually change the hyphens to colons. --- src/mac.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mac.rs b/src/mac.rs index 8f61141..1733b70 100644 --- a/src/mac.rs +++ b/src/mac.rs @@ -45,7 +45,7 @@ pub struct MacAddress { impl MacAddress { pub fn from_string(s: &str) -> Result { - let split: Result, _> = s.split(":") + let split: Result, _> = s.split(|c| c == ':' || c == '-') .map(|b| u8::from_str_radix(b, 16)) .collect(); match split {