Skip to content

Commit aa783eb

Browse files
committed
Remove Sized bound on INSObject
1 parent 3e95dae commit aa783eb

File tree

5 files changed

+9
-12
lines changed

5 files changed

+9
-12
lines changed

objc2-foundation/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2121
### Removed
2222
* **BREAKING**: Removed associated `Ownership` type from `INSObject`; instead,
2323
it is present on the types that actually need it (for example `NSCopying`).
24+
* **BREAKING**: Removed `Sized` bound on `INSObject`.
2425

2526
### Fixed
2627
* Soundness issue with `NSValue`, `NSDictionary`, `NSArray` and

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
@@ -11,8 +11,8 @@ use super::{INSCopying, INSFastEnumeration, INSObject, NSArray, NSEnumerator};
1111

1212
unsafe fn from_refs<D, T>(keys: &[&T], vals: &[&D::Value]) -> Id<D, Shared>
1313
where
14-
D: INSDictionary,
15-
T: INSCopying<Output = D::Key>,
14+
D: INSDictionary + ?Sized,
15+
T: INSCopying<Output = D::Key> + ?Sized,
1616
{
1717
let cls = D::class();
1818
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
@@ -94,7 +94,7 @@ unsafe impl<T: INSObject> RefEncode for NSFastEnumerationState<T> {
9494
const ENCODING_REF: Encoding<'static> = Encoding::Pointer(&Self::ENCODING);
9595
}
9696

97-
fn enumerate<'a, 'b: 'a, C: INSFastEnumeration>(
97+
fn enumerate<'a, 'b: 'a, C: INSFastEnumeration + ?Sized>(
9898
object: &'b C,
9999
state: &mut NSFastEnumerationState<C::Item>,
100100
buf: &'a mut [*const C::Item],
@@ -119,7 +119,7 @@ fn enumerate<'a, 'b: 'a, C: INSFastEnumeration>(
119119

120120
const FAST_ENUM_BUF_SIZE: usize = 16;
121121

122-
pub struct NSFastEnumerator<'a, C: 'a + INSFastEnumeration> {
122+
pub struct NSFastEnumerator<'a, C: 'a + INSFastEnumeration + ?Sized> {
123123
object: &'a C,
124124

125125
ptr: *const *const C::Item,
@@ -129,7 +129,7 @@ pub struct NSFastEnumerator<'a, C: 'a + INSFastEnumeration> {
129129
buf: [*const C::Item; FAST_ENUM_BUF_SIZE],
130130
}
131131

132-
impl<'a, C: INSFastEnumeration> NSFastEnumerator<'a, C> {
132+
impl<'a, C: INSFastEnumeration + ?Sized> NSFastEnumerator<'a, C> {
133133
fn new(object: &'a C) -> Self {
134134
Self {
135135
object,
@@ -174,7 +174,7 @@ impl<'a, C: INSFastEnumeration> NSFastEnumerator<'a, C> {
174174
}
175175
}
176176

177-
impl<'a, C: INSFastEnumeration> Iterator for NSFastEnumerator<'a, C> {
177+
impl<'a, C: INSFastEnumeration + ?Sized> Iterator for NSFastEnumerator<'a, C> {
178178
type Item = &'a C::Item;
179179

180180
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
@@ -8,11 +8,7 @@ use objc2::Message;
88

99
use super::NSString;
1010

11-
// The Sized bound is unfortunate; ideally, Objective-C objects would not be
12-
// treated as Sized. However, rust won't allow casting a dynamically-sized
13-
// type pointer to an Object pointer, because dynamically-sized types can have
14-
// fat pointers (two words) instead of real pointers.
15-
pub unsafe trait INSObject: Sized + Message {
11+
pub unsafe trait INSObject: Message {
1612
fn class() -> &'static Class;
1713

1814
fn hash_code(&self) -> usize {

0 commit comments

Comments
 (0)