diff --git a/src/config.rs b/src/config.rs index 6ceb7a6..4e414fc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -28,16 +28,15 @@ impl FromStr for Card { .parse::() .map_err(|e| AmdFanError::InvalidSuffix(format!("{:?}", e))) .map(|n| Card(n))?; - match std::fs::read_to_string(format!("{}/{}/device/vendor", ROOT_DIR, card)) { - Ok(vendor) => { + std::fs::read_to_string(format!("{}/{}/device/vendor", ROOT_DIR, card)) + .map_err(|_| AmdFanError::FailedReadVendor) + .and_then(|vendor| { if vendor.trim() == "0x1002" { Ok(card) } else { Err(AmdFanError::NotAmdCard) } - } - Err(_) => Err(AmdFanError::FailedReadVendor), - } + }) } }