[swift-evolution] [Discussion] Additional generics specialization
Adrian Zubarev
adrian.zubarev at devandartist.com
Mon Jul 18 02:04:08 CDT 2016
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160718/2777b1e1/attachment.html>
More information about the swift-evolution
mailing list