dtolnay/cxx

Support passing function pointers across the FFI

オープン

#52 opened on 2020/03/02

 (6 件のコメント) (9 件のリアクション) (0 人の担当者)Rust (253 件のフォーク)batch import
help wanted

Repository metrics

Stars
 (4,472 個のスター)
PR merge metrics
 (平均マージ 8m) (30d で 3 merged PRs)

説明

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);
}

コントリビューターガイド