Last active
May 12, 2017 05:53
-
-
Save kogai/6e81085d0a1d4c8d4c46ff2c257e4c91 to your computer and use it in GitHub Desktop.
RUSTFLAGS="--emit asm" cargo build
This file contains hidden or 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
| #![no_std] | |
| pub trait Foo { | |
| fn sum(&self, x: i32, y: i32) -> i32; | |
| } | |
| struct FooInstance; | |
| impl Foo for FooInstance { | |
| fn sum(&self, x: i32, y: i32) -> i32 { | |
| x + y | |
| } | |
| } | |
| struct FooInstance2; | |
| impl Foo for FooInstance2 { | |
| fn sum(&self, x: i32, y: i32) -> i32 { | |
| x + y + 100 | |
| } | |
| } | |
| fn call_sum<T: Foo>(x: T) -> i32 { | |
| x.sum(10, 10) | |
| } | |
| pub fn result() -> i32{ | |
| let f = FooInstance; | |
| let f2 = FooInstance2; | |
| call_sum(f) + call_sum(f2) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment