mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
map := { 'foo': 'bar' } syntax
This commit is contained in:
@@ -29,6 +29,18 @@ fn new_map(cap, elm_size int) map {
|
||||
return res
|
||||
}
|
||||
|
||||
// `m := { 'one': 1, 'two': 2 }`
|
||||
fn new_map_init(cap, elm_size int, keys *string, vals voidptr) map {
|
||||
mut res := map {
|
||||
element_size: elm_size
|
||||
root: 0
|
||||
}
|
||||
for i in 0 .. cap {
|
||||
res._set(keys[i], vals + i * elm_size)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
fn new_node(key string, val voidptr, element_size int) *Node {
|
||||
new_e := &Node {
|
||||
key: key
|
||||
|
||||
Reference in New Issue
Block a user