diff --git a/src/cell.rs b/src/cell.rs index f0c93c1..34d716d 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -47,6 +47,10 @@ pub struct Ref<'a, T: ?Sized + 'a> { value: NonNull, } +// SAFETY: `Ref<'_, T> acts as a reference. +unsafe impl<'a, T: ?Sized + 'a> Sync for Ref<'a, T> where for<'b> &'b T: Sync {} +unsafe impl<'a, T: ?Sized + 'a> Send for Ref<'a, T> where for<'b> &'b T: Send {} + impl<'a, T: ?Sized> Ref<'a, T> { /// Makes a new `Ref` for a component of the borrowed data which preserves /// the existing borrow. @@ -143,6 +147,10 @@ pub struct RefMut<'a, T: ?Sized + 'a> { marker: PhantomData<&'a mut T>, } +// SAFETY: `RefMut<'_, T> acts as a mutable reference. +unsafe impl<'a, T: ?Sized + 'a> Sync for RefMut<'a, T> where for<'b> &'b mut T: Sync {} +unsafe impl<'a, T: ?Sized + 'a> Send for RefMut<'a, T> where for<'b> &'b mut T: Send {} + impl<'a, T: ?Sized> RefMut<'a, T> { /// Makes a new `RefMut` for a component of the borrowed data which /// preserves the existing borrow.