From ad6e7b7916beaf56615b4d46a9a7d868c69e599d Mon Sep 17 00:00:00 2001 From: peamaeq Date: Fri, 24 Jun 2022 00:22:53 +0800 Subject: [PATCH] Shrink unsafe blocks --- common/src/transaction_list.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/src/transaction_list.rs b/common/src/transaction_list.rs index 1715461..d0942bf 100644 --- a/common/src/transaction_list.rs +++ b/common/src/transaction_list.rs @@ -300,13 +300,13 @@ impl AsHashTree for TransactionList { impl Drop for TransactionList { fn drop(&mut self) { - unsafe { + for event in &self.events { - let as_mut_ref = &mut (*event.as_ptr()); - ptr::drop_in_place(as_mut_ref); - dealloc(event.cast().as_ptr(), Layout::for_value(event.as_ref())); + let as_mut_ref = unsafe { &mut (*event.as_ptr()) }; + unsafe { ptr::drop_in_place(as_mut_ref) }; + unsafe { dealloc(event.cast().as_ptr(), Layout::for_value(event.as_ref())) }; } - } + } }