tools/corrosion/test/custom_profiles/basic_profiles/rust/src/lib.rs
author unC0Rr
Wed, 28 Aug 2024 15:31:51 +0200
branchtransitional_engine
changeset 16050 6a3dc15b78b9
permissions -rw-r--r--
Add corrosion as a subdirectory, CMake fixes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16050
6a3dc15b78b9 Add corrosion as a subdirectory, CMake fixes
unC0Rr
parents:
diff changeset
     1
use std::os::raw::c_char;
6a3dc15b78b9 Add corrosion as a subdirectory, CMake fixes
unC0Rr
parents:
diff changeset
     2
6a3dc15b78b9 Add corrosion as a subdirectory, CMake fixes
unC0Rr
parents:
diff changeset
     3
#[no_mangle]
6a3dc15b78b9 Add corrosion as a subdirectory, CMake fixes
unC0Rr
parents:
diff changeset
     4
pub extern "C" fn rust_function(name: *const c_char) {
6a3dc15b78b9 Add corrosion as a subdirectory, CMake fixes
unC0Rr
parents:
diff changeset
     5
    let name = unsafe { std::ffi::CStr::from_ptr(name).to_str().unwrap() };
6a3dc15b78b9 Add corrosion as a subdirectory, CMake fixes
unC0Rr
parents:
diff changeset
     6
    println!("Hello, {}! I'm Rust!", name);
6a3dc15b78b9 Add corrosion as a subdirectory, CMake fixes
unC0Rr
parents:
diff changeset
     7
}
6a3dc15b78b9 Add corrosion as a subdirectory, CMake fixes
unC0Rr
parents:
diff changeset
     8