Skip to content

Instantly share code, notes, and snippets.

@richardnfag
Created April 14, 2019 22:20
Show Gist options
  • Save richardnfag/736a4a14963fc875d0abd783ce643d62 to your computer and use it in GitHub Desktop.
Save richardnfag/736a4a14963fc875d0abd783ce643d62 to your computer and use it in GitHub Desktop.
Rust FFI no stdlib
#![feature(lang_items)]
#![no_std]
use core::panic::PanicInfo;
#[no_mangle]
pub extern "C" fn factorial(x: u32) -> u32 {
(1..).take_while(|&i| i <= x).product()
}
#[lang = "eh_personality"] extern fn rust_eh_personality() {}
#[panic_handler] fn panic(_info: &PanicInfo) -> ! {
loop {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment