Skip to content

danielhenrymantilla/extern-c.rs

::extern-c

Convert a zero-sized closure into an extern "C" fn(…) pointer with the same1 type signature.

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);

Footnotes

  1. but for the ABI, of course!