Skip to content

Commit 23cf4c5

Browse files
committed
add Send bound for SingleUseCell's Sync impl
1 parent df498d8 commit 23cf4c5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@ impl<T> SingleUseCell<T> {
166166
}
167167

168168
// SAFETY: Sharing a `SingleUseCell<T>` between threads is safe regardless of whether `T` is `Sync`
169-
// because we only expose the inner value once to one thread.
170-
unsafe impl<T> Sync for SingleUseCell<T> {}
169+
// because we only expose the inner value once to one thread. The `T: Send` bound makes sure that
170+
// sending a unique reference to another thread is safe.
171+
unsafe impl<T: Send> Sync for SingleUseCell<T> {}
171172

172173
// SAFETY: It's safe to send a `SingleUseCell<T>` to another thread if it's safe to send `T`.
173174
unsafe impl<T: Send> Send for SingleUseCell<T> {}

0 commit comments

Comments
 (0)