chore: reorg
This commit is contained in:
6
__ffi/live-reload-rust/libgreet-rs/Cargo.lock
generated
Normal file
6
__ffi/live-reload-rust/libgreet-rs/Cargo.lock
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "greet"
|
||||
version = "0.1.0"
|
||||
|
||||
12
__ffi/live-reload-rust/libgreet-rs/Cargo.toml
Normal file
12
__ffi/live-reload-rust/libgreet-rs/Cargo.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "greet"
|
||||
version = "0.1.0"
|
||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
crate-type = ["dylib"]
|
||||
|
||||
[dependencies]
|
||||
10
__ffi/live-reload-rust/libgreet-rs/src/lib.rs
Normal file
10
__ffi/live-reload-rust/libgreet-rs/src/lib.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
use std::{ffi::CStr, os::raw::c_char};
|
||||
|
||||
/// # Safety
|
||||
/// Pointer must be valid, and point to a null-terminated
|
||||
/// string. What happens otherwise is UB.
|
||||
pub unsafe extern "C" fn greet(name: *const c_char) {
|
||||
let cstr = CStr::from_ptr(name);
|
||||
println!("Hello, {}!", cstr.to_str().unwrap());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user