[swift-users] How to add this generic static func as a protocol requirement?

Jens Persson jens at bitcycle.com
Fri Jul 7 03:40:23 CDT 2017


protocol P {
    // …
    // For example the following will not work:
    // static func foo<T, R>(_ v: T) -> R
    // Is there some other way?
    // …
}
struct S2 : P {
    static func foo<T>(_ v: T) -> (T, T) {
        return (v, v)
    }
}
struct S3 : P {
    static func foo<T>(_ v: T) -> (T, T, T) {
        return (v, v, v)
    }
}

(I'm guessing but am not sure that I've run into (yet) a(nother) situation
which would require higher kinded types?)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170707/0e4c4496/attachment.html>


More information about the swift-users mailing list