Refactor macro

More minor refactoring of macro introduced 3 commits ago.
This commit is contained in:
Stephen Seo 2024-03-18 16:35:25 +09:00
parent 6d3a07975d
commit 6e2e67f086

View file

@ -6,15 +6,15 @@ macro_rules! cleanup_func {
$(var_pair: $orig_var:expr, $new_var:ident),*) => {
$(let $new_var = $orig_var;)*
struct $name <T: Fn() -> ()> {
struct $name <T: Fn()> {
func: T,
}
impl<T> Drop for $name <T> where T: Fn() -> () {
impl<T> Drop for $name <T> where T: Fn() {
fn drop(&mut self) {
(self.func)();
}
}
impl<T> $name <T> where T: Fn() -> () {
impl<T> $name <T> where T: Fn() {
fn new(func: T) -> Self {
Self {
func,