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
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
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