summary refs log tree commit diff stats
path: root/lib/std/objectdollar.nim
blob: 86ce9afc8200363969092f4f1a5f4639d658b458 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
## This module implements a generic `$` operator to convert objects to strings.

import std/private/miscdollars

proc `$`*[T: object](x: T): string =
  ## Generic `$` operator for objects with similar output to
  ## `$` for named tuples.
  runnableExamples:
    type Foo = object
      a, b: int
    let x = Foo(a: 23, b: 45)
    assert $x == "(a: 23, b: 45)"
  tupleObjectDollar(result, x)