From 7de26409c2f260bccf06b617e9e0ba0d4d0aeb71 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Fri, 9 Aug 2019 14:56:40 +0200 Subject: [PATCH] Better impl of write --- src/export.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/export.rs b/src/export.rs index 2f08b2678c..a0d40a93bb 100644 --- a/src/export.rs +++ b/src/export.rs @@ -1,7 +1,5 @@ //! IMPLEMENTATION DETAILS. DO NOT USE ANYTHING IN THIS MODULE -#[cfg(not(feature = "nightly"))] -use core::ptr; use core::{cell::Cell, u8}; #[cfg(armv7m)] @@ -101,11 +99,8 @@ impl MaybeUninit { #[cfg(not(feature = "nightly"))] pub fn write(&mut self, value: T) -> &mut T { - let ptr = self.inner.as_mut_ptr(); - unsafe { - ptr::write_volatile(ptr, value); - &mut *ptr - } + self.inner = core::mem::MaybeUninit::new(value); + unsafe { self.get_mut() } } }