builtin: fix the comment example in byte.str_escaped()

pull/7900/head
Delyan Angelov 2021-01-05 18:22:17 +02:00
parent 10e7045bee
commit 95431cf6b0
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 9 additions and 9 deletions

View File

@ -452,18 +452,18 @@ pub fn (b byte) str() string {
return str
}
// TODO make an actual example for the docs: Example: assert byte(0).str_escaped() == `\0` // <- but this fails?
// str_escaped returns the contents of `byte` as an escaped `string`.
// Example: assert byte(0).str_escaped() == r'`\0`'
pub fn (b byte) str_escaped() string {
str := match b {
0 { '`\\' + '0`' } // TODO BUG is preventing \\0 in a literal
7 { '`\\a`' }
8 { '`\\b`' }
9 { '`\\t`' }
10 { '`\\n`' }
11 { '`\\v`' }
12 { '`\\f`' }
13 { '`\\r`' }
0 { r'`\0`' }
7 { r'`\a`' }
8 { r'`\b`' }
9 { r'`\t`' }
10 { r'`\n`' }
11 { r'`\v`' }
12 { r'`\f`' }
13 { r'`\r`' }
32...126 { b.str() }
else { '0x' + b.hex() }
}