mirror of
https://github.com/status-im/nim-stew.git
synced 2025-01-10 04:05:44 +00:00
24 lines
590 B
Nim
24 lines
590 B
Nim
template init*(lvalue: var auto) =
|
|
mixin init
|
|
lvalue = init(type(lvalue))
|
|
|
|
template init*(lvalue: var auto, a1: auto)=
|
|
mixin init
|
|
lvalue = init(type(lvalue), a1)
|
|
|
|
template init*(lvalue: var auto, a1, a2: auto) =
|
|
mixin init
|
|
lvalue = init(type(lvalue), a1, a2)
|
|
|
|
template init*(lvalue: var auto, a1, a2, a3: auto) =
|
|
mixin init
|
|
lvalue = init(type(lvalue), a1, a2, a3)
|
|
|
|
when not declared(default):
|
|
proc default*(T: type): T = discard
|
|
|
|
proc toArray*[T](N: static int, data: openarray[T]): array[N, T] =
|
|
doAssert data.len == N
|
|
copyMem(addr result[0], unsafeAddr data[0], N)
|
|
|