mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
Better impl of write
This commit is contained in:
parent
e9bc00bc9b
commit
7de26409c2
1 changed files with 2 additions and 7 deletions
|
@ -1,7 +1,5 @@
|
||||||
//! IMPLEMENTATION DETAILS. DO NOT USE ANYTHING IN THIS MODULE
|
//! IMPLEMENTATION DETAILS. DO NOT USE ANYTHING IN THIS MODULE
|
||||||
|
|
||||||
#[cfg(not(feature = "nightly"))]
|
|
||||||
use core::ptr;
|
|
||||||
use core::{cell::Cell, u8};
|
use core::{cell::Cell, u8};
|
||||||
|
|
||||||
#[cfg(armv7m)]
|
#[cfg(armv7m)]
|
||||||
|
@ -101,11 +99,8 @@ impl<T> MaybeUninit<T> {
|
||||||
|
|
||||||
#[cfg(not(feature = "nightly"))]
|
#[cfg(not(feature = "nightly"))]
|
||||||
pub fn write(&mut self, value: T) -> &mut T {
|
pub fn write(&mut self, value: T) -> &mut T {
|
||||||
let ptr = self.inner.as_mut_ptr();
|
self.inner = core::mem::MaybeUninit::new(value);
|
||||||
unsafe {
|
unsafe { self.get_mut() }
|
||||||
ptr::write_volatile(ptr, value);
|
|
||||||
&mut *ptr
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue