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

datatypes: fix linked list of map (fix #17570) (#17573)

This commit is contained in:
yuyi 2023-03-09 21:26:01 +08:00 committed by GitHub
parent d353dd6e8a
commit 71c3b66ecf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -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
}

View File

@ -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
}
}