定义一个使用不同关联值返回自身的协议

时间:2016-07-23 21:07:17

标签: swift

我想实现以下内容:

struct Implementation1<Value>: Protocol1 {

    let v: Value

    func test<Next : Protocol1>(next: Next) -> Implementation1<Next.Value> {
    }
}

如何定义Protocol,以便在测试函数中我可以告诉它将Self专门返回Next.Value

我的尝试是

protocol Protocol1 {
    associatedtype Value

    var v: Value { get }

    func test<Next: Protocol1>(next: Next) -> Self<Value>
}

但当然这不起作用,因为我们不能专注于自我。

0 个答案:

没有答案
相关问题