#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

#306 in FFI

Download history 6934/week @ 2024-01-27 2634/week @ 2024-02-03 7658/week @ 2024-02-10 7322/week @ 2024-02-17 6591/week @ 2024-02-24 7160/week @ 2024-03-02 8554/week @ 2024-03-09 7205/week @ 2024-03-16 7263/week @ 2024-03-23 7677/week @ 2024-03-30 8156/week @ 2024-04-06 8810/week @ 2024-04-13 11302/week @ 2024-04-20 15603/week @ 2024-04-27 10943/week @ 2024-05-04 14418/week @ 2024-05-11

53,862 downloads per month

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