From 95431cf6b007561c1f105e4e7c5d76ffcae3d058 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 5 Jan 2021 18:22:17 +0200 Subject: [PATCH] builtin: fix the comment example in byte.str_escaped() --- vlib/builtin/int.v | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/vlib/builtin/int.v b/vlib/builtin/int.v index eed35bb212..0e7106ede7 100644 --- a/vlib/builtin/int.v +++ b/vlib/builtin/int.v @@ -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() } }