summary refs log tree commit diff stats
path: root/lib/pure/collections/lists.nim
diff options
context:
space:
mode:
authorAmjad Ben Hedhili <amjadhedhili@outlook.com>2023-03-27 16:10:51 +0100
committerGitHub <noreply@github.com>2023-03-27 17:10:51 +0200
commit3936071772d648f98c36e5aad16a341b86344e6c (patch)
treee8389fe274b4060bb3f421187572340d4fb935d4 /lib/pure/collections/lists.nim
parent55636a2913d0b0dec6b24568cb6baef43a9220c1 (diff)
downloadNim-3936071772d648f98c36e5aad16a341b86344e6c.tar.gz
Add `cursor` to lists iterator variables (#21527)
* followup #21507
Diffstat (limited to 'lib/pure/collections/lists.nim')
-rw-r--r--lib/pure/collections/lists.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/pure/collections/lists.nim b/lib/pure/collections/lists.nim
index 6e3ddf397..e1d32e737 100644
--- a/lib/pure/collections/lists.nim
+++ b/lib/pure/collections/lists.nim
@@ -286,7 +286,7 @@ iterator nodes*[T](L: SomeLinkedList[T]): SomeLinkedNode[T] =
         x.value = 5 * x.value - 1
     assert $a == "[49, 99, 199, 249]"
 
-  var it = L.head
+  var it {.cursor.} = L.head
   while it != nil:
     let nxt = it.next
     yield it
@@ -311,7 +311,7 @@ iterator nodes*[T](L: SomeLinkedRing[T]): SomeLinkedNode[T] =
         x.value = 5 * x.value - 1
     assert $a == "[49, 99, 199, 249]"
 
-  var it = L.head
+  var it {.cursor.} = L.head
   if it != nil:
     while true:
       let nxt = it.next
@@ -733,7 +733,7 @@ proc remove*[T](L: var SinglyLinkedList[T], n: SinglyLinkedNode[T]): bool {.disc
     if L.tail.next == n:
       L.tail.next = L.head # restore cycle
   else:
-    var prev = L.head
+    var prev {.cursor.} = L.head
     while prev.next != n and prev.next != nil:
       prev = prev.next
     if prev.next == nil: