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

cgen: implement generic array.index (#7501)

This commit is contained in:
yuyi
2020-12-24 02:10:16 +08:00
committed by GitHub
parent f505f5e333
commit 132807d5d1
4 changed files with 102 additions and 1 deletions

View File

@@ -1226,3 +1226,28 @@ fn test_struct_array_of_multi_type_in() {
println(ivan in people)
assert ivan in people
}
fn test_struct_array_of_multi_type_index() {
ivan := Person{
name: 'ivan'
nums: [1, 2, 3]
kv: {
'aaa': '111'
}
}
people := [Person{
name: 'ivan'
nums: [1, 2, 3]
kv: {
'aaa': '111'
}
}, Person{
name: 'bob'
nums: [2]
kv: {
'bbb': '222'
}
}]
println(people.index(ivan))
assert people.index(ivan) == 0
}