Hello everyone,
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.
This is similar to what has been described there:
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001233.html
<https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001233.html>
Is there any updates about it since 2015?
Also, do you think this would be a good idea to make extensions constrainable
by enum types, like that?
extension Type where P1: enum {
}
You could then write something similar to this:
protocol A {
associatedtype P1
associatedtype P2
static var p1PossibleValues:[P1] { get }
static var p2PossibleValues:[P2] { get }
}
extension A where P1: enum, P2: enum {
static var p1PossibleValues:[P1] { return p1PossibleValues.allValues }
static var p2PossibleValues:[P2] { return p2PossibleValues.allValues }
}
Would it make sense to do it this way?
Trevör_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution