builtin: fix `["abc", "xyz"].str()`

pull/9447/head
Delyan Angelov 2021-03-23 22:11:32 +02:00
parent b7c01db1f9
commit 7afa4c7e2c
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 4 additions and 1 deletions

View File

@ -498,6 +498,7 @@ pub fn (mut a []string) free() {
// str returns a string representation of the array of strings // str returns a string representation of the array of strings
// => '["a", "b", "c"]'. // => '["a", "b", "c"]'.
[manualfree]
pub fn (a []string) str() string { pub fn (a []string) str() string {
mut sb := strings.new_builder(a.len * 3) mut sb := strings.new_builder(a.len * 3)
sb.write_string('[') sb.write_string('[')
@ -511,7 +512,9 @@ pub fn (a []string) str() string {
} }
} }
sb.write_string(']') sb.write_string(']')
return sb.str() res := sb.str()
unsafe { sb.free() }
return res
} }
// hex returns a string with the hexadecimal representation // hex returns a string with the hexadecimal representation