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

checker: support non-string map.keys method (#7760)

This commit is contained in:
Nick Treleaven
2021-01-03 14:55:06 +00:00
committed by GitHub
parent 529f46d808
commit 38e0aa350d
4 changed files with 21 additions and 4 deletions

View File

@ -646,7 +646,7 @@ pub fn (m &map) keys() []string {
}
// Returns all keys in the map.
pub fn (m &map) keys_1() array {
fn (m &map) keys_1() array {
mut keys := __new_array(m.len, 0, m.key_bytes)
mut item := unsafe { byteptr(keys.data) }
if m.key_values.deletes == 0 {
@ -674,7 +674,7 @@ pub fn (m &map) keys_1() array {
// warning: only copies keys, does not clone
[unsafe]
pub fn (d &DenseArray) clone() DenseArray {
fn (d &DenseArray) clone() DenseArray {
res := DenseArray{
key_bytes: d.key_bytes
value_bytes: d.value_bytes

View File

@ -492,6 +492,7 @@ fn test_int_keys() {
same := mc == m
assert same
assert mc.len == 3
assert mc.keys() == [3,4,5]
mut all := []int{}
for k, v in mc {
assert m[k] == v