From: Ian Jackson Date: Sun, 16 May 2021 22:24:52 +0000 (+0100) Subject: if_let: Provide a way to get at the error X-Git-Tag: otter-0.6.0~211 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=903644247413a1e2cea20c69730aa3d10b1eeb3b;p=otter.git if_let: Provide a way to get at the error Signed-off-by: Ian Jackson --- diff --git a/base/misc.rs b/base/misc.rs index faa47bc4..66c98fff 100644 --- a/base/misc.rs +++ b/base/misc.rs @@ -67,6 +67,14 @@ pub fn space_rect_attrs(table_size: PosC) -> SvgAttrs { #[macro_export] macro_rules! if_let { + { $($variant:ident)::+ ($binding:pat) = $input:expr; + match $($otherwise:tt)* + } => { + let $binding = match $input { + $($variant)::+ (y) => y, + $($otherwise)*, + }; + }; { $($variant:ident)::+ ($binding:pat) = $input:expr; else $($otherwise:tt)* } => {