docs.rs failed to build libffi-0.4.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
libffi-3.2.0
libffi-rs: Rust bindings for libffi
The C libffi library provides two main facilities: assembling calls
to functions dynamically, and creating closures that can be called
as ordinary C functions. In Rust, the latter means that we can turn
a Rust lambda (or any object implementing Fn
/FnMut
) into an
ordinary C function pointer that we can pass as a callback to C.
Usage
It’s on crates.io, so you can add
[]
= "0.4.0"
to your Cargo.toml
and
extern crate libffi;
to your crate root.
Examples
In this example, we convert a Rust lambda containing a free variable
into an ordinary C code pointer. The type of fun
below is
extern "C" fn(u64, u64) -> u64
.
use libffi::high::Closure2;
let x = 5u64;
let f = |y: u64, z: u64| x + y + z;
let closure = Closure2::new(&f);
let fun = closure.code_ptr();
assert_eq!(18, fun(6, 7));