mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parent
fc193bebf2
commit
fd58e9f819
@ -679,7 +679,8 @@ fn (mut g Gen) gen_str_for_map(info ast.Map, styp string, str_fn_name string) {
|
||||
tmp_str := str_intp_sq('*($val_styp*)DenseArray_value(&m.key_values, i)')
|
||||
g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, $tmp_str);')
|
||||
} else if should_use_indent_func(val_sym.kind) && !val_sym.has_method('str') {
|
||||
g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, indent_${elem_str_fn_name}(*($val_styp*)DenseArray_value(&m.key_values, i), indent_count));')
|
||||
ptr_str := '*'.repeat(val_typ.nr_muls())
|
||||
g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, indent_${elem_str_fn_name}(*${ptr_str}($val_styp*)DenseArray_value(&m.key_values, i), indent_count));')
|
||||
} else if val_sym.kind in [.f32, .f64] {
|
||||
tmp_val := '*($val_styp*)DenseArray_value(&m.key_values, i)'
|
||||
if val_sym.kind == .f32 {
|
||||
|
@ -22,3 +22,18 @@ fn test_adding_to_mutable_string_field() {
|
||||
eprintln(foo.str)
|
||||
assert foo.str == 'hi!'
|
||||
}
|
||||
|
||||
struct MyStruct {
|
||||
a string
|
||||
b int
|
||||
}
|
||||
|
||||
fn test_map_of_ref_struct_string() {
|
||||
mut ar := map[string]&MyStruct{}
|
||||
ar['a'] = &MyStruct{}
|
||||
println(ar)
|
||||
assert '$ar'.contains('MyStruct')
|
||||
assert ('b' in ar) == false
|
||||
assert ('a' in ar) == true
|
||||
assert 'a' in ar
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user