From ee78822e057ac5f39804ecb6ac1096734be13ef8 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 19 Mar 2021 03:56:01 +0200 Subject: [PATCH] Alternative definition of string.hexToByteArray(N) This definition is more robust. The previously existing version was producing compilation errors in certain generic contexts. static "regular" params are recommended in general as they are more flexible than the explicit generic parameters. --- stew/byteutils.nim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stew/byteutils.nim b/stew/byteutils.nim index ce0e54a..977362a 100644 --- a/stew/byteutils.nim +++ b/stew/byteutils.nim @@ -63,6 +63,11 @@ func hexToByteArray*[N: static[int]](hexStr: string): array[N, byte] ## Read an hex string and store it in a byte array. No "endianness" reordering is done. hexToByteArray(hexStr, result) +func hexToByteArray*(hexStr: string, N: static int): array[N, byte] + {.raises: [ValueError, Defect], noInit, inline.}= + ## Read an hex string and store it in a byte array. No "endianness" reordering is done. + hexToByteArray(hexStr, result) + func fromHex*[N](A: type array[N, byte], hexStr: string): A {.raises: [ValueError, Defect], noInit, inline.}= ## Read an hex string and store it in a byte array. No "endianness" reordering is done.