@@ -174,6 +174,16 @@ object!(
174
174
}
175
175
) ;
176
176
177
+ // SAFETY: Same as Id<T, O> (which is what NSArray effectively stores).
178
+ //
179
+ // The `PhantomData` can't get these impls to display in the docs.
180
+ //
181
+ // TODO: Properly verify this
182
+ unsafe impl < T : Sync + Send > Sync for NSArray < T , Shared > { }
183
+ unsafe impl < T : Sync + Send > Send for NSArray < T , Shared > { }
184
+ unsafe impl < T : Sync > Sync for NSArray < T , Owned > { }
185
+ unsafe impl < T : Send > Send for NSArray < T , Owned > { }
186
+
177
187
unsafe impl < T : INSObject , O : Ownership > INSArray for NSArray < T , O > {
178
188
/// The `NSArray` itself (length and number of items) is always immutable,
179
189
/// but we would like to know when we're the only owner of the array, to
@@ -319,6 +329,14 @@ object!(
319
329
}
320
330
) ;
321
331
332
+ // SAFETY: Same as NSArray.
333
+ //
334
+ // TODO: Properly verify this
335
+ unsafe impl < T : Sync + Send > Sync for NSMutableArray < T , Shared > { }
336
+ unsafe impl < T : Sync + Send > Send for NSMutableArray < T , Shared > { }
337
+ unsafe impl < T : Sync > Sync for NSMutableArray < T , Owned > { }
338
+ unsafe impl < T : Send > Send for NSMutableArray < T , Owned > { }
339
+
322
340
unsafe impl < T : INSObject , O : Ownership > INSArray for NSMutableArray < T , O > {
323
341
type Ownership = Owned ;
324
342
type Item = T ;
@@ -540,4 +558,14 @@ mod tests {
540
558
assert_eq ! ( strings[ 1 ] . as_str( pool) , "hello" ) ;
541
559
} ) ;
542
560
}
561
+
562
+ #[ test]
563
+ fn test_send_sync ( ) {
564
+ fn assert_send_sync < T : Send + Sync > ( ) { }
565
+
566
+ assert_send_sync :: < NSArray < NSString , Shared > > ( ) ;
567
+ assert_send_sync :: < NSMutableArray < NSString , Shared > > ( ) ;
568
+ assert_send_sync :: < Id < NSArray < NSString , Shared > , Shared > > ( ) ;
569
+ assert_send_sync :: < Id < NSMutableArray < NSString , Shared > , Owned > > ( ) ;
570
+ }
543
571
}
0 commit comments