I'm trying to do something like that, but then, ParentC
doesn't conform to Parent
because its children
member isn't Child
but ChildC
Which is weird because ChildC
implements Child
...
Is this a limit of Swift? Or is there is a way of doing that?
(I do not ask for an alternative solution, I want to know if this is possible)
protocol Parent: Codable {
var children: [Child] { get }
}
protocol Child: Codable {
var name: String { get }
}
struct ParentC: Parent {
var children: [ChildC]
}
struct ChildC: Child {
var name: String
}