chore: clippy

This commit is contained in:
Vukašin Vojinović 2025-10-27 15:16:25 +01:00 committed by Ashley Wulber
parent a8d8e14413
commit b3be053f33
27 changed files with 654 additions and 706 deletions

View file

@ -16,19 +16,23 @@ impl HwAddress {
}
u64::from_str_radix(columnless_vec.join("").as_str(), 16)
.ok()
.and_then(|address| Some(HwAddress { address }))
.map(|address| HwAddress { address })
}
pub fn from_string(arg: &String) -> Option<Self> {
HwAddress::from_str(arg.as_str())
}
pub fn to_string(&self) -> String {
format!("{:#x}", self.address)
}
impl std::fmt::Display for HwAddress {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let hex = format!("{:#x}", self.address)
.trim_start_matches("0x")
.chars()
.collect::<Vec<_>>()
.chunks(2)
.map(|chunk| chunk.iter().cloned().collect::<String>())
.collect::<Vec<String>>()
.join(":")
.join(":");
write!(f, "{}", hex)
}
}