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

unsafe: tag with unsafe{} some more pointer manipulations

This commit is contained in:
Delyan Angelov
2020-07-22 21:42:51 +03:00
parent 949ed90b51
commit 276c1de190
9 changed files with 44 additions and 25 deletions

View File

@@ -478,11 +478,13 @@ fn test_reverse() {
fn test_bytes_to_string() {
mut buf := vcalloc(10)
buf[0] = `h`
buf[1] = `e`
buf[2] = `l`
buf[3] = `l`
buf[4] = `o`
unsafe {
buf[0] = `h`
buf[1] = `e`
buf[2] = `l`
buf[3] = `l`
buf[4] = `o`
}
assert string(buf) == 'hello'
assert string(buf, 2) == 'he'
bytes := [`h`, `e`, `l`, `l`, `o`]