Skip to main content

rust_spec/core_impls/
cells.rs

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