diff --git a/embassy/src/util/forever.rs b/embassy/src/util/forever.rs index 4c2620052..3d2af38b1 100644 --- a/embassy/src/util/forever.rs +++ b/embassy/src/util/forever.rs @@ -74,12 +74,8 @@ impl Forever { panic!("Forever.put() called multiple times"); } - unsafe { - let p = self.t.get(); - let p = (&mut *p).as_mut_ptr(); - p.write(val()); - &mut *p - } + let p: &'static mut MaybeUninit = unsafe { &mut *self.t.get() }; + p.write(val()) } /// Unsafely get a mutable reference to the contents of this Forever. @@ -93,8 +89,7 @@ impl Forever { #[inline(always)] #[allow(clippy::mut_from_ref)] pub unsafe fn steal(&self) -> &mut T { - let p = self.t.get(); - let p = (&mut *p).as_mut_ptr(); - &mut *p + let p: &mut MaybeUninit = &mut *self.t.get(); + p.assume_init_mut() } }