2021-10-06 10:43:49 +03:00
|
|
|
module builtin
|
|
|
|
|
|
|
|
import strings
|
|
|
|
|
|
|
|
pub fn (ra []rune) string() string {
|
|
|
|
mut sb := strings.new_builder(ra.len)
|
|
|
|
sb.write_runes(ra)
|
|
|
|
res := sb.str()
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (c rune) repeat(count int) string {
|
|
|
|
if count < 0 {
|
2022-11-15 16:53:13 +03:00
|
|
|
panic('rune.repeat: count is negative: ${count}')
|
2021-10-06 10:43:49 +03:00
|
|
|
} else if count == 0 {
|
|
|
|
return ''
|
|
|
|
} else if count == 1 {
|
|
|
|
return c.str()
|
|
|
|
}
|
|
|
|
res := ''
|
2021-11-14 22:06:58 +03:00
|
|
|
#res.str = String.fromCharCode(Number(c.val))
|
2021-10-06 10:43:49 +03:00
|
|
|
|
|
|
|
return res.repeat(count)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (c rune) str() string {
|
|
|
|
res := ''
|
2021-11-14 22:06:58 +03:00
|
|
|
#res.str = String.fromCharCode(Number(c.val))
|
2021-10-06 10:43:49 +03:00
|
|
|
|
|
|
|
return res
|
|
|
|
}
|