cgen: minor cleanup in gen_str_for_option (#8622)

pull/8637/head^2
yuyi 2021-02-08 23:00:51 +08:00 committed by GitHub
parent 9e751f72c4
commit f2100166c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -138,7 +138,7 @@ fn (mut g Gen) gen_str_for_option(typ table.Type, styp string, str_fn_name strin
g.auto_str_funcs.writeln('\tif (it.is_none) {')
g.auto_str_funcs.writeln('\t\tres = _SLIT("none");')
g.auto_str_funcs.writeln('\t} else if (it.ok) {')
if typ.is_string() {
if sym.kind == .string {
g.auto_str_funcs.writeln('\t\tres = _STR("\'%.*s\\000\'", 2, ${parent_str_fn_name}(*($sym.cname*)it.data));')
} else if sym.kind == .struct_ && !sym_has_str_method {
g.auto_str_funcs.writeln('\t\tres = indent_${parent_str_fn_name}(*($sym.cname*)it.data, indent_count);')