-
-
Notifications
You must be signed in to change notification settings - Fork 74
Downcasting to protocol objects #845
Copy link
Copy link
Open
Labels
A-objc2Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesAffects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesenhancementNew feature or requestNew feature or request
Description
Metadata
Metadata
Assignees
Labels
A-objc2Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesAffects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesenhancementNew feature or requestNew feature or request
It might be possible to allow converting
AnyObjecttoProtocolObject<dyn NSObjectProtocol>by checking if the object's class conforms to the protocol, something like:One complication is that
ProtocolObject::protocolreturns anOptionbecause of #820, unsure how we should handle that?Option<Option<X>>doesn't seem very nice, but neither does panicking!Might also wanna call it something else? Unsure what this operation is named elsewhere (the standard library doesn't seem to support
dyn Any->dyn MyTrait)?Related to #843.