rust/example.rs

49 lines
631 B
Rust
Raw Normal View History

2018-06-17 18:05:11 +02: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 19:10:00 +02:00
/*fn bcd(b: bool, a: u8) -> u8 {
2018-06-17 18:05:11 +02:00
if b {
a * 2
} else {
a * 3
}
2018-06-17 19:10:00 +02:00
}*/
fn call() {
abc(42);
}