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

bring back map.str()

This commit is contained in:
Alexander Medvednikov
2019-08-05 04:34:12 +02:00
parent 8d3617b3de
commit 5ed338dc2e
3 changed files with 24 additions and 10 deletions

View File

@@ -4,6 +4,8 @@
module builtin
import strings
struct map {
element_size int
root *Node
@@ -243,16 +245,19 @@ pub fn (m map) free() {
}
pub fn (m map_string) str() string {
// return 'not impl'
if m.size == 0 {
return '{}'
}
// TODO use bytes buffer
mut s := '{\n'
//for key, val in m {
//val := m[entry.key]
//s += ' "$entry.key" => "$val"\n'
//}
s += '}'
return s
//mut sb := strings.new_builder(50)
//sb.writeln('{')
mut s := '{\n'
for key, val in m {
//sb.writeln(' "$entry.key" => "$val"')
s += ' "$key" => "$val"\n'
}
s += '}\n'
//sb.writeln('}')
//return sb.str()
return s
}