From a42326ffc920f23d62bcbb7589396a40b79c93a6 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 17 May 2021 15:55:01 +0100 Subject: [PATCH] if_let: Provide the logically-necessary fourth case Signed-off-by: Ian Jackson --- base/misc.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/base/misc.rs b/base/misc.rs index 66c98fff..b4cb57cd 100644 --- a/base/misc.rs +++ b/base/misc.rs @@ -91,6 +91,14 @@ macro_rules! if_let { _ => { $($otherwise)* }, }; }; + { $($variant:ident)::+ {$binding:ident} = $input:expr; + match $($otherwise:tt)* + } => { + let $binding = match $input { + $($variant)::+ { $binding } => $binding, + $($otherwise)*, + }; + }; } #[ext(pub, name=DebugExt)] -- 2.30.2