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