Last active
January 16, 2018 13:32
-
-
Save jefftime/d7e96461138b5aa6895550b63caac66c 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 panic_fmt() -> ! { unsafe { abort() } } | |
#[lang = "eh_personality"] | |
#[no_mangle] | |
pub extern fn eh_personality() {} | |
#[lang = "eh_unwind_resume"] | |
#[no_mangle] | |
pub extern fn 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