<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">If an extension on your type declares a hashValue property, what should be the semantics? Is that an error (conflicts with default provided one), or is that one used?</div><br class=""><div><blockquote type="cite" class=""><div class="">On May 4, 2017, at 3:20 PM, Andrew Bennett via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">That's correct, consistent with&nbsp;<span style="font-size:12.800000190734863px" class="">Encoding/Decoding (</span><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0166-swift-archival-serialization.md" class="">SE-0166</a><span style="font-size:12.800000190734863px" class="">) it is sufficient to just do this:</span><div class=""><span style="font-size:12.800000190734863px" class=""><br class=""></span></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">struct</span><span style="font-variant-ligatures:no-common-ligatures" class=""> MyType: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">Hashable</span><span style="font-variant-ligatures:no-common-ligatures" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">var</span><span style="font-variant-ligatures:no-common-ligatures" class=""> foo: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">Int</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(4,51,255)" class="">var</span><span style="font-variant-ligatures:no-common-ligatures" class=""> bar: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)" class="">Float</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div>Now&nbsp;<span style="font-family: menlo; font-size: 11px;" class="">MyType</span>&nbsp;should get a generated implementation because each member is also Hashable.<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div>There's more details in the proposal near:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">An enum T that derives Equatable will receive a compiler-generated implementation of</blockquote><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, May 5, 2017 at 8:15 AM, Xiaodi Wu <span dir="ltr" class="">&lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">I'm imagining no syntax; effectively, as though there exists an "extension Equatable where [ all members : Equatable ]" with a default implementation.</div><div class=""><br class=""></div><div class=""><br class=""><div class="gmail_quote"><div class="">On Thu, May 4, 2017 at 17:13 John McCall &lt;<a href="mailto:rjmccall@apple.com" target="_blank" class="">rjmccall@apple.com</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><blockquote type="cite" class=""><div class="">On May 4, 2017, at 6:10 PM, Andrew Bennett via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><div class=""><div class="">I agree, let's make it opt-in.<div class=""><br class=""></div><div class="">This looks really great, I'm excited to get generated conformance for Equatable/Hashable in time for Swift 4.</div><div class=""><br class=""></div><div class="">I think it's worth mentioning that Encoding/Decoding generated conformance is already accepted and implemented in Swift 4. The implementation and acceptance criterion for Equatable/Hashable is likely to be very similar.</div><div class=""><br class=""></div><div class=""><b class="">For the open questions</b>, I think for the sake of getting this into Swift 4 we should go for explicit derivation, and don't allow omission of fields (yet).</div></div></div></blockquote><div class=""><br class=""></div></div></div><div style="word-wrap:break-word" class=""><div class="">Is there a syntax proposal for explicit derivation?&nbsp; Or are you imagining that just declaring the conformance but failing to implement it should trigger derivation?</div></div><div style="word-wrap:break-word" class=""><div class=""><br class=""></div><div class="">John.</div></div><div style="word-wrap:break-word" class=""><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div class=""><br class=""></div><div class="">Omission is nice-to-have, but likely to be a long-winded bike-shed.</div><div class=""><br class=""></div><div class="">Changing from explicit to implicit is a loss of information, and has a large impact on the language, it can't easily be undone, so it requires a large discussion when it's decided. It only adds a little additional convenience to the user though.</div><div class=""><br class=""></div><div class="">I suggest we discuss implicit generation and allowing omission with follow-up proposals, they&nbsp;will very likely be additive non-breaking changes. For this proposal we play it safe and stick to explicit conformance and no omission of fields.</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, May 5, 2017 at 8:01 AM, Xiaodi Wu via swift-evolution <span class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hmm, I can see the appeal of automatically deriving Equatable and Hashable conformance, but I'd like that to be opt-in. That is, types should declare that they are Equatable or Hashable to begin with. It wouldn't have to take extra syntax, as compiler magic could effectively synthesize default implementations for == and/or hashValue when all members are themselves Equatable or Hashable, respectively. With such a scheme, consideration can be made to accommodating classes too.<br class=""><div class="gmail_quote"><div class="">On Thu, May 4, 2017 at 15:37 Tony Allevato via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><div class="">Hi all,</div><div class=""><br class=""></div>A conversation on Twitter last night brought up some interest in this feature and I was encouraged to revive this proposal.<div class=""><br class=""></div><div class="">Jordan Rose <a href="https://twitter.com/UINT_MIN/status/859922619578986496" target="_blank" class="">mentioned</a> on Twitter that it could possibly make it in by the Swift 4 deadline if others contributed—I have a WIP branch (albeit not currently working because I rebased after a couple months of it being idle) that does the work for enums but I got stuck on the mutually recursive cases. If this got approved, I'd love to collaborate with other interested folks to finish up the implementation.</div><div class=""><br class=""></div><div class="">Link:&nbsp;<a href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad" target="_blank" class="">https://gist.github.com/<wbr class="">allevato/<wbr class="">2fd10290bfa84accfbe977d8ac07da<wbr class="">ad</a></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><h1 style="box-sizing:border-box;margin:0px 0px 16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class="">Deriving<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:inherit;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Equatable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>and<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:inherit;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Hashabl<wbr class="">e</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>for value types</h1><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class=""><li style="box-sizing:border-box" class="">Proposal:<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><a href="https://github.com/apple/swift-evolution/blob/master/proposals/NNNN-name.md" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank" class="">SE-0000</a></li><li style="box-sizing:border-box;margin-top:0.25em" class="">Author(s):<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><a href="https://github.com/allevato" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank" class="">Tony Allevato</a></li><li style="box-sizing:border-box;margin-top:0.25em" class="">Status:<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><span style="box-sizing:border-box;font-weight:600" class=""><a href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#rationale" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank" class="">Awaiting review</a></span></li><li style="box-sizing:border-box;margin-top:0.25em" class="">Review manager: TBD</li></ul><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class=""><a id="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-introduction" class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#introduction" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Introduction</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">Value types are prevalent throughout the Swift language, and we encourage developers to think in those terms when writing their own types. Frequently, developers have to write large amounts of boilerplate code to support equatability and hashability of value types. This proposal offers a way for the compiler to automatically derive conformance to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Equatable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>and<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Hashable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>to reduce this boilerplate, in a subset of scenarios where generating the correct implementation is known to be possible.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">Swift-evolution thread:<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/8919" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank" class="">Universal Equatability, Hashability, and Comparability</a></p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class=""><a id="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-motivation" class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#motivation" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Motivation</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">Building robust value types in Swift can involve writing significant boilerplate code to support hashability and equatability. Equality is pervasive across many value types, and for each one users must implement the<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">==</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>operator such that it performs a fairly rote memberwise equality test. As an example, an equality test for a struct looks fairly uninteresting:</p><div class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal" class=""><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">struct</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Foo</span>: <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-e" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Equatable</span> </span>{
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">static</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">==</span> (<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">lhs</span></span>: Foo, <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">rhs</span></span>: Foo) <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">-&gt;</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Bool</span> {
    <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> lhs.<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property1</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhs.<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property1</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">&amp;&amp;</span>
           lhs.<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property2</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhs.<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property2</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">&amp;&amp;</span>
           lhs.<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property3</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhs.<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property3</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">&amp;&amp;</span>
           <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">...</span>
  }
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">What's worse is that this operator must be updated if any properties are added, removed, or changed, and since it must be manually written, it's possible to get it wrong, either by omission or typographical error.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">Likewise, hashability is necessary when one wishes to store a value type in a<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Set</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>or use one as a multi-valued<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Dictionary</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>key. Writing high-quality, well-distributed hash functions is not trivial so developers may not put a great deal of thought into them – especially as the number of properties increases – not realizing that their performance could potentially suffer as a result. And as with equality, writing it manually means there is the potential to get it wrong.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">In particular, the code that must be written to implement equality for enums is quite verbose:</p><div class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal" class=""><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Token</span>: <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-e" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Equatable</span> </span>{
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">string</span>(<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>)
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">number</span>(<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>)
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">lparen</span>
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">rparen</span>
  
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">static</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">==</span> (<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">lhs</span></span>: Token, <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">rhs</span></span>: Token) <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">-&gt;</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Bool</span> {
    <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">switch</span> (lhs, rhs) {
    <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> (.<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">string</span>(<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> lhsString), .<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">string</span>(<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> rhsString))<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> lhsString <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhsString
    <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> (.<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">number</span>(<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> lhsNumber), .<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">number</span>(<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> lhsNumber))<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> lhsNumber <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhsNumber
    <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> (.<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">lparen</span>, .<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">lparen</span>), (.<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">rparen</span>, .<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">rparen</span>)<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">true</span>
    <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">default</span><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">false</span>
    }
  }
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">Crafting a high-quality hash function for this enum would be similarly inconvenient to write.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">Swift already derives<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Equatable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>and<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Hashable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"><wbr class="">&nbsp;</span>conformance for a small subset of enums: those for which the cases have no associated values (including enums with raw types). Two instances of such an enum are equal if they are the same case, and an instance's hash value is its ordinal:</p><div class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal" class=""><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Foo</span>  {
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">zero</span>, <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">one</span>, <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">two</span>
}

