@@ -30,7 +30,7 @@ unsafe fn from_refs<A: INSArray + ?Sized>(refs: &[&A::Item]) -> Id<A, A::Ownersh
30
30
31
31
pub unsafe trait INSArray : INSObject {
32
32
type Ownership : Ownership ;
33
- type Item : INSObject ;
33
+ type Item : INSObject + ? Sized ;
34
34
type ItemOwnership : Ownership ;
35
35
36
36
unsafe_def_fn ! ( fn new -> Self :: Ownership ) ;
@@ -169,7 +169,7 @@ object!(
169
169
/// TODO: Can we make it impossible? Should we?
170
170
///
171
171
/// What about `Id<NSArray<T, Shared>, Owned>`?
172
- unsafe pub struct NSArray <T , O : Ownership > {
172
+ unsafe pub struct NSArray <T : ? Sized , O : Ownership > {
173
173
item: PhantomData <Id <T , O >>,
174
174
}
175
175
) ;
@@ -179,22 +179,22 @@ object!(
179
179
// The `PhantomData` can't get these impls to display in the docs.
180
180
//
181
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 > { }
182
+ unsafe impl < T : Sync + Send + ? Sized > Sync for NSArray < T , Shared > { }
183
+ unsafe impl < T : Sync + Send + ? Sized > Send for NSArray < T , Shared > { }
184
+ unsafe impl < T : Sync + ? Sized > Sync for NSArray < T , Owned > { }
185
+ unsafe impl < T : Send + ? Sized > Send for NSArray < T , Owned > { }
186
186
187
187
/// ```compile_fail
188
188
/// use objc2::rc::Shared;
189
189
/// use objc2::runtime::Object;
190
190
/// use objc2_foundation::NSArray;
191
- /// fn needs_send_sync<T: Send + Sync>() {}
191
+ /// fn needs_send_sync<T: Send + Sync + ?Sized >() {}
192
192
/// needs_send_sync::<NSArray<Object, Shared>>();
193
193
/// ```
194
194
#[ cfg( doctest) ]
195
195
pub struct NSArrayWithObjectNotSendSync ;
196
196
197
- unsafe impl < T : INSObject , O : Ownership > INSArray for NSArray < T , O > {
197
+ unsafe impl < T : INSObject + ? Sized , O : Ownership > INSArray for NSArray < T , O > {
198
198
/// The `NSArray` itself (length and number of items) is always immutable,
199
199
/// but we would like to know when we're the only owner of the array, to
200
200
/// allow mutation of the array's items.
@@ -208,20 +208,20 @@ unsafe impl<T: INSObject, O: Ownership> INSArray for NSArray<T, O> {
208
208
209
209
// Copying only possible when ItemOwnership = Shared
210
210
211
- unsafe impl < T : INSObject > INSCopying for NSArray < T , Shared > {
211
+ unsafe impl < T : INSObject + ? Sized > INSCopying for NSArray < T , Shared > {
212
212
type Ownership = Shared ;
213
213
type Output = NSArray < T , Shared > ;
214
214
}
215
215
216
- unsafe impl < T : INSObject > INSMutableCopying for NSArray < T , Shared > {
216
+ unsafe impl < T : INSObject + ? Sized > INSMutableCopying for NSArray < T , Shared > {
217
217
type Output = NSMutableArray < T , Shared > ;
218
218
}
219
219
220
- unsafe impl < T : INSObject , O : Ownership > INSFastEnumeration for NSArray < T , O > {
220
+ unsafe impl < T : INSObject + ? Sized , O : Ownership > INSFastEnumeration for NSArray < T , O > {
221
221
type Item = T ;
222
222
}
223
223
224
- impl < T : INSObject , O : Ownership > Index < usize > for NSArray < T , O > {
224
+ impl < T : INSObject + ? Sized , O : Ownership > Index < usize > for NSArray < T , O > {
225
225
type Output = T ;
226
226
227
227
fn index ( & self , index : usize ) -> & T {
@@ -306,7 +306,7 @@ pub unsafe trait INSMutableArray: INSArray {
306
306
where
307
307
F : FnMut ( & Self :: Item , & Self :: Item ) -> Ordering ,
308
308
{
309
- extern "C" fn compare_with_closure < T , F : FnMut ( & T , & T ) -> Ordering > (
309
+ extern "C" fn compare_with_closure < T : ? Sized , F : FnMut ( & T , & T ) -> Ordering > (
310
310
obj1 : & T ,
311
311
obj2 : & T ,
312
312
context : * mut c_void ,
@@ -334,43 +334,43 @@ pub unsafe trait INSMutableArray: INSArray {
334
334
}
335
335
336
336
object ! (
337
- unsafe pub struct NSMutableArray <T , O : Ownership > {
337
+ unsafe pub struct NSMutableArray <T : ? Sized , O : Ownership > {
338
338
item: PhantomData <Id <T , O >>,
339
339
}
340
340
) ;
341
341
342
342
// SAFETY: Same as NSArray.
343
343
//
344
344
// TODO: Properly verify this
345
- unsafe impl < T : Sync + Send > Sync for NSMutableArray < T , Shared > { }
346
- unsafe impl < T : Sync + Send > Send for NSMutableArray < T , Shared > { }
347
- unsafe impl < T : Sync > Sync for NSMutableArray < T , Owned > { }
348
- unsafe impl < T : Send > Send for NSMutableArray < T , Owned > { }
345
+ unsafe impl < T : Sync + Send + ? Sized > Sync for NSMutableArray < T , Shared > { }
346
+ unsafe impl < T : Sync + Send + ? Sized > Send for NSMutableArray < T , Shared > { }
347
+ unsafe impl < T : Sync + ? Sized > Sync for NSMutableArray < T , Owned > { }
348
+ unsafe impl < T : Send + ? Sized > Send for NSMutableArray < T , Owned > { }
349
349
350
- unsafe impl < T : INSObject , O : Ownership > INSArray for NSMutableArray < T , O > {
350
+ unsafe impl < T : INSObject + ? Sized , O : Ownership > INSArray for NSMutableArray < T , O > {
351
351
type Ownership = Owned ;
352
352
type Item = T ;
353
353
type ItemOwnership = O ;
354
354
}
355
355
356
- unsafe impl < T : INSObject , O : Ownership > INSMutableArray for NSMutableArray < T , O > { }
356
+ unsafe impl < T : INSObject + ? Sized , O : Ownership > INSMutableArray for NSMutableArray < T , O > { }
357
357
358
358
// Copying only possible when ItemOwnership = Shared
359
359
360
- unsafe impl < T : INSObject > INSCopying for NSMutableArray < T , Shared > {
360
+ unsafe impl < T : INSObject + ? Sized > INSCopying for NSMutableArray < T , Shared > {
361
361
type Ownership = Shared ;
362
362
type Output = NSArray < T , Shared > ;
363
363
}
364
364
365
- unsafe impl < T : INSObject > INSMutableCopying for NSMutableArray < T , Shared > {
365
+ unsafe impl < T : INSObject + ? Sized > INSMutableCopying for NSMutableArray < T , Shared > {
366
366
type Output = NSMutableArray < T , Shared > ;
367
367
}
368
368
369
- unsafe impl < T : INSObject , O : Ownership > INSFastEnumeration for NSMutableArray < T , O > {
369
+ unsafe impl < T : INSObject + ? Sized , O : Ownership > INSFastEnumeration for NSMutableArray < T , O > {
370
370
type Item = T ;
371
371
}
372
372
373
- impl < T : INSObject , O : Ownership > Index < usize > for NSMutableArray < T , O > {
373
+ impl < T : INSObject + ? Sized , O : Ownership > Index < usize > for NSMutableArray < T , O > {
374
374
type Output = T ;
375
375
376
376
fn index ( & self , index : usize ) -> & T {
@@ -571,7 +571,7 @@ mod tests {
571
571
572
572
#[ test]
573
573
fn test_send_sync ( ) {
574
- fn assert_send_sync < T : Send + Sync > ( ) { }
574
+ fn assert_send_sync < T : Send + Sync + ? Sized > ( ) { }
575
575
576
576
assert_send_sync :: < NSArray < NSString , Shared > > ( ) ;
577
577
assert_send_sync :: < NSMutableArray < NSString , Shared > > ( ) ;
0 commit comments