-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add safe upcasting #518
Comments
The trait |
Also valuable from |
Tried implementing Perhaps an inherent method on |
Some sort of extern_category!(
unsafe trait MyCategory { ... }
unsafe impl<T: SubclassOf<MyType>> MyCategory for T {}
); Which would make it such that all subclasses of a given type |
Would also like to figure out how |
We already have the ability to convert from
NSView
to its superclassesNSResponder
usingDeref
,ClassType::as_super
orId::into_super
. In general, we should maybe consider anUpCast
trait of some sort, to be able to do this fully generically? Even better if it could integrate with aFrom
implementation forId
.It'd also be nice to have similar conversions from
NSArray<NSView>
toNSArray<NSResponder>
.Note that this is only valid for
__covariant
generic types, e.g.NSArray
, but notNSMutableArray
(see also this video from WWDC2015, timestamp around 23:40).See also the inverse of this in #474.
The text was updated successfully, but these errors were encountered: