mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-17 06:24:49 +00:00
simplify const_regex macro
The :vis macro matcher has been stable for a long time now. Let's use it, and replace the recursion with a plus pattern. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
9c786006df
commit
e3a78d6354
@ -39,21 +39,11 @@ impl std::ops::Deref for ConstRegexPattern {
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! const_regex {
|
||||
() => {};
|
||||
($(#[$attr:meta])* pub ($($vis:tt)+) $name:ident = $regex:expr; $($rest:tt)*) => {
|
||||
$crate::const_regex! { (pub ($($vis)+)) $(#[$attr])* $name = $regex; $($rest)* }
|
||||
};
|
||||
($(#[$attr:meta])* pub $name:ident = $regex:expr; $($rest:tt)*) => {
|
||||
$crate::const_regex! { (pub) $(#[$attr])* $name = $regex; $($rest)* }
|
||||
};
|
||||
($(#[$attr:meta])* $name:ident = $regex:expr; $($rest:tt)*) => {
|
||||
$crate::const_regex! { () $(#[$attr])* $name = $regex; $($rest)* }
|
||||
};
|
||||
(
|
||||
($($pub:tt)*) $(#[$attr:meta])* $name:ident = $regex:expr;
|
||||
$($rest:tt)*
|
||||
) => {
|
||||
$(#[$attr])* $($pub)* const $name: $crate::api::const_regex::ConstRegexPattern =
|
||||
($(
|
||||
$(#[$attr:meta])*
|
||||
$vis:vis $name:ident = $regex:expr;
|
||||
)+) => { $(
|
||||
$(#[$attr])* $vis const $name: $crate::api::const_regex::ConstRegexPattern =
|
||||
$crate::api::const_regex::ConstRegexPattern {
|
||||
regex_string: $regex,
|
||||
regex_obj: (|| -> &'static ::regex::Regex {
|
||||
@ -63,9 +53,7 @@ macro_rules! const_regex {
|
||||
&SCHEMA
|
||||
})
|
||||
};
|
||||
|
||||
$crate::const_regex! { $($rest)* }
|
||||
};
|
||||
)+ };
|
||||
}
|
||||
|
||||
#[cfg(feature = "test-harness")]
|
||||
|
Loading…
Reference in New Issue
Block a user