Skip to content

Upcasting generic collections #654

@madsmtm

Description

@madsmtm

It'd be nice to have conversions to superclasses in collection types that use lightweight generics, i.e. some way to turn NSArray<NSView> into NSArray<NSResponder>, or even NSArray<NSObject>.

Note that this is only valid for __covariant immutable generic types, e.g. NSArray, but not NSMutableArray (see also this video from WWDC2015, timestamp around 23:40).

Related to #518 and might require a trait like in #271.

Also desirable: Some unsafe way to cast only the generics, e.g. NSArray<T>::cast_objects_unchecked<U>(self) -> NSArray<U>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frameworkAffects the framework crates and the translator for themenhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions