#abi #callback #extern #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

#354 in FFI

Download history 10976/week @ 2024-10-24 10418/week @ 2024-10-31 8703/week @ 2024-11-07 10123/week @ 2024-11-14 11572/week @ 2024-11-21 13912/week @ 2024-11-28 19642/week @ 2024-12-05 18192/week @ 2024-12-12 7906/week @ 2024-12-19 2431/week @ 2024-12-26 16330/week @ 2025-01-02 21039/week @ 2025-01-09 20140/week @ 2025-01-16 20884/week @ 2025-01-23 24652/week @ 2025-01-30 24625/week @ 2025-02-06

93,987 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