Skip to content

Instantly share code, notes, and snippets.

@lkuper
Created January 2, 2014 05:06
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 lkuper/8215298 to your computer and use it in GitHub Desktop.
Save lkuper/8215298 to your computer and use it in GitHub Desktop.
trait Printable {
fn print(&self) { println!("{:?}", *self) }
}
impl Printable for int {}
impl Printable for ~str {
fn print(&self) { println(*self) }
}
impl Printable for bool {}
impl Printable for float {}
fn main() {
1.print();
(~"foo").print();
true.print();
3.14159.print();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment