From 00fb24c0d22786645b8bb178a72ee0f66cb44590 Mon Sep 17 00:00:00 2001 From: Kodi Craft Date: Mon, 24 Jun 2024 23:40:47 +0200 Subject: [PATCH] implement Drop for client struct --- src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index b898e08..9dcfc10 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -618,7 +618,7 @@ fn derive_protocol(input: proc_macro2::TokenStream) -> proc_macro2::TokenStream // Create a struct which the client will use to communicate let client_recv_queue_wrapper = format_ident!("__{}RecvQueueWrapper", name); let client_struct = quote! { - #[derive(Clone)] + #[derive(::std::clone::Clone)] struct #client_recv_queue_wrapper { recv_queue: ::std::sync::Arc<::tokio::sync::Mutex<::tokio::sync::mpsc::Receiver<(u64, #answer_enum_name)>>>, } @@ -707,6 +707,11 @@ fn derive_protocol(input: proc_macro2::TokenStream) -> proc_macro2::TokenStream } #(#client_impl)* } + impl std::drop::Drop for #client_struct_name { + fn drop(&mut self) { + self.close(); + } + } }; let expanded = quote! {