summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-04-04 13:05:38 +0200
committerAraq <rumpf_a@web.de>2013-04-04 13:05:38 +0200
commitbeb13ecf621f87dea88912c340698459a63f0737 (patch)
treec46e8fe359ff0946c8f26624299c4b227dade0f3 /lib
parent2f826b5305d27a5deb004bc91f52640d89c2f603 (diff)
downloadNim-beb13ecf621f87dea88912c340698459a63f0737.tar.gz
rod file viewer for easier debugging of rod files
Diffstat (limited to 'lib')
-rw-r--r--lib/system.nim12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim
index 08de426c4..ad0ef6287 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -1597,6 +1597,18 @@ proc `$`*[T: tuple|object](x: T): string =
     result.add($value)
   result.add(")")
 
+proc `$`*[T: set](x: T): string = 
+  ## generic ``$`` operator for sets that is lifted from the components
+  ## of `x`. Example:
+  ##
+  ## .. code-block:: nimrod
+  ##   ${23, 45} == "{23, 45}"
+  result = "{"
+  for value in items(x):
+    if result.len > 1: result.add(", ")
+    result.add($value)
+  result.add("}")
+
 when false:
   proc `$`*[T](a: openArray[T]): string = 
     ## generic ``$`` operator for open arrays that is lifted from the elements