mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-09-07 00:17:24 +08:00
refactor: 使用 regex 1.13.0 引入的内置 regex! 宏
This commit is contained in:
@@ -1,9 +1,4 @@
|
|||||||
macro_rules! regex {
|
use regex::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"))
|
|
||||||
}};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn filenamify<S: AsRef<str>>(input: S) -> String {
|
pub fn filenamify<S: AsRef<str>>(input: S) -> String {
|
||||||
let reserved = regex!("[<>:\"/\\\\|?*\u{0000}-\u{001F}\u{007F}\u{0080}-\u{009F}]+");
|
let reserved = regex!("[<>:\"/\\\\|?*\u{0000}-\u{001F}\u{007F}\u{0080}-\u{009F}]+");
|
||||||
|
|||||||
Reference in New Issue
Block a user