Correctly unpack &mut [T] into *mut T and usize
This commit is contained in:
20
wasi-common-cbindgen/tests/array_args.rs
Normal file
20
wasi-common-cbindgen/tests/array_args.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
extern crate wasi_common_cbindgen;
|
||||
|
||||
pub use wasi_common_cbindgen::wasi_common_cbindgen;
|
||||
|
||||
#[wasi_common_cbindgen]
|
||||
fn array_args(a: &mut [u8]) {
|
||||
a[0] = 1;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut expected: &mut [u8] = &mut [0, 0];
|
||||
array_args(&mut expected);
|
||||
|
||||
let given: &mut [u8] = &mut [0, 0];
|
||||
unsafe {
|
||||
__wasi_array_args(given.as_mut_ptr(), given.len());
|
||||
}
|
||||
|
||||
assert_eq!(given, expected);
|
||||
}
|
||||
Reference in New Issue
Block a user