From 2ce8113d20b92889f22a3ecd641f50c3c6dfc354 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 17 May 2021 15:57:36 +0100 Subject: [PATCH] if_let: Remove the "match" from the general case Signed-off-by: Ian Jackson --- base/misc.rs | 14 +++++++------- src/bundles.rs | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/base/misc.rs b/base/misc.rs index b4cb57cd..c34a258f 100644 --- a/base/misc.rs +++ b/base/misc.rs @@ -68,19 +68,19 @@ pub fn space_rect_attrs(table_size: PosC) -> SvgAttrs { #[macro_export] macro_rules! if_let { { $($variant:ident)::+ ($binding:pat) = $input:expr; - match $($otherwise:tt)* + else $($otherwise:tt)* } => { let $binding = match $input { - $($variant)::+ (y) => y, - $($otherwise)*, + $($variant)::+ (y) => y, + _ => { $($otherwise)* }, }; }; { $($variant:ident)::+ ($binding:pat) = $input:expr; - else $($otherwise:tt)* + $($otherwise:tt)* } => { let $binding = match $input { - $($variant)::+ (y) => y, - _ => { $($otherwise)* }, + $($variant)::+ (y) => y, + $($otherwise)*, }; }; { $($variant:ident)::+ {$binding:ident} = $input:expr; @@ -92,7 +92,7 @@ macro_rules! if_let { }; }; { $($variant:ident)::+ {$binding:ident} = $input:expr; - match $($otherwise:tt)* + $($otherwise:tt)* } => { let $binding = match $input { $($variant)::+ { $binding } => $binding, diff --git a/src/bundles.rs b/src/bundles.rs index 789db9a9..09e06e61 100644 --- a/src/bundles.rs +++ b/src/bundles.rs @@ -950,7 +950,7 @@ impl InstanceBundles { pub fn truncate_all_besteffort(instance: &InstanceName) { if_let!{ Ok(bundles) = InstanceBundles::scan_game_bundles(instance); - match Err(e) => { + Err(e) => { error!("failed to scan game bundles for {}: {}", instance, e); return; } @@ -958,14 +958,14 @@ impl InstanceBundles { for entry in bundles { if_let!{ Ok((fpath,_what)) = entry; - match Err(e) => { + Err(e) => { error!("failed to make sense of a pathname for {}: {}", instance, e); continue; } }; if_let!{ Ok(_) = File::create(&fpath); - match Err(e) => { + Err(e) => { warn!("failed to truncate a bundle for {}: {}: {}", instance, fpath, e); continue; -- 2.30.2