Skip to content

Commit

Permalink
Add cursor to lists iterator variables (#22531)
Browse files Browse the repository at this point in the history
* followup #21507
  • Loading branch information
AmjadHD committed Aug 24, 2023
1 parent 1013378 commit fc6a388
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/pure/collections/lists.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit fc6a388

Please sign in to comment.