Best way to describe this is via a simple example:
protocol Section {
typealias K
typealias T
var key:K {get}
var items: [T] { get}
}
protocol Container {
typealias T
typealias S: Section
typealias K: Equatable
var sections:[S] { get } //<== not precise!
func newSection<S:Section where S.T == T, S.K == K>(key:K, items:[T]) -> S //yes that is what we want
}What we want is to declare a section property that express the same constraint like in the newSection() function... Is this currently possible?
p.s. if we create a generic type (not protocol) like below, it worked, but we really wanted to keep this property as protcol if possible:
struct SectionStruct<K,T>:Section {
var key:K
var items: [T]
}
protocol Container {
typealias T
typealias S: Section
typealias K: Equatable
var sections:[SectionStruct<K,T>] { get }
}