diff options
| author | Josh Stone <jistone@redhat.com> | 2022-06-27 15:49:59 -0700 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2022-06-27 15:49:59 -0700 |
| commit | 6400736142172ea0cd64e742bf43cd119e24f02a (patch) | |
| tree | 905243dae1b32bcf4c3e20e35066e0c52ae66967 /library/alloc/src | |
| parent | 2f3ddd9f594adf9773547aa7cedb43c4ac8ffd2f (diff) | |
| download | rust-6400736142172ea0cd64e742bf43cd119e24f02a.tar.gz rust-6400736142172ea0cd64e742bf43cd119e24f02a.zip | |
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.
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/boxed/thin.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/library/alloc/src/boxed/thin.rs b/library/alloc/src/boxed/thin.rs index 807c035fdbd..203e5dff0c7 100644 --- a/library/alloc/src/boxed/thin.rs +++ b/library/alloc/src/boxed/thin.rs @@ -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 |
