[swift-users] Using ... as a concrete type conforming to protocol ... is not supported

Jason Sadler jason.sadler at gmail.com
Fri Apr 1 13:36:48 CDT 2016


It turns out you can use an equality type constraint instead of a conformance type constraint:

extension CollectionType where Generator.Element == AnyEquatable {
    func indexOf(element : AnyEquatable) -> Index? {
        return indexOf({ (currentElement : Generator.Element ) -> Bool in
            element.equals(currentElement)
        })
    }
}

Discussion is ongoing at swift-evolution: https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160328/013922.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160401/648d9f38/attachment.html>


More information about the swift-users mailing list