dtolnay/cxx

Support higher rank function pointers

Aperta

#817 aperta il 9 apr 2021

 (0 commenti) (0 reazioni) (0 assegnatari)Rust (253 fork)batch import
help wanted

Metriche repository

Star
 (4472 stelle)
Metriche merge PR
 (Merge medio 8m) (3 PR mergiate in 30 g)

Descrizione

#[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>));
  |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Guida contributor