Skip to content

Commit 674c1fc

Browse files
authored
Rollup merge of rust-lang#98595 - cuviper:send-sync-thinbox, r=m-ou-se
Implement `Send` and `Sync` for `ThinBox<T>` Just like `Box<T>`, `ThinBox<T>` owns its data on the heap, so it should implement `Send` and `Sync` when `T` does. This extends tracking issue rust-lang#92791.
2 parents 6de107a + 6400736 commit 674c1fc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/alloc/src/boxed/thin.rs

+8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ pub struct ThinBox<T: ?Sized> {
3333
_marker: PhantomData<T>,
3434
}
3535

36+
/// `ThinBox<T>` is `Send` if `T` is `Send` because the data is owned.
37+
#[unstable(feature = "thin_box", issue = "92791")]
38+
unsafe impl<T: ?Sized + Send> Send for ThinBox<T> {}
39+
40+
/// `ThinBox<T>` is `Sync` if `T` is `Sync` because the data is owned.
41+
#[unstable(feature = "thin_box", issue = "92791")]
42+
unsafe impl<T: ?Sized + Sync> Sync for ThinBox<T> {}
43+
3644
#[unstable(feature = "thin_box", issue = "92791")]
3745
impl<T> ThinBox<T> {
3846
/// Moves a type to the heap with its `Metadata` stored in the heap allocation instead of on

0 commit comments

Comments
 (0)