-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix NSCopying
and NSMutableCopying
#401
Comments
Looking at the conforming types of
Everything else works just like |
An example of using
(Honestly, this behaviour seems more like a bug than the intended behaviour...) |
So in #419 I was considering getting rid of the The places where it is troublesome in the first place is in usage of
In all of these cases, the protocol is being used to do polymorphism, but we know that the type of Maybe having these as subtraits of The other troublesome cases are when
Having just a bound of |
Actually, the trait AllowedKeyKinds {}
impl AllowedKeyKinds for Immutable {}
impl AllowedKeyKinds for ImmutableWithMutableSubclass {}
trait AllowedKeys {}
impl<T: PartialEq + Hash + ClassType> AllowedKey for T
where
Self::Kind: AllowedKeyKinds,
{}
impl<K: AllowedKey, V: ...> for NSMutableDictionary<K, V> {
pub fn insert(key: &impl NSCopying<Output = K>, val: Id<V>);
} This would allow passing |
Okay, back to basics:
I think the answer to these is:
|
Perhaps a solution could be something like: // Implementation
extern_protocol!(
pub unsafe trait NSCopying { ... }
unsafe impl<T> ProtocolType for dyn NSCopying<Output = T> { ... }
);
// Type usage
ProtocolObject<dyn NSCopying<Output = DummySelf>> (Or some kind of equivalent that still ensures you can't suddenly turn a |
Or for solution 1c, perhaps we could have classkinds |
In #293 / #291, I changed protocols to work like traits.
However,
NSCopying
andNSMutableCopying
are still special-cased since they work a bit differently, they require the user to specify the output type and ownership. How can we makeicrate
do that for us? And what about protocols that "inherit" from these two (likeDOMEventTarget
)?Perhaps this ties in with #399 somewhat?
In any case, I need to get a better understanding and research which types actually implement these two protocols, and just as importantly, which ones don't!
The text was updated successfully, but these errors were encountered: