mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: fix ["abc", "xyz"].str()
This commit is contained in:
@@ -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
|
||||||
|
Reference in New Issue
Block a user