dtolnay/cxx

Support passing function pointers across the FFI

開放

#52 建立於 2020年3月2日

 (6 則留言) (9 個反應) (0 位負責人)Rust (253 個分叉)batch import
help wanted

倉庫指標

星標
 (4,472 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

i.e. function parameters with the type fn(...) -> ....

#[cxx::bridge]
mod ffi {
    extern "Rust" {
        fn f(arg: u8, callback: fn(u8));
    }
}

fn f(arg: u8, callback: fn(u8)) {
    callback(256 - arg);
}

貢獻者指南