Skip to content

Commit

Permalink
Add Send and Sync impls for Array
Browse files Browse the repository at this point in the history
Impls `Send` if the underlying type `T: Send`, and likewise for
`T: Sync`.
  • Loading branch information
tarcieri committed Jan 16, 2024
1 parent 600e0c7 commit cdbc860
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T, U: ArraySize> Send for Array<T, U> 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<T, U: ArraySize> Sync for Array<T, U> where T: Sync {}

impl<'a, T, U> TryFrom<&'a [T]> for Array<T, U>
where
Self: Clone,
Expand Down

0 comments on commit cdbc860

Please sign in to comment.