Skip to content

Commit fc0bf12

Browse files
committed
Make option::get return the option contents by reference
I can't believe this actually works!
1 parent 906f1fc commit fc0bf12

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/lib/option.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
tag t<@T> { none; some(T); }
44

5-
fn get<@T>(opt: t<T>) -> T {
6-
alt opt { some(x) { x } none. { fail "option none" } }
5+
fn get<@T>(opt: t<T>) -> &T {
6+
alt opt { some(x) { ret x; } none. { fail "option none"; } }
77
}
88

99
fn map<@T, @U>(f: block(T) -> U, opt: t<T>) -> t<U> {

0 commit comments

Comments
 (0)