What you are looking for is
(which, in turn, is part of the "manifest manifest" ). The proposal was accepted for Swift 4, but not yet implemented. From the offer:
Conditional mappings express the idea that a generic type will conform to a particular protocol only when its type arguments satisfy certain requirements.
and a prime example is
extension Array: Equatable where Element: Equatable { static func ==(lhs: Array<Element>, rhs: Array<Element>) -> Bool { ... } }
make uniform arrays of equivalent elements, which is impossible at the moment. Your example essentially
struct SomeWrapper<Wrapped> { let wrapped: Wrapped } extension SomeWrapper: Equatable where Wrapped: Equatable { static func ==(lhs: SomeWrapper<Wrapped>, rhs: SomeWrapper<Wrapper>) -> Bool { return lhs.wrapped == rhs.wrapped } }
from this sentence.
source share