Alejandro Ciniglio

Hashable and Equatable conformance for classes

If you just want instance comparison in swift, you can use these conformances.

class Foo: Hashable, Equatable, ObservableObject {
    static func == (lhs: Foo, rhs: Foo) -> Bool {
        lhs === rhs
    }
    
    func hash(into hasher: inout Hasher) {
        hasher.combine(ObjectIdentifier(self))
    }
}