Make option::get return the option contents by reference
I can't believe this actually works!
This commit is contained in:
parent
906f1fc425
commit
fc0bf12516
@ -2,8 +2,8 @@
|
||||
|
||||
tag t<@T> { none; some(T); }
|
||||
|
||||
fn get<@T>(opt: t<T>) -> T {
|
||||
alt opt { some(x) { x } none. { fail "option none" } }
|
||||
fn get<@T>(opt: t<T>) -> &T {
|
||||
alt opt { some(x) { ret x; } none. { fail "option none"; } }
|
||||
}
|
||||
|
||||
fn map<@T, @U>(f: block(T) -> U, opt: t<T>) -> t<U> {
|
||||
|
Loading…
Reference in New Issue
Block a user