Skip to content

Instantly share code, notes, and snippets.

@lkuper
Created July 6, 2012 23:17
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/3063336 to your computer and use it in GitHub Desktop.
Save lkuper/3063336 to your computer and use it in GitHub Desktop.
iface from_string {
fn from_string(s: str) -> self;
}
impl of from_string for int {
fn from_string(s: str) -> int {
let o = int::from_str(s);
alt o {
some(i) { i }
none { fail; }
}
}
}
fn main() {
log(error, 2.from_string("3"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment