this is really stupid:
extension Codelink
{
enum Keyword:String
{
case actor
case `associatedtype`
case `case`
case `class`
case `enum`
case `func`
case `import`
case macro
case `protocol`
case `static`
case `struct`
case `typealias`
case `var`
}
}
extension Codelink.Keyword
{
init?(rawValue string:Substring)
{
switch string
{
case "actor": self = .actor
case "associatedtype": self = .associatedtype
case "case": self = .case
case "class": self = .class
case "enum": self = .enum
case "func": self = .func
case "import": self = .import
case "macro": self = .macro
case "protocol": self = .protocol
case "static": self = .static
case "struct": self = .struct
case "typealias": self = .typealias
case "var": self = .var
case _: return nil
}
}
}
one way to work around the issue is to make the RawValue
type Substring
and not String
. but that messes with a lot of things that expect a RawRepresentable<String>
conformance.
any better ways to avoid parroting the enum cases?