Skip to main content

rust_spec/core_impls/
cells.rs

1use core::{
2    cell::{Cell, UnsafeCell},
3    ops::Add,
4};
5
6use crate::{
7    RustSpec, drop::NoDrop, layout::Robust, mutability::WithInterior, niche::WithoutNiche,
8};
9
10macro_rules! interior_cell {
11    ($($ty:ident),+ $(,)?) => {$(
12        unsafe impl<T: RustSpec + ?Sized> RustSpec for $ty<T>
13        where
14            Robust: Add<T::Trap>,
15            NoDrop: Add<T::Drop>,
16        {
17            type Layout = T::Layout;
18            type Size = T::Size;
19            type Alignment = T::Alignment;
20            type Trap = <Robust as Add<T::Trap>>::Output;
21            type Niche = WithoutNiche;
22            type Drop = <NoDrop as Add<T::Drop>>::Output;
23            type Mutability = WithInterior;
24            type __IndirectTrap = T::__IndirectTrap;
25        }
26    )+};
27}
28
29interior_cell!(UnsafeCell, Cell);