Skip to content

Commit cdbc860

Browse files
committed
Add Send and Sync impls for Array
Impls `Send` if the underlying type `T: Send`, and likewise for `T: Sync`.
1 parent 600e0c7 commit cdbc860

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,14 @@ where
560560
}
561561
}
562562

563+
// SAFETY: `Array` is a `repr(transparent)` newtype for `[T; N]`, so as long as `T: Send` it should
564+
// also be `Send`.
565+
unsafe impl<T, U: ArraySize> Send for Array<T, U> where T: Send {}
566+
567+
// SAFETY: `Array` is a `repr(transparent)` newtype for `[T; N]`, so as long as `T: Sync` it should
568+
// also be `Sync`.
569+
unsafe impl<T, U: ArraySize> Sync for Array<T, U> where T: Sync {}
570+
563571
impl<'a, T, U> TryFrom<&'a [T]> for Array<T, U>
564572
where
565573
Self: Clone,

0 commit comments

Comments
 (0)