From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id B383179615 for ; Tue, 4 May 2021 14:50:57 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A4BDE96F8 for ; Tue, 4 May 2021 14:50:57 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 2F6B196EF for ; Tue, 4 May 2021 14:50:57 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 059FF426AF for ; Tue, 4 May 2021 14:50:57 +0200 (CEST) From: Wolfgang Bumiller To: pbs-devel@lists.proxmox.com Date: Tue, 4 May 2021 14:50:56 +0200 Message-Id: <20210504125056.31055-1-w.bumiller@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.019 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox] simplify const_regex macro X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 May 2021 12:50:57 -0000 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 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