I'm going to ask this question again, because I still don't think it makes any sense.
Take the following example.
protocol MyItem: Identifiable {
var id: Int { get }
}
let items: [MyItem] = [] // can only be used as a generic constraint...
A solution is available, though, as below.
protocol MyItemProtocol {
var id: Int { get }
}
protocol MyItem: MyItemProtocol, Identifiable { }
let myItems: [MyItemProtocol] = []
The above works, but it seems arbitrary unnecessary to create another protocol to achieve this.
The type has been made concrete by the fact that ID
has been specified as Int
in the protocol. You cannot conform to the protocol without having Int
as the type for ID
. So saying it can only be used as a generic constraint makes no sense in my opinion as the type cannot change (as I see it) when the associated type has been specified.