[swift-evolution] [Idea] Typealias for protocols with associated types

Eugene Gubin hemet.mail at gmail.com
Thu Feb 4 11:24:00 CST 2016


Currently protocols with associated types could not be used as types. One
could use type-erased wrappers (e.g. AnyGenerator,
AnyRandomAccessCollection etc.) but writing these produce a lot of
boilerplate code. I think it would be convenient to use something like this:

class MyClass {
    typealias IntCollection = CollectionType where
CollectionType.Generator.Element == Int

    var collection: IntCollection
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160204/264ec9b3/attachment.html>


More information about the swift-evolution mailing list