Add cursor annotations to lists iterator variables (#21507)

Add `cursor` annotations to iterator variables

* See https://nim-lang.github.io/Nim/destructors.html#the-cursor-pragma
This commit is contained in:
Amjad Ben Hedhili 2023-03-13 08:43:45 +01:00 • committed by GitHub
commit c52e44d845
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -188,13 +188,13 @@ func toDoublyLinkedList*[T](elems: openArray[T]): DoublyLinkedList[T] {.since: (
result.add(elem) result.add(elem)
template itemsListImpl() {.dirty.} = template itemsListImpl() {.dirty.} =
var it = L.head var it {.cursor.} = L.head
while it != nil: while it != nil:
yield it.value yield it.value
it = it.next it = it.next
template itemsRingImpl() {.dirty.} = template itemsRingImpl() {.dirty.} =
var it = L.head var it {.cursor.} = L.head
if it != nil: if it != nil:
while true: while true:
yield it.value yield it.value