refactor: 使用 regex 1.13.0 引入的内置 regex! 宏

This commit is contained in:
amtoaer
2026-07-13 11:02:25 +08:00
parent 73265a1e12
commit d3cdf5102d

View File

@@ -1,9 +1,4 @@
macro_rules! regex {
($re:literal $(,)?) => {{
static RE: once_cell::sync::OnceCell<regex::Regex> = once_cell::sync::OnceCell::new();
RE.get_or_init(|| regex::Regex::new($re).expect("invalid regex"))
}};
}
use regex::regex;
pub fn filenamify<S: AsRef<str>>(input: S) -> String {
let reserved = regex!("[<>:\"/\\\\|?*\u{0000}-\u{001F}\u{007F}\u{0080}-\u{009F}]+");