rust/example.rs

54 lines
688 B
Rust
Raw Normal View History

2018-06-17 11:05:11 -05:00
#![feature(no_core, lang_items)]
#![no_core]
#[lang="sized"]
trait Sized {}
#[lang="copy"]
trait Copy {}
#[lang="freeze"]
trait Freeze {}
#[lang="mul"]
trait Mul<RHS = Self> {
type Output;
#[must_use]
fn mul(self, rhs: RHS) -> Self::Output;
}
impl Mul for u8 {
type Output = u8;
fn mul(self, rhs: u8) -> u8 {
self * rhs
}
}
#[lang="panic"]
fn panic(_expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! {
loop {}
}
fn abc(a: u8) -> u8 {
a * 2
}
2018-06-17 12:10:00 -05:00
/*fn bcd(b: bool, a: u8) -> u8 {
2018-06-17 11:05:11 -05:00
if b {
a * 2
} else {
a * 3
}
2018-06-17 12:10:00 -05:00
}*/
fn call() {
abc(42);
}
2018-06-18 11:39:07 -05:00
fn indirect_call() {
let f: fn() = call;
f();
}