From 8adce672578683dcc7ab62e5492e0f5dbc07a0b4 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Fri, 26 Jan 2024 18:03:59 +0100 Subject: docs: string example Signed-off-by: Henry Gressmann --- examples/rust/src/print.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/rust/src/print.rs (limited to 'examples/rust/src/print.rs') diff --git a/examples/rust/src/print.rs b/examples/rust/src/print.rs new file mode 100644 index 0000000..34f3c7f --- /dev/null +++ b/examples/rust/src/print.rs @@ -0,0 +1,18 @@ +#![no_std] +#![no_main] + +#[cfg(not(test))] +#[panic_handler] +fn panic(_info: &core::panic::PanicInfo) -> ! { + core::arch::wasm32::unreachable() +} + +#[link(wasm_import_module = "env")] +extern "C" { + fn printi32(x: i32); +} + +#[no_mangle] +pub unsafe extern "C" fn add_and_print(lh: i32, rh: i32) { + printi32(lh + rh); +} -- cgit v1.3.1