mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parent
d353dd6e8a
commit
71c3b66ecf
@ -207,7 +207,7 @@ pub fn (mut iter ListIter[T]) next() ?T {
|
||||
if iter.node == unsafe { nil } {
|
||||
return none
|
||||
}
|
||||
res := iter.node.data
|
||||
res := unsafe { iter.node.data }
|
||||
iter.node = iter.node.next
|
||||
return res
|
||||
}
|
||||
|
@ -168,3 +168,26 @@ fn test_linked_list_separate_iterators() {
|
||||
}
|
||||
assert res == [1, 2, 3]
|
||||
}
|
||||
|
||||
struct Foo {
|
||||
mut:
|
||||
field LinkedList[map[string]int]
|
||||
}
|
||||
|
||||
fn test_linked_list_map() {
|
||||
mut foo := Foo{}
|
||||
foo.field.push({
|
||||
'one': 1
|
||||
})
|
||||
foo.field.push({
|
||||
'two': 2
|
||||
})
|
||||
println(foo)
|
||||
mut iter := foo.field.iterator()
|
||||
assert iter.next()! == {
|
||||
'one': 1
|
||||
}
|
||||
assert iter.next()! == {
|
||||
'two': 2
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user