public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox] simplify const_regex macro
Date: Tue,  4 May 2021 14:50:56 +0200	[thread overview]
Message-ID: <20210504125056.31055-1-w.bumiller@proxmox.com> (raw)

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





             reply	other threads:[~2021-05-04 12:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-04 12:50 Wolfgang Bumiller [this message]
2021-05-05  5:48 ` [pbs-devel] applied: " Dietmar Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210504125056.31055-1-w.bumiller@proxmox.com \
    --to=w.bumiller@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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