Ich habe den folgenden Code:Mit Protokoll generische Funktion und 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()
}
}
Nun ist das Problem in der Something
Implementierung von next
. Ich möchte Something<U>
anstelle von Something<Value>
zurückgeben.
Aber wenn ich das tue, habe ich den folgenden Fehler.
type 'Something<Value>' does not conform to protocol 'NextType'
protocol requires nested type 'Value'