titertypedesc.nim 274 B

123456789101112131415161718
  1. discard """
  2. output: '''0
  3. (id: 0)
  4. @[]
  5. [0, 0, 0]'''
  6. """
  7. iterator foo*(T: typedesc): T =
  8. var x: T
  9. yield x
  10. for a in foo(int): echo a
  11. for b in foo(tuple[id: int]): echo b
  12. for c in foo(seq[int]): echo c
  13. type Generic[T] = T
  14. for d in foo(Generic[array[0..2, int]]): echo d