我有以下3种协议。
protocol OperationProtocol {
associatedtype Parameter1
associatedtype Parameter2
}
protocol Protocol1 {
associatedtype Type1
}
protocol Protocol2: Protocol1 {
associatedtype Operation: OperationProtocol
}
现在,在Protocol2声明中,我想约束Operation.Parameter1 = Type1
我尝试过像下面这样的where子句,但是我失败了。
protocol Protocol2: Protocol1 {
associatedtype Operation: OperationProtocol where Operation.Parameter1 = Self.Type1
}
答案 0 :(得分:1)
我在发布问题后不到5分钟就设法回答了:) 这是答案:
protocol Protocol2: Protocol1 {
associatedtype Operation: OperationProtocol
associatedtype Type1 = Operation.Parameter1
}