Access denied, Please sign in and make sure you have proper permission.
这能看吗?
并不是奇怪 只是觉得复杂头都绕晕了,为了设计标准库的容器协议,会写出这么复杂的 constrain,好吧这肯定是有水平的,但我如果写完类似的代码我是崩溃的,至少头脑里会报警,会想是不是走上了歧途。
这是文档的锅,主要是这里有一个递归的声明 SubSequence.SubSequence == SubSequence
,所以文档生成器才被绕进去了,实际声明的代码其实很简单:
// https://github.com/apple/swift/blob/master/stdlib/public/core/Collection.swift
protocol Collection: Sequence {
override associatedtype Element
associatedtype Index: Comparable
associatedtype SubSequence: Collection where SubSequence.Index == Index,
Element == SubSequence.Element,
SubSequence.SubSequence == SubSequence
...
}
Swift 本身还是不错的,槽点不多,苹果的文档确实太坑爹。