<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> x <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> (Foo.<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">one</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> Foo.<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">two</span>)  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c" style="box-sizing:border-box">//</span> evaluates to false</span>
<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> y <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> Foo.<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">one</span>.<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">hashValue</span>     <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c" style="box-sizing:border-box">//</span> evaluates to 1</span></pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">Likewise, conformance to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">RawRepresentable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>is automatically derived for enums with a raw type. Since there is precedent for derived conformances in Swift, we propose extending this support to more value types.</p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class=""><a id="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-proposed-solution" class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#proposed-solution" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Proposed solution</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">In general, we propose that value types derive conformance to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Equatable</code>/<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Hashable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>if all of its members are<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Equatable</code>/<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Hashable</code>. We describe the specific conditions under which these conformances are derived below, followed by the details of how the conformance requirements are implemented.</p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class=""><a id="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-protocol-derivability-conditions" class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#protocol-derivability-conditions" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Protocol derivability conditions</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">For brevity, let<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>represent either the protocol<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Equatable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>or<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Hashable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"><wbr class="">&nbsp;</span>in the descriptions below.</p><h4 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:16px;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class=""><a id="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-derived-conformances-for-enums" class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#derived-conformances-for-enums" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Derived conformances for<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:inherit;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">enum</code>s</h4><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">For an<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">enum</code>, derivability of<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>is based on the conformances of its cases' associated values. Computed properties are not considered.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">The following rules determine whether conformance to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>can be derived for an<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">enum</code>:</p><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class=""><li style="box-sizing:border-box" class=""><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px" class="">An<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">enum</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>with no cases does not derive conformance to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code>, since it is not possible to create instances of such types.</p></li><li style="box-sizing:border-box;margin-top:0.25em" class=""><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px" class="">An<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">enum</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>with one or more cases derives conformance to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>if all of the associated values of all of its cases conform to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>(either explicitly or derived).</p></li></ul><h4 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:16px;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class=""><a id="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-derived-conformances-for-structs" class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#derived-conformances-for-structs" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Derived conformances for<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:inherit;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">struct</code>s</h4><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">For a<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">struct</code>, derivability of<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>is based on the conformances of its stored instance properties<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><em style="box-sizing:border-box" class="">only</em>. Neither static properties nor computed instance properties (those with custom getters) are considered.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">The following rules determine whether conformance to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>can be derived for a<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">struct</code>:</p><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class=""><li style="box-sizing:border-box" class=""><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px" class="">A<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">struct</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>with<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><em style="box-sizing:border-box" class="">no</em><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>stored properties does<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><em style="box-sizing:border-box" class="">not</em><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>derive conformance to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code>. (Even though it is vacuously true that all instances of a<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">struct</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>with no stored properties could be considered equal and hash to the same value, the reality is that such<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">struct</code>s are more often used for grouping/nesting of other entities and not for their singular value, and we don't consider it worthwhile to generate extra code in this case.)</p></li><li style="box-sizing:border-box;margin-top:0.25em" class=""><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px" class="">A<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">struct</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>with one or more stored properties derives conformance to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>if all if the types of all of its stored properties conform to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>(either explicitly or derived).</p></li></ul><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class=""><a id="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-considerations-for-recursive-types" class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#considerations-for-recursive-types" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Considerations for recursive types</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">For brevity in the discussion below, the term<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><em style="box-sizing:border-box" class="">members</em><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>refers only to those members that are checked for deriving conformances:<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><em style="box-sizing:border-box" class="">stored properties</em><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>for<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">struct</code>s and<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><em style="box-sizing:border-box" class="">associated values</em><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>for<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">enum</code>s.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">Recursive value types require a bit more care when determining whether a conformance can be derived. Consider the following<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">enum</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>with an<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">indirect</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>case:</p><div class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal" class=""><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">TreeNode</span> {
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">empty</span>
 &nbsp;<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">leaf</span>(<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">value</span></span>: <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>)
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">internal</span>(<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">left</span></span>: TreeNode, <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">right</span></span>: TreeNode)
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">When examining the<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">internal</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>case, an application of the rules above implies that "<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">TreeNode</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>derives<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>if<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">TreeNod<wbr class="">e</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>conforms to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code>"—a recursive condition. In this situation, we note that any instance of this type—or of any recursive type—forms a finite tree structure because the recursion must be terminated eventually by using one of the other base cases. Therefore, without changing the outcome,<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><span style="box-sizing:border-box;font-weight:600" class="">we can assume for the purposes of determining whether<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">T</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>derives<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>that any members of type<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">T</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>already conform to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code>.</span><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>If any members of different types prohibit deriving<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code>, then we know that the whole type cannot derive it; likewise, if all of the other members permit deriving<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code>, then we know that<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">T</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>can derive it by recursively applying the derived operation.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">This property can be extended to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><em style="box-sizing:border-box" class="">mutually</em><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>recursive types as well. Consider this contrived example:</p><div class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal" class=""><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">A</span> {
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">value</span>(<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>)
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">b</span>(B)
}

