public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox] simplify const_regex macro
@ 2021-05-04 12:50 Wolfgang Bumiller
  2021-05-05  5:48 ` [pbs-devel] applied: " Dietmar Maurer
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfgang Bumiller @ 2021-05-04 12:50 UTC (permalink / raw)
  To: pbs-devel

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>
---
 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 68a4c0a..f3f16b6 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")]
-- 
2.20.1





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-05  5:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-04 12:50 [pbs-devel] [PATCH proxmox] simplify const_regex macro Wolfgang Bumiller
2021-05-05  5:48 ` [pbs-devel] applied: " Dietmar Maurer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal