Skip to content

Commit

Permalink
Merge pull request #225 from Imberflur/trustcell-fix
Browse files Browse the repository at this point in the history
Add missing Send/Sync impls
  • Loading branch information
zesterer authored Feb 13, 2023
2 parents 0daab64 + 14096ad commit 9708b7f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ pub struct Ref<'a, T: ?Sized + 'a> {
value: NonNull<T>,
}

// 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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 9708b7f

Please sign in to comment.