tgenericconverter.nim 353 B

12345678910111213141516171819202122232425262728293031
  1. discard """
  2. output: '''666
  3. 666'''
  4. """
  5. # test the new generic converters:
  6. type
  7. TFoo2[T] = object
  8. x: T
  9. TFoo[T] = object
  10. data: array[0..100, T]
  11. converter toFoo[T](a: TFoo2[T]): TFoo[T] =
  12. result.data[0] = a.x
  13. proc p(a: TFoo[int]) =
  14. echo a.data[0]
  15. proc q[T](a: TFoo[T]) =
  16. echo a.data[0]
  17. var
  18. aa: TFoo2[int]
  19. aa.x = 666
  20. p aa
  21. q aa