I had a need to hold a reference to any string enum, no matter where it was declared.
Here is my solution :
public protocol StringEnumType : Hashable & RawRepresentable where Self.RawValue == String { }
This is then attached to an enum. e.g. :
public enum CellIdentifier : String, StringEnumType
{
case value
case summary
}
… or you can add it in an extension :
extension CellIdentifier : StringEnumType { }
Of course, due to PAT restrictions, this has to be used to qualify a generic parameter type but, it does then allow me to declare a method (or other generic type) that will work with a string-based enum, without knowing what the concrete enum type will be.
Now, tell me that "everybody" already knows this