dtolnay/cxx

Support higher rank function pointers

Open

#817 opened on Apr 9, 2021

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Rust (253 forks)batch import
help wanted

Repository metrics

Stars
 (4,472 stars)
PR merge metrics
 (Avg merge 8m) (3 merged PRs in 30d)

Description

#[cxx::bridge]
mod ffi {
    extern "Rust" {
        type Thing<'a>;
    }

    unsafe extern "C++" {
        fn f(callback: for<'a> fn(&mut Thing<'a>, &mut Thing<'a>));
    }
}

Currently rejected:

error: function pointer with lifetime parameters is not supported yet
 --> src/main.rs:8:24
  |
8 |         fn f(callback: for<'a> fn(&mut Thing<'a>, &mut Thing<'a>));
  |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Contributor guide