Skip to content

Instantly share code, notes, and snippets.

@BigZaphod
Last active November 1, 2019 20:34
Show Gist options
  • Save BigZaphod/ab3f86c582ff7358b9fc74f51a6f06f7 to your computer and use it in GitHub Desktop.
Save BigZaphod/ab3f86c582ff7358b9fc74f51a6f06f7 to your computer and use it in GitHub Desktop.
protocol ReferenceEquatable: AnyObject, Equatable {}
extension ReferenceEquatable {
static func == (lhs: Self, rhs: Self) -> Bool {
return lhs === rhs
}
}
protocol ReferenceHashable: ReferenceEquatable, Hashable {}
extension ReferenceHashable {
func hash(into hasher: inout Hasher) {
ObjectIdentifier(self).hash(into: &hasher)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment