diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-09-15 17:47:39 +0200 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-09-15 17:49:29 +0200 |
| commit | fc0bf125168ec3df75bc57c250a62d3ea225a546 (patch) | |
| tree | 126ff09e1167acfcce1b48ba08b0b21069c05d12 /src/lib | |
| parent | 906f1fc425a827d7bbbb87a6e86ce0aa7faf0bb8 (diff) | |
Make option::get return the option contents by reference
I can't believe this actually works!
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/option.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/option.rs b/src/lib/option.rs index c10c22ae18d..53c19ba8c0a 100644 --- a/src/lib/option.rs +++ b/src/lib/option.rs @@ -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> { |
