You can declare a generic type corresponding to a type RawRepresentablethat is a protocol that matches all enumerations declaring a primitive rawValue.
enum EnumA: Int {
case A = 0
}
enum EnumB {
case A
}
func doGenericSomething<T: RawRepresentable>(arg: T) {
println(arg.rawValue)
}
doGenericSomething(EnumA.A)
doGenericSomething(EnumB.A)
You cannot, however, specify the type of renaming rawValue in a generic format. For information, you can see the message here .