From: Ian Jackson Date: Mon, 17 May 2021 14:55:01 +0000 (+0100) Subject: if_let: Provide the logically-necessary fourth case X-Git-Tag: otter-0.6.0~198 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a42326ffc920f23d62bcbb7589396a40b79c93a6;p=otter.git if_let: Provide the logically-necessary fourth case Signed-off-by: Ian Jackson --- 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)]