#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

#307 in FFI

Download history 4977/week @ 2024-01-05 5879/week @ 2024-01-12 8784/week @ 2024-01-19 7425/week @ 2024-01-26 3182/week @ 2024-02-02 6514/week @ 2024-02-09 7541/week @ 2024-02-16 6616/week @ 2024-02-23 6719/week @ 2024-03-01 8239/week @ 2024-03-08 7880/week @ 2024-03-15 8046/week @ 2024-03-22 6559/week @ 2024-03-29 8483/week @ 2024-04-05 8469/week @ 2024-04-12 10187/week @ 2024-04-19

34,784 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