YiJiang
(蒋艺)
1
protocol MyProtocol {
func foo()
func bar()
}
struct MyStruct1: MyProtocol {
func foo() { }
func bar() { }
}
struct MyStruct2: MyProtocol {
func foo() { }
func bar() { }
}
enum StructHolder: MyProtocol {
case first(MyStruct1)
case second(MyStruct2)
}
has anyone write a macro that automatically conform StructHolder to MyProtocol?
From my understanding, in embedded swift, I can't use let array: [any MyProtocol] so I want to use let array: [StructHolder]. But this way I have to repeat all methods with a switch case pattern.