<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="">Hello everyone,<div class=""><div class=""><br class=""></div><div class="">As I was writing a program, I realised that I could make it safer by being able to list all possible cases of a Swift enum.</div><div class="">This is similar to what has been described there:</div><div class=""><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001233.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001233.html</a></div><div class=""><br class=""></div><div class="">Is there any updates about it since 2015?</div></div><div class=""><br class=""></div><div class="">Also, do you think this would be a good idea to make extensions constrainable by enum types, like that?</div><div class="">extension Type where P1: enum {</div><div class="">}</div><div class=""><br class=""></div><div class="">You could then write something similar to this:</div><div class=""><br class=""></div><div class="">protocol A {</div><div class="">associatedtype P1</div><div class="">associatedtype P2</div><div class="">static var p1PossibleValues:[P1] { get }</div><div class="">static var p2PossibleValues:[P2] { get }</div><div class="">}</div><div class=""><br class=""></div><div class="">extension A where P1: enum, P2: enum {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>static var p1PossibleValues:[P1] { return p1PossibleValues.allValues }</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>static var p2PossibleValues:[P2] { return p2PossibleValues.allValues }</div><div class="">}</div><div class=""><br class=""></div><div class="">Would it make sense to do it this way?</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Trevör</div></body></html>