From fbfbb30a65cf9629843a3dba278db3a62b6e31f2 Mon Sep 17 00:00:00 2001 From: khai96_ Date: Wed, 18 Oct 2023 14:08:25 +0700 Subject: [PATCH] refactor: use `find` --- tasks/integrated-benchmark/src/verify.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tasks/integrated-benchmark/src/verify.rs b/tasks/integrated-benchmark/src/verify.rs index 93e0b149b..d5c826749 100644 --- a/tasks/integrated-benchmark/src/verify.rs +++ b/tasks/integrated-benchmark/src/verify.rs @@ -35,12 +35,10 @@ where eprintln!("Revision {revision:?} is invalid"); panic!("Revision cannot start with a dot"); } - for char in revision.chars() { - if !matches!(char, 'a'..='z' | 'A'..='Z' | '0'..='9' | '-' | '_' | '+' | '.' | '~' | '^') - { - eprintln!("Revision {revision:?} is invalid"); - panic!("Invalid character: {char:?}"); - } + let invalid_char = revision.chars().find(|char| !matches!(char, 'a'..='z' | 'A'..='Z' | '0'..='9' | '-' | '_' | '+' | '.' | '~' | '^')); + if let Some(char) = invalid_char { + eprintln!("Revision {revision:?} is invalid"); + panic!("Invalid character: {char:?}"); } } }