objectdollar.nim 391 B

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