Closed
Description
Currently only freestanding functions are supported by this crate, not methods.
I like the approach of using self
in the foreign function parameter list to signify a method receiver:
#[cxx::bridge]
mod ffi {
extern "C" {
type C;
fn f(self: &C);
}
extern "Rust" {
type R;
fn g(self: &R);
}
}
struct R {...}
impl R {
fn g(&self) {...}
}
This would expose the methods r.g()
to C++ and c.f()
to Rust.
The above syntax would require rustc 1.43 or newer for rust-lang/rust#68728.
Metadata
Metadata
Assignees
Labels
No labels