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:
@@ -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`]
|
||||
|
Reference in New Issue
Block a user