From 8a6e741d6c9e3dd77f1adf596bca0cd35fb375ff Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 4 Dec 2019 11:06:00 +0100 Subject: [PATCH] api: let ConstRegexPattern deref to Regex This way we can just use `SOME_REGEX.is_match()` again without having to explicitly call `(SOME_REGEX.regex_obj)()` first. Signed-off-by: Wolfgang Bumiller --- proxmox-api/src/const_regex.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/proxmox-api/src/const_regex.rs b/proxmox-api/src/const_regex.rs index 8541f660..32d810c5 100644 --- a/proxmox-api/src/const_regex.rs +++ b/proxmox-api/src/const_regex.rs @@ -19,6 +19,14 @@ impl fmt::Debug for ConstRegexPattern { } } +impl std::ops::Deref for ConstRegexPattern { + type Target = regex::Regex; + + fn deref(&self) -> &Self::Target { + (self.regex_obj)() + } +} + /// Macro to generate a ConstRegexPattern /// /// ```