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 {
|
|
|
|
panic('rune.repeat: count is negative: $count')
|
|
|
|
} 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
|
|
|
|
}
|