#abi #callback #extern

extern-c

Convert a zero-sized closure into an extern "C" fn() pointer

2 releases

0.1.1-rc1 Sep 7, 2023
0.1.0 Sep 5, 2023

#2752 in Rust patterns

Download history 6903/week @ 2024-07-10 7462/week @ 2024-07-17 6655/week @ 2024-07-24 6793/week @ 2024-07-31 5290/week @ 2024-08-07 5972/week @ 2024-08-14 6595/week @ 2024-08-21 6205/week @ 2024-08-28 7503/week @ 2024-09-04 5158/week @ 2024-09-11 6483/week @ 2024-09-18 8023/week @ 2024-09-25 9688/week @ 2024-10-02 8661/week @ 2024-10-09 13509/week @ 2024-10-16 11061/week @ 2024-10-23

44,261 downloads per month
Used in 32 crates (2 directly)

Zlib OR MIT OR Apache-2.0

13KB
175 lines

::extern-c

Convert a zero-sized closure into an extern "C" fn() pointer with the same[^abi] type signature.

[^abi]: but for the ABI, of course!

Repository Latest version Documentation MSRV no_std compatible License CI

Example

use ::extern_c::extern_c;

let f: extern "C" fn(bool) -> u8 = extern_c(|b: bool| b as u8);
assert_eq!(f(true), 1);

Dependencies

~8KB