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

strings: add Builder.write_rune/1 and Builder.write_runes/1 methods

This commit is contained in:
Delyan Angelov
2021-08-19 07:14:20 +03:00
parent 26b77515b9
commit fe08e1c504
3 changed files with 46 additions and 7 deletions

View File

@@ -34,9 +34,7 @@ pub fn (c rune) str() string {
[manualfree]
pub fn (ra []rune) string() string {
mut sb := strings.new_builder(ra.len)
for r in ra {
sb.write_string(r.str())
}
sb.write_runes(ra)
res := sb.str()
unsafe { sb.free() }
return res