-
-
Save steveklabnik/5abd59a8fe7e5abda3db58bd8c208fbb to your computer and use it in GitHub Desktop.
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, start)] | |
#![no_std] | |
#[link(name = "c")] | |
extern { | |
fn puts(s: *const u8) -> isize; | |
fn abort() -> !; | |
} | |
#[lang = "panic_fmt"] | |
#[no_mangle] | |
pub extern fn rust_panic_fmt() -> ! { unsafe { abort() } } | |
#[lang = "eh_personality"] | |
#[no_mangle] | |
pub extern fn rust_eh_personality() {} | |
#[lang = "eh_unwind_resume"] | |
#[no_mangle] | |
pub extern fn rust_eh_unwind_resume() {} | |
struct MyType { | |
integer: i32 | |
} | |
impl MyType { | |
pub fn new(flag: bool) -> Result<MyType, ()> { | |
if flag { Ok(MyType { integer: 5 }) } else { Err(()) } | |
} | |
} | |
#[start] | |
fn main(_argc: isize, _argv: *const *const u8) -> isize { | |
unsafe { puts(b"Hello, world\0" as *const u8); } | |
let s = MyType::new(true).unwrap(); | |
0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment