Created
April 14, 2019 22:20
-
-
Save richardnfag/736a4a14963fc875d0abd783ce643d62 to your computer and use it in GitHub Desktop.
Rust FFI no stdlib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![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