objectdollar.nim 310 B

123456789101112
  1. import std/private/miscdollars
  2. proc `$`*[T: object](x: T): string =
  3. ## Generic `$` operator for objects with similar output to
  4. ## `$` for named tuples.
  5. runnableExamples:
  6. type Foo = object
  7. a, b: int
  8. let x = Foo(a: 23, b: 45)
  9. assert $x == "(a: 23, b: 45)"
  10. tupleObjectDollar(result, x)