Skip to content

Commit 0a5e889

Browse files
committed
Small tweaks to CopyHelper
1 parent 8812f32 commit 0a5e889

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

crates/objc2/src/runtime/nscopying.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ pub trait Copyhelper<T: ?Sized> {
99
type CopyOutput: ?Sized + Message;
1010
type MutableCopyOutput: ?Sized + Message;
1111

12+
// TODO: Use this to autogenerate `ToOwned` impls
1213
#[doc(hidden)]
1314
fn __do_copy(t: &T) -> Id<T>;
1415
}
15-
impl<T: ClassType + NSCopying + Message<Kind = Unknown>> Copyhelper<T> for Unknown {
16+
impl<T: NSCopying + Message<Kind = Unknown>> Copyhelper<T> for Unknown {
1617
type CopyOutput = T;
1718
type MutableCopyOutput = T;
1819

@@ -21,7 +22,7 @@ impl<T: ClassType + NSCopying + Message<Kind = Unknown>> Copyhelper<T> for Unkno
2122
t.copy()
2223
}
2324
}
24-
impl<T: ClassType + NSCopying + Message<Kind = Immutable>> Copyhelper<T> for Immutable {
25+
impl<T: NSCopying + Message<Kind = Immutable>> Copyhelper<T> for Immutable {
2526
type CopyOutput = T;
2627
type MutableCopyOutput = T;
2728

@@ -30,7 +31,7 @@ impl<T: ClassType + NSCopying + Message<Kind = Immutable>> Copyhelper<T> for Imm
3031
t.copy()
3132
}
3233
}
33-
impl<T: ClassType + NSCopying + Message<Kind = Mutable>> Copyhelper<T> for Mutable {
34+
impl<T: NSCopying + Message<Kind = Mutable>> Copyhelper<T> for Mutable {
3435
type CopyOutput = T;
3536
type MutableCopyOutput = T;
3637

@@ -41,8 +42,8 @@ impl<T: ClassType + NSCopying + Message<Kind = Mutable>> Copyhelper<T> for Mutab
4142
}
4243
impl<T, S> Copyhelper<T> for ImmutableWithMutableSubclass<S>
4344
where
44-
T: ClassType + NSCopying + Message<Kind = ImmutableWithMutableSubclass<S>>,
45-
S: ClassType + Message<Kind = MutableWithImmutableSuperclass<T>>,
45+
T: NSCopying + Message<Kind = ImmutableWithMutableSubclass<S>>,
46+
S: Message<Kind = MutableWithImmutableSuperclass<T>>,
4647
{
4748
type CopyOutput = T;
4849
type MutableCopyOutput = S;
@@ -54,8 +55,8 @@ where
5455
}
5556
impl<T, S> Copyhelper<T> for MutableWithImmutableSuperclass<S>
5657
where
57-
T: ClassType + NSMutableCopying + Message<Kind = MutableWithImmutableSuperclass<S>>,
58-
S: ClassType + Message<Kind = ImmutableWithMutableSubclass<T>>,
58+
T: NSMutableCopying + Message<Kind = MutableWithImmutableSuperclass<S>>,
59+
S: Message<Kind = ImmutableWithMutableSubclass<T>>,
5960
{
6061
type CopyOutput = S;
6162
type MutableCopyOutput = T;
@@ -65,7 +66,7 @@ where
6566
t.mutableCopy()
6667
}
6768
}
68-
impl<T: ClassType + NSCopying + Message<Kind = InteriorMutable>> Copyhelper<T> for InteriorMutable {
69+
impl<T: NSCopying + Message<Kind = InteriorMutable>> Copyhelper<T> for InteriorMutable {
6970
type CopyOutput = T;
7071
type MutableCopyOutput = T;
7172

@@ -74,7 +75,7 @@ impl<T: ClassType + NSCopying + Message<Kind = InteriorMutable>> Copyhelper<T> f
7475
t.copy()
7576
}
7677
}
77-
impl<T: ClassType + NSCopying + Message<Kind = MainThreadOnly>> Copyhelper<T> for MainThreadOnly {
78+
impl<T: NSCopying + Message<Kind = MainThreadOnly>> Copyhelper<T> for MainThreadOnly {
7879
type CopyOutput = T;
7980
type MutableCopyOutput = T;
8081

@@ -100,7 +101,7 @@ pub unsafe trait NSCopying {
100101
/// `NSString`.
101102
fn copy(&self) -> Id<<Self::Kind as Copyhelper<Self>>::CopyOutput>
102103
where
103-
Self: Sized + ClassType,
104+
Self: Sized + Message,
104105
Self::Kind: Copyhelper<Self>,
105106
{
106107
unsafe { msg_send_id![self, copy] }
@@ -132,9 +133,10 @@ crate::__inner_extern_protocol!(
132133
/// - The `mutableCopy` selector must return an owned object.
133134
/// - TODO: More.
134135
pub unsafe trait NSMutableCopying {
136+
#[allow(non_snake_case)]
135137
fn mutableCopy(&self) -> Id<<Self::Kind as Copyhelper<Self>>::MutableCopyOutput>
136138
where
137-
Self: Sized + ClassType,
139+
Self: Sized + Message,
138140
Self::Kind: Copyhelper<Self>,
139141
{
140142
unsafe { msg_send_id![self, mutableCopy] }

0 commit comments

Comments
 (0)