Skip to content

Commit dc303e6

Browse files
committed
Remove Sized bound on INSObject
1 parent 220f562 commit dc303e6

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

objc2-foundation/src/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use super::{
1414
NSRange,
1515
};
1616

17-
unsafe fn from_refs<A: INSArray>(refs: &[&A::Item]) -> Id<A, A::Ownership> {
17+
unsafe fn from_refs<A: INSArray + ?Sized>(refs: &[&A::Item]) -> Id<A, A::Ownership> {
1818
let cls = A::class();
1919
let obj: *mut A = unsafe { msg_send![cls, alloc] };
2020
let obj: *mut A = unsafe {

objc2-foundation/src/dictionary.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use super::{INSCopying, INSFastEnumeration, INSObject, NSArray, NSEnumerator};
1212

1313
unsafe fn from_refs<D, T>(keys: &[&T], vals: &[&D::Value]) -> Id<D, D::Ownership>
1414
where
15-
D: INSDictionary,
16-
T: INSCopying<Output = D::Key>,
15+
D: INSDictionary + ?Sized,
16+
T: INSCopying<Output = D::Key> + ?Sized,
1717
{
1818
let cls = D::class();
1919
let count = min(keys.len(), vals.len());

objc2-foundation/src/enumerator.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ unsafe impl<T: INSObject> RefEncode for NSFastEnumerationState<T> {
7272
const ENCODING_REF: Encoding<'static> = Encoding::Pointer(&Self::ENCODING);
7373
}
7474

75-
fn enumerate<'a, 'b: 'a, C: INSFastEnumeration>(
75+
fn enumerate<'a, 'b: 'a, C: INSFastEnumeration + ?Sized>(
7676
object: &'b C,
7777
state: &mut NSFastEnumerationState<C::Item>,
7878
buf: &'a mut [*const C::Item],
@@ -97,7 +97,7 @@ fn enumerate<'a, 'b: 'a, C: INSFastEnumeration>(
9797

9898
const FAST_ENUM_BUF_SIZE: usize = 16;
9999

100-
pub struct NSFastEnumerator<'a, C: 'a + INSFastEnumeration> {
100+
pub struct NSFastEnumerator<'a, C: 'a + INSFastEnumeration + ?Sized> {
101101
object: &'a C,
102102

103103
ptr: *const *const C::Item,
@@ -107,7 +107,7 @@ pub struct NSFastEnumerator<'a, C: 'a + INSFastEnumeration> {
107107
buf: [*const C::Item; FAST_ENUM_BUF_SIZE],
108108
}
109109

110-
impl<'a, C: INSFastEnumeration> NSFastEnumerator<'a, C> {
110+
impl<'a, C: INSFastEnumeration + ?Sized> NSFastEnumerator<'a, C> {
111111
fn new(object: &'a C) -> Self {
112112
Self {
113113
object,
@@ -151,7 +151,7 @@ impl<'a, C: INSFastEnumeration> NSFastEnumerator<'a, C> {
151151
}
152152
}
153153

154-
impl<'a, C: INSFastEnumeration> Iterator for NSFastEnumerator<'a, C> {
154+
impl<'a, C: INSFastEnumeration + ?Sized> Iterator for NSFastEnumerator<'a, C> {
155155
type Item = &'a C::Item;
156156

157157
fn next(&mut self) -> Option<&'a C::Item> {

objc2-foundation/src/object.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ use objc2::Message;
77

88
use super::NSString;
99

10-
// The Sized bound is unfortunate; ideally, Objective-C objects would not be
11-
// treated as Sized. However, rust won't allow casting a dynamically-sized
12-
// type pointer to an Object pointer, because dynamically-sized types can have
13-
// fat pointers (two words) instead of real pointers.
14-
pub unsafe trait INSObject: Sized + Message {
10+
pub unsafe trait INSObject: Message {
1511
/// Indicates whether the type is mutable or immutable.
1612
///
1713
/// [`Shared`] means that only a shared [`Id`] can ever be held to this

0 commit comments

Comments
 (0)