This is something additional, but I’m curios about how the community feels 
about it.

I recently come across the issue where conforming to Hashable wasn’t enough to 
thecke if two instances of the same generic type were equal.

I had additionally provide myself the != function.

public func !=<T, U>(lhs: SomeTypeName<T>, rhs: SomeTypeName<U>) -> Bool {
    return lhs.hashValue != rhs.hashValue
}
I wondered if Swift can ever get generic specialization like this:

public func !=<T : Hashable, U, V>(lhs: T<U>, rhs: T<V>) -> Bool {
    return !(lhs.hashValue == rhs.hashValue)
}
This function in stdlib would fill the gap. Or we need an extra protocol 
GenericHashable which includes !=.



-- 
Adrian Zubarev
Sent with Airmail
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to