The general constraint syntax where T == Usays that the type Tmust be of the same type as the type U.
First make a simpler example:
protocol GenericProtocol {
associatedtype T
associatedtype U
}
extension GenericProtocol where T == U {
func foo() {}
}
class ConcreteClassA: GenericProtocol {
typealias T = Int
typealias U = Float
}
class ConcreteClassB: GenericProtocol {
typealias T = Int
typealias U = Int
}
let a = ConcreteClassA()
let b = ConcreteClassB()
Now which one, aor bhas a member foo? The answer b.
Since the total expansion limit adds that T, and Ushould be of the same type, the extension applies only to ConcreteClassB, because it Tand Uare Int.
Get back to your code now.
, Indices.Iterator.Element , Index. , .
Indices - Indices. , Indices.Iterator.Element - . Index , , . , . , . . .
, :
indices.contains(index)