Skip to content

Commit 0fbf591

Browse files
197gsebcrozet
authored andcommitted
Fix T: Sync bound of impl Send for ViewStorage (#1581)
1 parent 8f117be commit 0fbf591

1 file changed

Lines changed: 28 additions & 8 deletions

File tree

src/base/matrix_view.rs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ macro_rules! view_storage_impl (
3333
#[deprecated = "Use ViewStorage(Mut) instead."]
3434
pub type $legacy_name<'a, T, R, C, RStride, CStride> = $T<'a, T, R, C, RStride, CStride>;
3535

36-
unsafe impl<'a, T: Send, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Send
37-
for $T<'a, T, R, C, RStride, CStride>
38-
{}
39-
40-
unsafe impl<'a, T: Sync, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Sync
41-
for $T<'a, T, R, C, RStride, CStride>
42-
{}
43-
4436
impl<'a, T, R: Dim, C: Dim, RStride: Dim, CStride: Dim> $T<'a, T, R, C, RStride, CStride> {
4537
/// Create a new matrix view without bounds checking and from a raw pointer.
4638
///
@@ -136,6 +128,20 @@ impl<T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Copy
136128
{
137129
}
138130

131+
/// Safety: Equivalent to a shared reference to `T`. All `Dim` type arguments are `Send + Sync`. A
132+
/// shared reference can be sent iff `T: Sync`.
133+
unsafe impl<'a, T: Sync, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Send
134+
for ViewStorage<'a, T, R, C, RStride, CStride>
135+
{
136+
}
137+
138+
/// Safety: Equivalent to a shared reference to `T`. All `Dim` type arguments are `Send + Sync`. A
139+
/// shared reference is `Sync` iff `T: Sync`.
140+
unsafe impl<'a, T: Sync, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Sync
141+
for ViewStorage<'a, T, R, C, RStride, CStride>
142+
{
143+
}
144+
139145
impl<T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Clone
140146
for ViewStorage<'_, T, R, C, RStride, CStride>
141147
{
@@ -145,6 +151,20 @@ impl<T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Clone
145151
}
146152
}
147153

154+
/// Safety: Equivalent to a unique reference to `T`. All `Dim` type arguments are `Send + Sync`. A
155+
/// unique reference is `Send` iff `T: Send`.
156+
unsafe impl<'a, T: Send, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Send
157+
for ViewStorageMut<'a, T, R, C, RStride, CStride>
158+
{
159+
}
160+
161+
/// Safety: Equivalent to a unique reference to `T`. All `Dim` type arguments are `Send + Sync`. A
162+
/// unique reference is `Sync` iff `T: Sync`.
163+
unsafe impl<'a, T: Sync, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Sync
164+
for ViewStorageMut<'a, T, R, C, RStride, CStride>
165+
{
166+
}
167+
148168
impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
149169
ViewStorageMut<'a, T, R, C, RStride, CStride>
150170
where

0 commit comments

Comments
 (0)