summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-06-01 17:59:21 +0200
committerAndreas Rumpf <rumpf_a@web.de>2016-06-01 17:59:58 +0200
commitdc4a30c6b16f306d8baab086d71bc2a5aae91682 (patch)
tree8ada2f64e34bc7e58b30de2895fbd901c53bdc5b /lib/pure
parenta1291a318751d8d9111eb3d0b8189b0d6987c400 (diff)
downloadNim-dc4a30c6b16f306d8baab086d71bc2a5aae91682.tar.gz
adds strutils.toHex variant that knows about the used integer size
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/strutils.nim4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim
index 22641bca2..f59313450 100644
--- a/lib/pure/strutils.nim
+++ b/lib/pure/strutils.nim
@@ -542,6 +542,10 @@ proc toHex*(x: BiggestInt, len: Positive): string {.noSideEffect,
     # handle negative overflow
     if n == 0 and x < 0: n = -1
 
+proc toHex*[T](x: T): string =
+  ## Shortcut for ``toHex(x, T.sizeOf * 2)``
+  toHex(x, T.sizeOf * 2)
+
 proc intToStr*(x: int, minchars: Positive = 1): string {.noSideEffect,
   rtl, extern: "nsuIntToStr".} =
   ## Converts `x` to its decimal representation.