I have a protocol with associated type. I want the protocol to impose some method only if the associated type conforms to Equatable.
Something like this:
public protocol ListOfThings {
associatedtype ThingType
func append(_ thing: ThingType)
// This function makes sense only if ThingType is equatable
func remove(_ thing: ThingType) where ThingType: Equatable
}
I just can't find the right syntax for that.
I also tried with an extension, but the compiler (rightly) claims for the function body.
extension ListOfThings where ThingType: Equatable {
func remove(_ thing: ThingType)
}