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.
master
Dustin 2018-09-29 11:40:55 -05:00
parent 989a6eb0e6
commit 823cfc2593
1 changed files with 1 additions and 1 deletions

View File

@ -45,7 +45,7 @@ pub struct MacAddress {
impl MacAddress {
pub fn from_string(s: &str) -> Result<Self, ParseError> {
let split: Result<Vec<_>, _> = s.split(":")
let split: Result<Vec<_>, _> = s.split(|c| c == ':' || c == '-')
.map(|b| u8::from_str_radix(b, 16))
.collect();
match split {