原书出处
Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)
6 Chapter 6. Beyond Standard Rust Invoking Rust from C
for the job here is
Box::into_raw, which abnegates responsibility for the heap object, effectively “forgetting” about it: #[no_mangle] pub extern "C" fn new_struct_raw(v: u32) -> *mut FfiStruct { let s = FfiStruct::new(v); // create `FfiStruct` on stack let b = Box::new(s); // move `FfiStruct` to heap // Consume the `Box` and take responsibility for the heap memory. Box::into_r
aw(b) } This raises
原书定位详情
来源:a19c7933-4eda-4176-aebd-30fe7e1ad292
正文位置:extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch06.html#id164
EPUB SHA-256:523496927c4fd2d3fc11c9b81ad96b76201e66d746b6ac29d71d61d3517181c1