What is the best way to make a enum case Typed-signature / interpolation?
enum TestEnum {
case caseWithoutAssociatedValues
case bar2(value: Int)
case baz(val: Int, String)
case baz(val: UInt, bal: (String, ty: Double))
case caseWithAssociatedValues(Int, String, Double)
case caseWithOptionalFunc(func: ((Double, Double) -> Double)?)
case caseWithFuncOptionalReturn(((Double, Double) -> Double?))
case caseWithOptionalFuncOptionalReturn(((Double, Double) -> Double?)?)
}
Expected output:
"caseWithoutAssociatedValues"
"bar2(value: Int)",
"baz(val: Int, String)",
"baz(val: UInt, bal: (String, ty: Double))",
"caseWithAssociatedValues(Int, String, Double)"
"caseWithOptionalFunc(func: Optional<(Double, Double) -> Double>)"
"caseWithFuncOptionalReturn((Double, Double) -> Optional)"
"caseWithOptionalFuncOptionalReturn(Optional<(Double, Double) -> Optional>)")
Currently I use reflection to solve this task. But there is a plan to drop reflection metadata to reduce app binary size as there are no other reasons for reflection metadata.
Another option is to use macros, but this new feature unavailable for older OS versions.
Is there any other options?