dtolnay/cxx

Support higher rank function pointers

Open

#817 opened on Apr 9, 2021

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

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