INNER CODE UNIT · Rust
is_mac_addr
pythops/bluetui · src/bluetooth.rs:150
fn is_mac_addr(s: &str) -> bool {
if s.len() != 17 {
return false;
}
let mut chars = s.chars();
for _ in 0..5 {
// Matches [A-Fa-f0-9][A-Fa-f0-9]-
if !(matches!(chars.next(), Some(c) if c.is_ascii_hexdigit())
&& matches!(chars.next(), Some(c) if c.is_ascii_hexdigit())
&& matches!(chars.next(), Some('-')))
{
return false;
}
}
// Matches [A-Fa-f0-9][A-Fa-f0-9]$
matches!(chars.next(), Some(c) if c.is_ascii_hexdigit())
&& matches!(chars.next(), Some(c) if c.is_ascii_hexdigit())
&& chars.next().is_none()