#extern #abi #callback #pointers #c

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

#263 in FFI

Download history 24511/week @ 2025-03-10 23912/week @ 2025-03-17 28778/week @ 2025-03-24 23684/week @ 2025-03-31 28016/week @ 2025-04-07 25958/week @ 2025-04-14 21568/week @ 2025-04-21 20950/week @ 2025-04-28 21133/week @ 2025-05-05 28161/week @ 2025-05-12 26054/week @ 2025-05-19 22192/week @ 2025-05-26 22399/week @ 2025-06-02 16383/week @ 2025-06-09 20880/week @ 2025-06-16 18602/week @ 2025-06-23

78,501 downloads per month
Used in 33 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