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'