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.
This commit is contained in:
parent
6bcb21184a
commit
ee78822e05
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue