From 82855ac66b6d4176ab37f6923f84a01fbbfc5303 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Wed, 10 May 2023 16:02:21 +0100 Subject: [PATCH] Remove unsafe from clone --- agb-hashmap/src/node.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/agb-hashmap/src/node.rs b/agb-hashmap/src/node.rs index 0cbe22f5..29ed7efb 100644 --- a/agb-hashmap/src/node.rs +++ b/agb-hashmap/src/node.rs @@ -156,18 +156,12 @@ where V: Clone, { fn clone(&self) -> Self { - if self.has_value() { + if let Some((k, v)) = self.key_value_ref() { Self { hash: self.hash, distance_to_initial_bucket: self.distance_to_initial_bucket, - key: MaybeUninit::new( - // SAFETY: has a value - unsafe { self.key.assume_init_ref() }.clone(), - ), - value: MaybeUninit::new( - // SAFETY: has a value - unsafe { self.value.assume_init_ref() }.clone(), - ), + key: MaybeUninit::new(k.clone()), + value: MaybeUninit::new(v.clone()), } } else { Self {