garnet/rust/lib.rs

11 lines
234 B
Rust
Raw Normal View History

2026-02-19 11:08:20 +00:00
use std::ffi::{CStr, c_char};
2026-02-19 11:08:20 +00:00
fn say_hello(name: &str) {
println!("Hello from Rust, {name}!");
}
2026-02-19 11:08:20 +00:00
#[unsafe(no_mangle)]
extern "C" fn hello(c: *const c_char) -> () {
say_hello(unsafe { CStr::from_ptr(c) }.to_str().unwrap())
}