[swift-evolution] [Draft] Allow multiple conformances to the same protocol

Антон Жилин antonyzhilin at gmail.com
Wed Jun 8 14:07:12 CDT 2016


==Motivation==

protocol From {
    associatedtype FromType
    init(_ value: FromType)
}

The problem is, one type cannot implement multiple From "conversions".

==Proposed solution==

Allow specifying all associated types using generic syntax.

extension Int : From<Float> { }
extension Int : From<Double> { }

This is only allowed in conformance declarations.

==Future directions==

We can replace all *Convertible protocols with From and Into, which will be
defined similarly to Rust.

- Anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160608/ff35e595/attachment.html>


More information about the swift-evolution mailing list