1
我有下面的代码:协议具有通用功能和associatedType
protocol NextType {
associatedtype Value
associatedtype NextResult
var value: Value? { get }
func next<U>(param: U) -> NextResult
}
struct Something<Value>: NextType {
var value: Value?
func next<U>(param: U) -> Something<Value> {
return Something()
}
}
现在的问题是在Something
实施next
。我想返回Something<U>
而不是Something<Value>
。
但是当我这样做时,我得到了以下错误。
type 'Something<Value>' does not conform to protocol 'NextType'
protocol requires nested type 'Value'