about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorBrian J. Burg <burg@cs.washington.edu>2012-11-08 16:25:22 -0800
committerBrian J. Burg <burg@cs.washington.edu>2012-11-08 16:25:22 -0800
commita5718ba377fbc915618062d7562229a4eb754c9f (patch)
tree24d677437c4617132003a38633c2034c1f90c7b4 /src/libcore
parent17020244e476b5a40b0d2eb576574a0cf5543d80 (diff)
Change option::expect to not require a Copy bound, and move instead.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/option.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index 3b1d2079800..0bb3262e569 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -85,16 +85,17 @@ pub pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T {
     }
 }
 
-pub pure fn expect<T: Copy>(opt: Option<T>, reason: ~str) -> T {
+pub pure fn expect<T>(opt: Option<T>, reason: ~str) -> T {
     /*!
-     * Gets the value out of an option, printing a specified message on
-     * failure
+     * Gets the value out of an option without copying, printing a 
+     * specified message on failure.
      *
      * # Failure
      *
      * Fails if the value equals `none`
      */
-    match opt { Some(copy x) => x, None => fail reason }
+    if opt.is_some() { move option::unwrap(move opt) }
+    else { fail reason }
 }
 
 pub pure fn map<T, U>(opt: &Option<T>, f: fn(x: &T) -> U) -> Option<U> {