You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a future where the macros sandbox allows for reading from files, users could simplify this code:
import EnumeratorMacro
@Enumerator("""enum Subtype: String { {{#cases}} case {{name}} {{/cases}}}""","""var subtype: Subtype { switch self { {{#cases}} case .{{name}}: .{{name}} {{/cases}} }}""")enumTestEnum{case a(val1:String, val2:Int)case b
case testCase(testValue:String)}
to:
import EnumeratorMacro
import EnumeratorMacroImpl
@attached(member, names: arbitrary)
macro CreateSubtype()= #externalMacro(
module:"EnumeratorMacroImpl",
type:"EnumeratorMacroType")@CreateSubtypeenumTestEnum{case a(val1:String, val2:Int)case b
case testCase(testValue:String)}
And for all the next enums, you only need to use @CreateSubtype instead of writing the whole template.
How this'll work is that it'll try to read a template file which will be expected to be located at a pre-defined place like /PROJECT_ROOT/macro-templates/CreateSubtype.mustache.
The text was updated successfully, but these errors were encountered:
In a future where the macros sandbox allows for reading from files, users could simplify this code:
to:
And for all the next enums, you only need to use
@CreateSubtype
instead of writing the whole template.How this'll work is that it'll try to read a template file which will be expected to be located at a pre-defined place like
/PROJECT_ROOT/macro-templates/CreateSubtype.mustache
.The text was updated successfully, but these errors were encountered: