From 6ba79825c922eb651175a77e9c63e2afaa23eb54 Mon Sep 17 00:00:00 2001 From: Aurorans Solis Date: Fri, 2 Jul 2021 15:37:05 -0700 Subject: [PATCH] Made suggested edits. --- src/config.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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), - } + }) } }