enum maybe { just(T), nothing } impl methods for maybe { fn ~[](idx: uint) -> T { alt self { just(t) { t } nothing { fail; } } } }