Yes. That's how things work already, with protocols:
func ƒ(collection: any Collection) -> (Any?, Int) {
(collection.first, collection.count)
}
func ƒ<Collection: Swift.Collection>(collection: Collection) -> (Collection.Element?, Int) {
(collection.first, collection.count)
}
some
and any
would be useful with all generic types—just, unlike with protocols, specifying the "associated type" would not useful, because unlike some/any Protocol<T>
, there's nothing else for that to mean, other than Type<T>
itself.
There hasn't been a lot of discussion yet. You all should start clamoring for it.