Skip to content

Commit 2298e1b

Browse files
committed
make PySliceContainer Sync
1 parent 0f1dd03 commit 2298e1b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/dtype.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ impl Sealed for Bound<'_, PyArrayDescr> {}
697697
///
698698
/// [enumerated-types]: https://numpy.org/doc/stable/reference/c-api/dtype.html#enumerated-types
699699
/// [data-models]: https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models
700-
pub unsafe trait Element: Sized + Send {
700+
pub unsafe trait Element: Sized + Send + Sync {
701701
/// Flag that indicates whether this type is trivially copyable.
702702
///
703703
/// It should be set to true for all trivially copyable types (like scalar types

src/slice_container.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ pub(crate) struct PySliceContainer {
1414
}
1515

1616
unsafe impl Send for PySliceContainer {}
17+
unsafe impl Sync for PySliceContainer {}
1718

18-
impl<T: Send> From<Box<[T]>> for PySliceContainer {
19+
impl<T: Send + Sync> From<Box<[T]>> for PySliceContainer {
1920
fn from(data: Box<[T]>) -> Self {
2021
unsafe fn drop_boxed_slice<T>(ptr: *mut u8, len: usize, _cap: usize) {
2122
let _ = Box::from_raw(ptr::slice_from_raw_parts_mut(ptr as *mut T, len));
@@ -39,7 +40,7 @@ impl<T: Send> From<Box<[T]>> for PySliceContainer {
3940
}
4041
}
4142

42-
impl<T: Send> From<Vec<T>> for PySliceContainer {
43+
impl<T: Send + Sync> From<Vec<T>> for PySliceContainer {
4344
fn from(data: Vec<T>) -> Self {
4445
unsafe fn drop_vec<T>(ptr: *mut u8, len: usize, cap: usize) {
4546
let _ = Vec::from_raw_parts(ptr as *mut T, len, cap);
@@ -65,7 +66,7 @@ impl<T: Send> From<Vec<T>> for PySliceContainer {
6566

6667
impl<A, D> From<ArrayBase<OwnedRepr<A>, D>> for PySliceContainer
6768
where
68-
A: Send,
69+
A: Send + Sync,
6970
D: Dimension,
7071
{
7172
fn from(data: ArrayBase<OwnedRepr<A>, D>) -> Self {

0 commit comments

Comments
 (0)