#[link(name = "static_methods_crate", vers = "0.1")]; #[crate_type = "lib"]; export read, readMaybe; trait read { static fn readMaybe(s: ~str) -> option; } impl int: read { static fn readMaybe(s: ~str) -> option { int::from_str(s) } } impl bool: read { static fn readMaybe(s: ~str) -> option { match s { ~"true" => some(true), ~"false" => some(false), _ => none } } } fn read(s: ~str) -> T { match readMaybe(s) { some(x) => x, _ => fail ~"read failed!" } }