arraybuf: fix dangling pointer and name workaround (#237)
https://github.com/nim-lang/Nim/issues/24260 https://github.com/nim-lang/Nim/issues/24261
This commit is contained in:
parent
763147cf82
commit
45b0e9d157
|
@ -56,14 +56,16 @@ template setLen*(b: var ArrayBuf, newLenParam: int) =
|
||||||
b.n = nl
|
b.n = nl
|
||||||
|
|
||||||
template data*(bParam: ArrayBuf): openArray =
|
template data*(bParam: ArrayBuf): openArray =
|
||||||
block:
|
# TODO https://github.com/nim-lang/Nim/issues/24260
|
||||||
bParam.evalOnceAs(b)
|
# TODO https://github.com/nim-lang/Nim/issues/24261
|
||||||
b.buf.toOpenArray(0, b.len() - 1)
|
bParam.evalOnceAs(bArrayBufPrivate)
|
||||||
|
bArrayBufPrivate.buf.toOpenArray(0, bArrayBufPrivate.len() - 1)
|
||||||
|
|
||||||
template data*(bParam: var ArrayBuf): var openArray =
|
template data*(bParam: var ArrayBuf): var openArray =
|
||||||
block:
|
# TODO https://github.com/nim-lang/Nim/issues/24260
|
||||||
bParam.evalOnceAs(b)
|
# TODO https://github.com/nim-lang/Nim/issues/24261
|
||||||
b.buf.toOpenArray(0, b.len() - 1)
|
bParam.evalOnceAs(bArrayBufPrivate)
|
||||||
|
bArrayBufPrivate.buf.toOpenArray(0, bArrayBufPrivate.len() - 1)
|
||||||
|
|
||||||
iterator items*[N, T](b: ArrayBuf[N, T]): lent T =
|
iterator items*[N, T](b: ArrayBuf[N, T]): lent T =
|
||||||
for i in 0 ..< b.len:
|
for i in 0 ..< b.len:
|
||||||
|
|
Loading…
Reference in New Issue