#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

#321 in FFI

Download history 14289/week @ 2024-05-10 14705/week @ 2024-05-17 15330/week @ 2024-05-24 17267/week @ 2024-05-31 12294/week @ 2024-06-07 12892/week @ 2024-06-14 16200/week @ 2024-06-21 14178/week @ 2024-06-28 7458/week @ 2024-07-05 6696/week @ 2024-07-12 7563/week @ 2024-07-19 6469/week @ 2024-07-26 6016/week @ 2024-08-02 5371/week @ 2024-08-09 7017/week @ 2024-08-16 5592/week @ 2024-08-23

25,708 downloads per month
Used in dittolive-ditto

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