10 lines
188 B
Rust
10 lines
188 B
Rust
|
enum maybe<T> { just(T), nothing }
|
||
|
|
||
|
impl methods<T:copy> for maybe<T> {
|
||
|
fn [](idx: uint) -> T {
|
||
|
alt self {
|
||
|
just(t) { t }
|
||
|
nothing { fail; }
|
||
|
}
|
||
|
}
|
||
|
}
|