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
parent b2c1dcbbc9
commit c52e44d845

View File

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