<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">B</span> {
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">value</span>(<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>)
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">c</span>(C)
}

<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">C</span> {
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">value</span>(<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Double</span>)
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">a</span>(A)
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">The rules state that—ignoring the trivial cases—"<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">A</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>derives<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>if<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">B</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>confor<wbr class="">ms to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code>," and "<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">B</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>derives<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>if<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">C</code>conforms to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code>," and "<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">C</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>derives<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>if<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">A</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>conforms to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code>." The same observation about recursion and the finiteness of instances from above holds here, so we can generalize the rule above as follows:</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class=""><span style="box-sizing:border-box;font-weight:600" class="">A type<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">T</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>can derive<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>if all members of<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">T</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>conform to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>or are of types found in cycles that lead back to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">T</code>such that the members of those other types along the cycle also all conform to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">P</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>or are themselves along such a cycle.</span></p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class=""><a id="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-other-considerations" class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#other-considerations" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Other considerations</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">When conditional conformances are supported in Swift, generic types should conditionally derive<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Equatable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>and<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Hashable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><wbr class="">for type argument substitutions where the rules above are satisfied.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">A notable side effect of this is that<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Optional&lt;Wrapped&gt;</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>would derive<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Equatable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>and<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Hashable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><wbr class="">conformance when<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Wrapped</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>conforms to those protocols, because it is an<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">enum</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>that would satisfy the rules described above. Its implementation would not need to be in the standard library (but there is also nothing preventing it from being there).</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">Conditional conformances will also significantly improve derivability coverage over other payload/member types. For example, consider a<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">struct</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>containing a stored property that is an array of<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Equatable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>types:</p><div class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal" class=""><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">struct</span> <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Foo</span> {
  <span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> values<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> [<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>]
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">Today,<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Array&lt;String&gt;</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>does not conform to<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Equatable</code>, so its presence would prohibit<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Foo</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>from deriving<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Equatable</code>. However, once Swift can express the conformance<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Array&lt;Element&gt;: Equatable where Element: Equatable</code>,<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Foo</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>would automatically derive<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Equatable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>as well. This makes derived conformances significantly more powerful.</p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class=""><a id="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-implementation-details" class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#implementation-details" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Implementation details</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">An<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">enum T</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>that derives<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Equatable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>will receive a compiler-generated implementation of<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">static == (lhs: T, rhs: T) -&gt; Bool</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>that returns<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">true</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>if and only if<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">lhs</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>and<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">rhs</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>are the same case and have payloads that are memberwise-equal.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">An<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">enum T</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>that derives<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Hashable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>will receive a compiler-generated implementation of<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">var hashValue: Int { get }</code>that uses an unspecified hash function<span style="box-sizing:border-box;font-size:12px;line-height:0;vertical-align:baseline" class="">†</span><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>to compute the hash value by incorporating the case's ordinal (i.e., definition order) followed by the hash values of its associated values as its terms, also in definition order.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">A<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">struct T</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>that derives<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Equatable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>will receive a compiler-generated implementation of<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">static == (lhs: T, rhs: T) -&gt; Bool</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>that returns<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">true</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>if and only if<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">lhs.x == rhs.x</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>for all stored properties in<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">T</code>.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">A<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">struct T</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>that derives<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">Hashable</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>will receive a compiler-generated implementation of<span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">var hashValue: Int { get }</code><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>that uses an unspecified hash function<span style="box-sizing:border-box;font-size:12px;line-height:0;vertical-align:baseline" class="">†</span><span class="m_6227900310735958705m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space">&nbsp;</span>to compute the hash value by incorporating the hash values of the fields as its terms, in definition order.</p><div style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, system-ui, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;" class=""><br class="webkit-block-placeholder"></div></div></div></blockquote></div></blockquote></div></div></div></blockquote></div></div></blockquote></div></div>
</blockquote></div><br class=""></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>