address review comment
https://github.com/rust-lang/rustc-dev-guide/pull/1394#discussion_r934018419
This commit is contained in:
parent
3faf82c00e
commit
74b9b456c1
|
|
@ -8,7 +8,7 @@ use std::{
|
||||||
|
|
||||||
use chrono::{Datelike as _, Month, TimeZone as _, Utc};
|
use chrono::{Datelike as _, Month, TimeZone as _, Utc};
|
||||||
use glob::glob;
|
use glob::glob;
|
||||||
use regex::{Regex, RegexSet};
|
use regex::Regex;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
struct Date {
|
struct Date {
|
||||||
|
|
@ -37,15 +37,10 @@ impl fmt::Display for Date {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_date_regex() -> Vec<Regex> {
|
fn make_date_regex() -> Vec<Regex> {
|
||||||
let patterns = [
|
Vec::from([
|
||||||
r"<!--\s+date-check:\s+(\D+)\s+(\d{4})\s+-->",
|
Regex::new(r"<!--\s+date-check:\s+(\D+)\s+(\d{4})\s+-->").unwrap(),
|
||||||
r"<!--\s+date-check\s+-->\s+(\D+)\s+(\d{4})\b",
|
Regex::new(r"<!--\s+date-check\s+-->\s+(\D+)\s+(\d{4})\b").unwrap(),
|
||||||
];
|
])
|
||||||
let set = RegexSet::new(&patterns).unwrap();
|
|
||||||
set.patterns()
|
|
||||||
.iter()
|
|
||||||
.map(|pattern| Regex::new(pattern).unwrap())
|
|
||||||
.collect()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_dates_from_file(date_regexes: &[Regex], text: &str) -> Vec<(usize, Date)> {
|
fn collect_dates_from_file(date_regexes: &[Regex], text: &str) -> Vec<(usize, Date)> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue