1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vfmt: voidptr(0) => unsafe { nil } (p.1)

This commit is contained in:
Alexander Medvednikov
2022-07-21 20:45:57 +03:00
parent be9f8cc777
commit caa0c2f153
17 changed files with 153 additions and 123 deletions

View File

@@ -89,12 +89,12 @@ pub fn (mut list DoublyLinkedList<T>) pop_back() ?T {
if list.len == 1 {
// head == tail
value := list.tail.data
list.head = voidptr(0)
list.tail = voidptr(0)
list.head = unsafe { nil }
list.tail = unsafe { nil }
return value
}
value := list.tail.data
list.tail.prev.next = voidptr(0) // unlink tail
list.tail.prev.next = unsafe { nil } // unlink tail
list.tail = list.tail.prev
return value
}
@@ -110,12 +110,12 @@ pub fn (mut list DoublyLinkedList<T>) pop_front() ?T {
if list.len == 1 {
// head == tail
value := list.head.data
list.head = voidptr(0)
list.tail = voidptr(0)
list.head = unsafe { nil }
list.tail = unsafe { nil }
return value
}
value := list.head.data
list.head.next.prev = voidptr(0) // unlink head
list.head.next.prev = unsafe { nil } // unlink head
list.head = list.head.next
return value
}
@@ -261,15 +261,15 @@ pub fn (list DoublyLinkedList<T>) str() string {
// next implements the iter interface to use DoublyLinkedList with
// V's for loop syntax.
pub fn (mut list DoublyLinkedList<T>) next() ?T {
if list.iter == voidptr(0) {
if list.iter == unsafe { nil } {
// initialize new iter object
list.iter = &DoublyListIter<T>{
node: list.head
}
return list.next()
}
if list.iter.node == voidptr(0) {
list.iter = voidptr(0)
if list.iter.node == unsafe { nil } {
list.iter = unsafe { nil }
return none
}
defer {