If we are willing to accept the possibility of padding bytes giving us a false negative, it is trivially easy to write a function that checks two values of the same type for identicality—identicalness?
extension Equatable {
@inlinable /* @backDeployed etc */
public func isKnownIdentical(to other: Self) -> Bool {
withUnsafeBytes(of: self) { lhs in
withUnsafeBytes(of: other) { rhs in
lhs.elementsEqual(rhs) // or just memcmp
}
}
}
}
Have we definitely ruled out the utility of that option in this thread? It would be at least as correct as a default implementation that always returned false
.