diff options
| author | Mathias <[email protected]> | 2022-08-18 21:08:57 +0200 |
|---|---|---|
| committer | Mathias <[email protected]> | 2022-08-18 21:08:57 +0200 |
| commit | a7d6bc7ba5faef3d711b944baf6c8e3685fdb37e (patch) | |
| tree | d35085173fb8e4a0ff3b6357e3aaef18c6124e6e /embassy-executor/src/executor/raw/util.rs | |
| parent | 9c9b7b1a66dc90a9183886867811d2db57df714c (diff) | |
| parent | aefa5275a2ab2cac6caef599e7adb76ce1beeddd (diff) | |
Merge branch 'master' of https://github.com/embassy-rs/embassy into embassy-rp/dma
Diffstat (limited to 'embassy-executor/src/executor/raw/util.rs')
| -rw-r--r-- | embassy-executor/src/executor/raw/util.rs | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/embassy-executor/src/executor/raw/util.rs b/embassy-executor/src/executor/raw/util.rs deleted file mode 100644 index ed5822188..000000000 --- a/embassy-executor/src/executor/raw/util.rs +++ /dev/null | |||
| @@ -1,33 +0,0 @@ | |||
| 1 | use core::cell::UnsafeCell; | ||
| 2 | use core::mem::MaybeUninit; | ||
| 3 | use core::ptr; | ||
| 4 | |||
| 5 | pub(crate) struct UninitCell<T>(MaybeUninit<UnsafeCell<T>>); | ||
| 6 | impl<T> UninitCell<T> { | ||
| 7 | pub const fn uninit() -> Self { | ||
| 8 | Self(MaybeUninit::uninit()) | ||
| 9 | } | ||
| 10 | |||
| 11 | pub unsafe fn as_mut_ptr(&self) -> *mut T { | ||
| 12 | (*self.0.as_ptr()).get() | ||
| 13 | } | ||
| 14 | |||
| 15 | #[allow(clippy::mut_from_ref)] | ||
| 16 | pub unsafe fn as_mut(&self) -> &mut T { | ||
| 17 | &mut *self.as_mut_ptr() | ||
| 18 | } | ||
| 19 | |||
| 20 | pub unsafe fn write(&self, val: T) { | ||
| 21 | ptr::write(self.as_mut_ptr(), val) | ||
| 22 | } | ||
| 23 | |||
| 24 | pub unsafe fn drop_in_place(&self) { | ||
| 25 | ptr::drop_in_place(self.as_mut_ptr()) | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | impl<T: Copy> UninitCell<T> { | ||
| 30 | pub unsafe fn read(&self) -> T { | ||
| 31 | ptr::read(self.as_mut_ptr()) | ||
| 32 | } | ||
| 33 | } | ||
