From cdbc8601b03baaf5d00add28d4a1778d20f944ff Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Tue, 16 Jan 2024 16:26:41 -0700 Subject: [PATCH] Add `Send` and `Sync` impls for `Array` Impls `Send` if the underlying type `T: Send`, and likewise for `T: Sync`. --- src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 9cc84bd..9f03495 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -560,6 +560,14 @@ where } } +// SAFETY: `Array` is a `repr(transparent)` newtype for `[T; N]`, so as long as `T: Send` it should +// also be `Send`. +unsafe impl Send for Array where T: Send {} + +// SAFETY: `Array` is a `repr(transparent)` newtype for `[T; N]`, so as long as `T: Sync` it should +// also be `Sync`. +unsafe impl Sync for Array where T: Sync {} + impl<'a, T, U> TryFrom<&'a [T]> for Array where Self: Clone,