-
-
Save erickt/2421363 to your computer and use it in GitHub Desktop.
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
#[link(name = "a", vers = "0.1")]; | |
#[crate_type = "lib"]; | |
iface to_str { | |
fn to_str() -> str; | |
} | |
impl of to_str for str { | |
fn to_str() -> str { self } | |
} |
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
#[link(name = "b", vers = "0.1")]; | |
#[crate_type = "lib"]; | |
use a; | |
import a::to_str; | |
impl of to_str for int { | |
fn to_str() -> str { #fmt("%?", self) } | |
} |
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
#[link(name = "c", vers = "0.1")]; | |
#[crate_type = "lib"]; | |
use a; | |
import a::to_str; | |
impl of to_str for bool { | |
fn to_str() -> str { #fmt("%b", self) } | |
} |
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
use a; | |
use b; | |
use c; | |
import b::to_str; | |
import c::to_str; | |
fn main() { | |
io::println("foo".to_str()); | |
io::println(1.to_str()); | |
io::println(true.to_str()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment