summaryrefslogtreecommitdiff
path: root/examples/rust/src/host_fn.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/host_fn.rs
parent7e668f9e321c941f38395e47a29501dce0fc81a9 (diff)
fix: fix build, improve error handling
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'examples/rust/src/host_fn.rs')
-rw-r--r--examples/rust/src/host_fn.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/examples/rust/src/host_fn.rs b/examples/rust/src/host_fn.rs
new file mode 100644
index 0000000..ada74bd
--- /dev/null
+++ b/examples/rust/src/host_fn.rs
@@ -0,0 +1,11 @@
+#![no_main]
+
+#[link(wasm_import_module = "env")]
+unsafe extern "C" {
+ fn bar(left: i64, right: i32) -> i32;
+}
+
+#[unsafe(no_mangle)]
+pub fn foo() -> i32 {
+ unsafe { bar(1, 2) }
+}