Skip to content

Commit 9f2b049

Browse files
committed
implement Zeroable for UnsafeCell
1 parent 275b8ab commit 9f2b049

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ extern crate alloc;
255255
use alloc::{boxed::Box, sync::Arc};
256256
use core::{
257257
alloc::AllocError,
258-
cell::Cell,
258+
cell::UnsafeCell,
259259
convert::Infallible,
260260
marker::PhantomData,
261261
mem::MaybeUninit,
@@ -1387,6 +1387,9 @@ impl_zeroable! {
13871387
// SAFETY: Type is allowed to take any value, including all zeros.
13881388
{<T>} MaybeUninit<T>,
13891389

1390+
// SAFETY: `T: Zeroable` and `UnsafeCell` is `repr(transparent)`.
1391+
{<T: ?Sized + Zeroable>} UnsafeCell<T>,
1392+
13901393
// SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee).
13911394
Option<NonZeroU8>, Option<NonZeroU16>, Option<NonZeroU32>, Option<NonZeroU64>,
13921395
Option<NonZeroU128>, Option<NonZeroUsize>,

0 commit comments

Comments
 (0)