Chr*_*ler 4 generics ios swift
为什么协议可能会出错?对于任何其他协议,我们都会收到错误
protocol SomeProtocol {
}
struct Test1<T> where T: SomeProtocol {
}
struct Test2<T> where T: Error {
}
let test1: Test1<SomeProtocol> = Test1() ----> Protocol 'SomeProtocol' as a type cannot conform to the protocol itself
let test2: Test2<Error> = Test2() ----> It's Ok
Run Code Online (Sandbox Code Playgroud)