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

builtin: fix byte.str() (part 2)

This commit is contained in:
Alexander Medvednikov
2021-01-05 19:26:48 +01:00
parent 7a6b160d63
commit 3722e16073
2 changed files with 4 additions and 23 deletions

View File

@ -441,18 +441,7 @@ pub fn (nn byteptr) hex_full() string { return u64_to_hex(nn, 16) }
// str returns the contents of `byte` as a zero terminated `string`.
// Example: assert byte(111).str() == 'o'
pub fn (b byte) str() string {
// TODO
// return int(b).str_l(7)
mut str := string{
str: malloc(2)
len: 1
}
unsafe {
str.str[0] = b
str.str[1] = `\0`
}
// println(str)
return str
return int(b).str_l(7)
}
pub fn (b byte) ascii_str() string {