implement Drop for client struct
This commit is contained in:
		
							parent
							
								
									b5870e62fe
								
							
						
					
					
						commit
						00fb24c0d2
					
				| @ -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! { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user