dtolnay/cxx

Support passing function pointers across the FFI

Open

#52 创建于 2020年3月2日

在 GitHub 查看
 (6 评论) (9 反应) (0 负责人)Rust (4,472 star) (253 fork)batch import
help wanted

描述

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

贡献者指南