@@ -7,7 +7,7 @@ use crate::encode::{Encoding, RefEncode};
77use crate :: rc:: { autoreleasepool_leaking, Id } ;
88use crate :: runtime:: __nsstring:: nsstring_to_str;
99use crate :: runtime:: { AnyObject , NSObjectProtocol } ;
10- use crate :: { Message , ProtocolType } ;
10+ use crate :: Message ;
1111
1212/// An internal helper trait for [`ProtocolObject`].
1313///
@@ -57,25 +57,25 @@ pub unsafe trait ImplementedBy<T: ?Sized + Message> {
5757/// ```
5858#[ doc( alias = "id" ) ]
5959#[ repr( C ) ]
60- pub struct ProtocolObject < P : ?Sized + ProtocolType > {
60+ pub struct ProtocolObject < P : ?Sized > {
6161 inner : AnyObject ,
6262 p : PhantomData < P > ,
6363}
6464
6565// SAFETY: The type is `#[repr(C)]` and `AnyObject` internally
66- unsafe impl < P : ?Sized + ProtocolType > RefEncode for ProtocolObject < P > {
66+ unsafe impl < P : ?Sized > RefEncode for ProtocolObject < P > {
6767 const ENCODING_REF : Encoding = Encoding :: Object ;
6868}
6969
7070// SAFETY: The type is `AnyObject` internally, and is mean to be messaged
7171// as-if it's an object.
72- unsafe impl < P : ?Sized + ProtocolType > Message for ProtocolObject < P > { }
72+ unsafe impl < P : ?Sized > Message for ProtocolObject < P > { }
7373
74- impl < P : ?Sized + ProtocolType > ProtocolObject < P > {
74+ impl < P : ?Sized > ProtocolObject < P > {
7575 /// Get an immutable type-erased reference from a type implementing a
7676 /// protocol.
7777 #[ inline]
78- pub fn from_ref < T : Message > ( obj : & T ) -> & Self
78+ pub fn from_ref < T : ? Sized + Message > ( obj : & T ) -> & Self
7979 where
8080 P : ImplementedBy < T > ,
8181 {
@@ -89,7 +89,7 @@ impl<P: ?Sized + ProtocolType> ProtocolObject<P> {
8989 /// Get a mutable type-erased reference from a type implementing a
9090 /// protocol.
9191 #[ inline]
92- pub fn from_mut < T : Message > ( obj : & mut T ) -> & mut Self
92+ pub fn from_mut < T : ? Sized + Message > ( obj : & mut T ) -> & mut Self
9393 where
9494 P : ImplementedBy < T > ,
9595 {
@@ -118,24 +118,24 @@ impl<P: ?Sized + ProtocolType> ProtocolObject<P> {
118118 }
119119}
120120
121- impl < P : ?Sized + ProtocolType + NSObjectProtocol > PartialEq for ProtocolObject < P > {
121+ impl < P : ?Sized + NSObjectProtocol > PartialEq for ProtocolObject < P > {
122122 #[ inline]
123123 #[ doc( alias = "isEqual:" ) ]
124124 fn eq ( & self , other : & Self ) -> bool {
125125 self . __isEqual ( other)
126126 }
127127}
128128
129- impl < P : ?Sized + ProtocolType + NSObjectProtocol > Eq for ProtocolObject < P > { }
129+ impl < P : ?Sized + NSObjectProtocol > Eq for ProtocolObject < P > { }
130130
131- impl < P : ?Sized + ProtocolType + NSObjectProtocol > hash:: Hash for ProtocolObject < P > {
131+ impl < P : ?Sized + NSObjectProtocol > hash:: Hash for ProtocolObject < P > {
132132 #[ inline]
133133 fn hash < H : hash:: Hasher > ( & self , state : & mut H ) {
134134 self . __hash ( ) . hash ( state) ;
135135 }
136136}
137137
138- impl < P : ?Sized + ProtocolType + NSObjectProtocol > fmt:: Debug for ProtocolObject < P > {
138+ impl < P : ?Sized + NSObjectProtocol > fmt:: Debug for ProtocolObject < P > {
139139 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
140140 // Attempt to format description string
141141 if let Some ( description) = self . __description ( ) {
@@ -159,29 +159,27 @@ impl<P: ?Sized + ProtocolType + NSObjectProtocol> fmt::Debug for ProtocolObject<
159159 }
160160}
161161
162- impl < P , T > AsRef < ProtocolObject < T > > for ProtocolObject < P >
162+ impl < P : ? Sized , T > AsRef < ProtocolObject < T > > for ProtocolObject < P >
163163where
164- P : ?Sized + ProtocolType ,
165- T : ?Sized + ProtocolType + ImplementedBy < ProtocolObject < P > > ,
164+ T : ?Sized + ImplementedBy < ProtocolObject < P > > ,
166165{
167166 #[ inline]
168167 fn as_ref ( & self ) -> & ProtocolObject < T > {
169168 ProtocolObject :: from_ref ( self )
170169 }
171170}
172171
173- impl < P , T > AsMut < ProtocolObject < T > > for ProtocolObject < P >
172+ impl < P : ? Sized , T > AsMut < ProtocolObject < T > > for ProtocolObject < P >
174173where
175- P : ?Sized + ProtocolType ,
176- T : ?Sized + ProtocolType + ImplementedBy < ProtocolObject < P > > ,
174+ T : ?Sized + ImplementedBy < ProtocolObject < P > > ,
177175{
178176 #[ inline]
179177 fn as_mut ( & mut self ) -> & mut ProtocolObject < T > {
180178 ProtocolObject :: from_mut ( self )
181179 }
182180}
183181
184- // TODO: Maybe iplement Borrow + BorrowMut?
182+ // TODO: Maybe implement Borrow + BorrowMut?
185183
186184#[ cfg( test) ]
187185#[ allow( clippy:: missing_safety_doc) ]
@@ -194,7 +192,9 @@ mod tests {
194192 use super :: * ;
195193 use crate :: mutability:: Mutable ;
196194 use crate :: runtime:: { NSObject , NSObjectProtocol } ;
197- use crate :: { declare_class, extern_methods, extern_protocol, ClassType , DeclaredClass } ;
195+ use crate :: {
196+ declare_class, extern_methods, extern_protocol, ClassType , DeclaredClass , ProtocolType ,
197+ } ;
198198
199199 extern_protocol ! (
200200 unsafe trait Foo {
0 commit comments