From 2fb5f5e996cec1df7be61d4dd29fef7750ad0e2f Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter <daniel.hofstetter@42dh.com> Date: Mon, 8 Apr 2024 09:36:16 +0200 Subject: [PATCH] lscpu: fix "never_loop" clippy lint --- src/uu/lscpu/src/lscpu.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uu/lscpu/src/lscpu.rs b/src/uu/lscpu/src/lscpu.rs index bafe107..1bf8a06 100644 --- a/src/uu/lscpu/src/lscpu.rs +++ b/src/uu/lscpu/src/lscpu.rs @@ -23,10 +23,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { if let Ok(contents) = fs::read_to_string("/proc/cpuinfo") { let re = Regex::new(r"^model name\s+:\s+(.*)$").unwrap(); - for cap in re.captures_iter(&contents) { + // Assuming all CPUs have the same model name + if let Some(cap) = re.captures_iter(&contents).next() { println!("Model name: {}", &cap[1]); - break; // Assuming all CPUs have the same model name - } + }; } Ok(()) }