Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing Send/Sync impls #225

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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