I would like to do something like this:
enum TestEnum {
case all
case some(_ testElements: Set<TestElement>)
}
public protocol TestElement: Hashable {
var identifier: String { get }
}
But I get this error:
Protocol 'TestElement' as a type cannot conform to 'Hashable'
What could I do? Thank you for your help
I am not exactly sure what do you want to use the TestEnum for, but I suggest rewriting it with using one additional element which would be instance of TestClass, so you can conform to TestEnum.some . Here is the code:
There is also an easier and more elegant solution, which is using TestElement as a struct, instead of protocol. I would prersonally recommend this approach. Here is the code: