A simple example demonstrating FFI between Lean 4 and Rust. Successfully compiled on Lean 4.22.0-rc4.
- Call Rust functions from Lean
- Pass strings and custom data structures between languages
LeanFFI/FFI.lean
- FFI bindingsMain.lean
- Call Rust functionsffi/
- Rust librarysrc/lib.rs
- Rust implementationshim.c
- C wrapper
Make sure you have Lean 4 and Rust installed, then run:
lake build && lake exe lean_ffi
This will output messages from both Lean and Rust, demonstrating the FFI integration.
If you modify the code, you may need to run lake clean
and cargo clean
to rebuild everything.
🦀