Skip to content

Instantly share code, notes, and snippets.

@erickt
Created April 19, 2012 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erickt/2421363 to your computer and use it in GitHub Desktop.
Save erickt/2421363 to your computer and use it in GitHub Desktop.
#[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 }
}
#[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) }
}
#[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) }
}
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