From 8209da3b21770d1508bbb3ddfcf54d4781a12e5b Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Wed, 14 May 2025 16:30:03 +0200 Subject: [PATCH] Refactor device reset logic to use match statement for better clarity --- Cargo.toml | 2 +- src/main.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1ba57bc..df814a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "phenix" description = "Utility to restart PCIe devices when link is lost." -version = "0.1.4" +version = "0.1.5" edition = "2024" license = "GPL-3.0-or-later" repository="https://code.edgarpierre.fr/edpibu/phenix" diff --git a/src/main.rs b/src/main.rs index e13669e..e0c9e24 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,8 +23,9 @@ fn manage_line(line: String) { println!("PCIe link lost {prefix}"); let id = line.splitn(3, " ").nth(1); - if let Some(id) = id { - reset_device(id); + match id { + Some(id) => reset_device(id), + None => println!("No device id found in message {line}"), } } }