diff options
| author | Quentin Smith <[email protected]> | 2022-08-19 00:53:06 -0400 |
|---|---|---|
| committer | Quentin Smith <[email protected]> | 2022-08-19 00:53:41 -0400 |
| commit | 71e468681b1c074e06276d34ff00e36169c632f5 (patch) | |
| tree | ce86220caabbdc044720df8efb23de7bc4c36ea0 /embassy-executor/src/executor/raw/util.rs | |
| parent | 2edf532f8d8ce048137990bf74b07759428ed7c1 (diff) | |
| parent | aefa5275a2ab2cac6caef599e7adb76ce1beeddd (diff) | |
Merge branch 'master' of https://github.com/embassy-rs/embassy into rtos-trace
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 | } | ||
