Skip to content

Commit cca2b94

Browse files
authored
Merge pull request #43 from dtolnay/regex
Touch up PR 42
2 parents 2e6902a + f41bcb5 commit cca2b94

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

generate/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ edition = "2018"
66
publish = false
77

88
[dependencies]
9-
regex = "1.12.2"
9+
regex = "1.9"

generate/src/parse.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,12 @@ fn parse_unicode_version(filename: &str, contents: &str) -> (u64, u64, u64) {
8585
let (name, extension) = filename
8686
.rsplit_once('.')
8787
.expect("Failed to split file name into name and extension");
88-
let re = Regex::new(&format!(r"# {name}-(\d+).(\d+).(\d+).{extension}")).unwrap();
88+
let re = Regex::new(&format!(r"^# {name}-(\d+)\.(\d+)\.(\d+)\.{extension}\n")).unwrap();
8989
let caps = re
9090
.captures(contents)
9191
.expect("Failed to find unicode version in unicode data");
92-
let v = caps
93-
.iter()
94-
.skip(1)
95-
.map(|s| {
96-
s.unwrap()
97-
.as_str()
98-
.parse()
99-
.expect("Failed to parse unicode version")
100-
})
101-
.collect::<Vec<u64>>();
102-
(v[0], v[1], v[2])
92+
let (_, [major, minor, patch]) = caps.extract();
93+
[major, minor, patch]
94+
.map(|s| s.parse().expect("Failed to parse unicode version"))
95+
.into()
10396
}

generate/src/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn output(
2727
writeln!(
2828
out,
2929
"pub const UNICODE_VERSION: (u64, u64, u64) = {:?};",
30-
properties.unicode_version()
30+
properties.unicode_version(),
3131
);
3232
writeln!(out);
3333

0 commit comments

Comments
 (0)