From e3a78d635462d9afce9ececb3216a09e67beb9da Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Tue, 4 May 2021 14:50:56 +0200 Subject: [PATCH] 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 --- proxmox/src/api/const_regex.rs | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/proxmox/src/api/const_regex.rs b/proxmox/src/api/const_regex.rs index 68a4c0ab..f3f16b6d 100644 --- a/proxmox/src/api/const_regex.rs +++ b/proxmox/src/api/const_regex.rs @@ -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")]