summaryrefslogtreecommitdiff
path: root/examples/rust/src/hello.rs
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2025-02-12 19:13:23 +0100
committerHenry Gressmann <mail@henrygressmann.de>2025-02-12 19:13:23 +0100
commitd6493c277eb1104aaf72a8e0e6959ce3d1cc4932 (patch)
treea82452aeb44be6b79d15fc83ddfcbd12a965520a /examples/rust/src/hello.rs
parent7e668f9e321c941f38395e47a29501dce0fc81a9 (diff)
fix: fix build, improve error handling
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'examples/rust/src/hello.rs')
-rw-r--r--examples/rust/src/hello.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/examples/rust/src/hello.rs b/examples/rust/src/hello.rs
index c8e2ac3..3d9f400 100644
--- a/examples/rust/src/hello.rs
+++ b/examples/rust/src/hello.rs
@@ -1,23 +1,23 @@
#![no_main]
#[link(wasm_import_module = "env")]
-extern "C" {
+unsafe extern "C" {
fn print_utf8(location: i64, len: i32);
}
const ARG: &[u8] = &[0u8; 100];
-#[no_mangle]
+#[unsafe(no_mangle)]
pub unsafe extern "C" fn arg_ptr() -> i32 {
ARG.as_ptr() as i32
}
-#[no_mangle]
+#[unsafe(no_mangle)]
pub unsafe extern "C" fn arg_size() -> i32 {
ARG.len() as i32
}
-#[no_mangle]
+#[unsafe(no_mangle)]
pub unsafe extern "C" fn hello(len: i32) {
let arg = core::str::from_utf8(&ARG[0..len as usize]).unwrap();
let res = format!("Hello, {}!", arg).as_bytes().to_vec();