You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When iterating over the pairs of a Table or (or indeed any other std lib type with a custom iterator), there's no fundamental reason why a copy of the keys/values should be needed and indeed, it is significantly expensive to require one for anything but non-trivial table entries.
Apart from being broadly inefficient, it also makes it hard to use move-only types in general because they can no longer be used with std containers.
import std/tables
typeNoCopies=objectproc`=copy`(a: varNoCopies, b: NoCopies) {.error.}
var t: Table[int, NoCopies]
t[3] =NoCopies() # only movesfor k,v in t.pairs(): # lent values, no need to copy!echo"found entry"
Nim Version
2.2
Current Output
Error: '=copy' is not available for type <NoCopies>; requires a copy because it's not the last read of 't.data[h].val'; routine: main
Expected Output
Known Workarounds
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered:
Description
When iterating over the pairs of a
Table
or (or indeed any other std lib type with a custom iterator), there's no fundamental reason why a copy of the keys/values should be needed and indeed, it is significantly expensive to require one for anything but non-trivial table entries.Apart from being broadly inefficient, it also makes it hard to use move-only types in general because they can no longer be used with std containers.
Nim Version
2.2
Current Output
Expected Output
Known Workarounds
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: