summaryrefslogtreecommitdiff
path: root/examples/rust/src/hello.rs
diff options
context:
space:
mode:
authorMica White <botahamec@outlook.com>2026-10-31 11:10:49 -0400
committerMica White <botahamec@outlook.com>2026-10-31 11:10:49 -0400
commit264ea48cc8c6dd9c3c9e0fe1a559252863fc9962 (patch)
tree84a4a58de14442f4fcfa06bd0d82480508f82759 /examples/rust/src/hello.rs
parent7877eca4e8be283e7c51168ee3a3b05d9000f39c (diff)
parentb45a98a85c776d956a797773acd2f198c06b40ed (diff)
Merge branch 'main' into bota-tortuise
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);
+ }
}