Is there a way to make custom protocols be propagative like standard Hashable, Equatable, Codable and so on i.e. when all properties of a struct/class conform to the protocol then the struct/class itself can conform to that protocol.
Say I have a simple protocol like this:
protocol State {
init()
}
Suppose I have two structs:
struct State1: State {}
struct State2: State {}
They conform to the protocol, then I want to have another struct conforming to my protocol like this:
struct AppState: State { // error: Type 'AppState' does not conform to protocol 'State'
let state1: State1
let state2: State2
}
In theory if all properties has an empty init() then it should be no problem implicitly implementing init in the AppState struct. But the compiler only understand an explicit init() in AppState. So is there a way to enhance my protocol State to have that feature?