From 60fc98f73bae509f201247e7ffc8e5bb5ab85961 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Mon, 18 Mar 2024 16:16:52 +0900 Subject: [PATCH] Refactor helper macro Some cleanup of the helper macro introduced in the previous commit. --- src/helper.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/helper.rs b/src/helper.rs index a318f59..0d60a47 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -1,6 +1,11 @@ #[macro_export] macro_rules! cleanup_func { - (func: $cleanup_fn:expr, name: $name:ident, hold_name: $hold_name:ident) => { + (func: $cleanup_fn:expr, + name: $name:ident, + hold_name: $hold_name:ident, + $(var_pair: $orig_var:expr, $new_var:ident),*) => { + $(let $new_var = $orig_var;)* + struct $name ()> { func: T, } @@ -16,12 +21,7 @@ macro_rules! cleanup_func { } } } + $hold_name = $name::new($cleanup_fn); - }; - (func: $cleanup_fn:expr, name: $name:ident, hold_name: $hold_name:ident, $(var_pair: $orig_var:expr, $new_var:ident),*) => { - { - $(let $new_var = $orig_var;)* - cleanup_func!(func: $cleanup_fn, name: $name, hold_name: $hold_name); - } } }