Giving names to callback parameters


#1

The external API for our project has a number of FFI functions containing callbacks. We were wondering if it was possible to give callback parameters meaningful names which would appear in our documentation.

For example, the following code with named callback parameters is valid:

#[no_mangle]
pub unsafe extern "C" fn app_account_info(
    app: *mut App,
    user_data: *mut c_void,
    o_cb: extern "C" fn(user_data: *mut c_void, result: FfiResult, account_info: *const FfiAccountInfo),
)

Yet the parameter names are absent from the generated docs:

pub unsafe extern "C" fn app_account_info(
    app: *mut App, 
    user_data: *mut c_void, 
    o_cb: extern "C" fn(_: *mut c_void, _: FfiResult, _: *const FfiAccountInfo)
)

I did some googling for this and failed to find anything relevant. Any ideas?


#2

I filed rust-lang/rust#44570 to follow up. I’m sure they would love a rustdoc PR if you have time to fix this.


#3

This has been fixed as of rustc 1.22.0-nightly (05f8ddc46 2017-10-07)!