Skip to content

Commit

Permalink
Rollup merge of #98595 - cuviper:send-sync-thinbox, r=m-ou-se
Browse files Browse the repository at this point in the history
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 #92791.
  • Loading branch information
Dylan-DPC authored Jun 28, 2022
2 parents 6de107a + 6400736 commit 674c1fc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions library/alloc/src/boxed/thin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ pub struct ThinBox<T: ?Sized> {
_marker: PhantomData<T>,
}

/// `ThinBox<T>` is `Send` if `T` is `Send` because the data is owned.
#[unstable(feature = "thin_box", issue = "92791")]
unsafe impl<T: ?Sized + Send> Send for ThinBox<T> {}

/// `ThinBox<T>` is `Sync` if `T` is `Sync` because the data is owned.
#[unstable(feature = "thin_box", issue = "92791")]
unsafe impl<T: ?Sized + Sync> Sync for ThinBox<T> {}

#[unstable(feature = "thin_box", issue = "92791")]
impl<T> ThinBox<T> {
/// Moves a type to the heap with its `Metadata` stored in the heap allocation instead of on
Expand Down

0 comments on commit 674c1fc

Please sign in to comment.