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

#358 in FFI

Download history 9865/week @ 2024-11-15 12237/week @ 2024-11-22 15274/week @ 2024-11-29 20450/week @ 2024-12-06 17437/week @ 2024-12-13 4970/week @ 2024-12-20 3440/week @ 2024-12-27 18728/week @ 2025-01-03 20120/week @ 2025-01-10 22101/week @ 2025-01-17 20823/week @ 2025-01-24 24153/week @ 2025-01-31 26262/week @ 2025-02-07 17515/week @ 2025-02-14 14448/week @ 2025-02-21 13380/week @ 2025-02-28

75,801 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