summaryrefslogtreecommitdiff
path: root/examples/rust/src/hello.rs
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2026-08-23 13:40:38 +0200
committerGitHub <noreply@github.com>2026-08-23 13:40:38 +0200
commit951c8070169e8bd970940029156f305e741aecdb (patch)
treefbf012a24cbd380b689958122e7f66a2a85d23e1 /examples/rust/src/hello.rs
parent358a183e5c12c32b8836acf9c71799f56e00b036 (diff)
chore: remove LinearMemory trait (#53)
Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'examples/rust/src/hello.rs')
-rw-r--r--examples/rust/src/hello.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/examples/rust/src/hello.rs b/examples/rust/src/hello.rs
index 3d9f400..06ef5c9 100644
--- a/examples/rust/src/hello.rs
+++ b/examples/rust/src/hello.rs
@@ -19,10 +19,12 @@ pub unsafe extern "C" fn arg_size() -> i32 {
#[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();
+ unsafe {
+ let arg = core::str::from_utf8(&ARG[0..len as usize]).unwrap();
+ let res = format!("Hello, {}!", arg).as_bytes().to_vec();
- let len = res.len() as i32;
- let ptr = res.leak().as_ptr() as i64;
- print_utf8(ptr, len);
+ let len = res.len() as i32;
+ let ptr = res.leak().as_ptr() as i64;
+ print_utf8(ptr, len);
+ }
}