Skip to content

Commit 0306ffb

Browse files
committed
Extract closure to function
1 parent bf06e8e commit 0306ffb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/tools/compiletest/src/main.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -848,11 +848,11 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
848848
let patch = splits.next();
849849

850850
let major: u32 = major.parse().unwrap();
851-
let (minor, patch): (u32, u32) = match minor.find(|c: char| !c.is_digit(10)) {
851+
let (minor, patch): (u32, u32) = match minor.find(not_a_digit) {
852852
None => {
853853
let minor = minor.parse().unwrap();
854854
let patch: u32 = match patch {
855-
Some(patch) => match patch.find(|c: char| !c.is_digit(10)) {
855+
Some(patch) => match patch.find(not_a_digit) {
856856
None => patch.parse().unwrap(),
857857
Some(idx) if idx > 3 => 0,
858858
Some(idx) => patch[..idx].parse().unwrap(),
@@ -898,15 +898,19 @@ fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> {
898898
if let Some(apple_ver) =
899899
full_version_line.strip_prefix("LLDB-").or_else(|| full_version_line.strip_prefix("lldb-"))
900900
{
901-
if let Some(idx) = apple_ver.find(|c: char| !c.is_digit(10)) {
901+
if let Some(idx) = apple_ver.find(not_a_digit) {
902902
let version: u32 = apple_ver[..idx].parse().unwrap();
903903
return Some((version, full_version_line.contains("rust-enabled")));
904904
}
905905
} else if let Some(lldb_ver) = full_version_line.strip_prefix("lldb version ") {
906-
if let Some(idx) = lldb_ver.find(|c: char| !c.is_digit(10)) {
906+
if let Some(idx) = lldb_ver.find(not_a_digit) {
907907
let version: u32 = lldb_ver[..idx].parse().unwrap();
908908
return Some((version * 100, full_version_line.contains("rust-enabled")));
909909
}
910910
}
911911
None
912912
}
913+
914+
fn not_a_digit(c: char) -> bool {
915+
!c.is_digit(10)
916+
}

0 commit comments

Comments
 (0)