我想指定一个类型约束,类型应该是原始值枚举:
enum SomeEnum: Int {
case One, Two, Three
}
class SomeProtocol<E: enum<Int>> { // <- won't compile
func doSomething(e: E) {
compute(e.toRaw())
}
}
Run Code Online (Sandbox Code Playgroud)
我怎么能在Swift中做到这一点?(我以F#语法为例)