I've been working on this very thing for a while :)<br><br>Proposal PR: <a href="https://github.com/apple/swift-evolution/pull/706">https://github.com/apple/swift-evolution/pull/706</a><br><br>Implementation PR: <a href="https://github.com/apple/swift/pull/9619">https://github.com/apple/swift/pull/9619</a><br><br>I was really hoping to get it into Swift 4 but the deadline is fast approaching, he proposal hasn't been officially reviewed yet (there's a thread on this list from a few weeks ago where we hashed out a couple drafts), and the implementation, based on the smoke test, seems to have a strange issue that only occurs on Linux (assuming it's not unrelated) that I haven't been able to track down yet.<br><div class="gmail_quote"><div dir="ltr">On Fri, May 26, 2017 at 9:10 AM Logan Shire via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Given we now have precedent in the form of the derived Codable conformance coming in Swift 4.0,<br>
it begs the question why we don’t offer the same behavior for value types that declare themselves to be Equatable<br>
and have all Equatable properties. E.g.<br>
<br>
struct A: Equatable {<br>
let foo: String<br>
let bar: Int<br>
}<br>
<br>
struct B: Equatable {<br>
let baz: Double<br>
}<br>
<br>
struct C: Equatable {<br>
let a: A<br>
let b: B<br>
}<br>
<br>
let a = A(foo: “hello”, bar: 1)<br>
let a2 = A(foo: “hello”, bar: 2)<br>
a == a2 // false<br>
let b = B(baz: 3.1)<br>
let c = C(a: a, b: b)<br>
le c2 = C(a: a2, b: b)<br>
c == c2 // false<br>
<br>
You would always be free to shadow the provided implementation:<br>
<br>
extension A {<br>
func ==(lhs: A, rhs: A) {<br>
return lhs.foo == rhs.foo<br>
}<br>
}<br>
<br>
a == a2 // true<br>
<br>
It’s up for debate whether this should apply to reference types, or Hashable, but at a bare minimum we should<br>
offer it for value types consisting of Equatable value types that explicitly declare but don’t implement the conformance.<br>
<br>
Thanks!<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>