Ideal implementation would have hash and == inside parseEnum, but mixin stops working in this way. Looks like yet another bug

import tables
import hashes
import strutils

proc genTableForEnum[T: enum](): Table[string, T] =
  result = initTable[string, T](rightSize(ord(high(T)) - ord(low(T)) + 1))
  for i in items(T):
    # TODO: ignore holes
    result[$i] = i

proc hash(s: string): Hash {.inline.} =
  hashIgnoreStyle(s)

proc `==`(s1, s2: string): bool {.inline.} =
  cmpIgnoreStyle(s1, s2) == 0

proc parseEnum*[T: enum](s: string): T =
  const enumTable = genTableForEnum[T]()
  enumTable[s]

2017-05-14 20:50:46
Araq, could you please opine on this one? 2017-05-14 20:52:28
<<<••12••>>>