We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1702024 commit a5718baCopy full SHA for a5718ba
src/libcore/option.rs
@@ -85,16 +85,17 @@ pub pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T {
85
}
86
87
88
-pub pure fn expect<T: Copy>(opt: Option<T>, reason: ~str) -> T {
+pub pure fn expect<T>(opt: Option<T>, reason: ~str) -> T {
89
/*!
90
- * Gets the value out of an option, printing a specified message on
91
- * failure
+ * Gets the value out of an option without copying, printing a
+ * specified message on failure.
92
*
93
* # Failure
94
95
* Fails if the value equals `none`
96
*/
97
- match opt { Some(copy x) => x, None => fail reason }
+ if opt.is_some() { move option::unwrap(move opt) }
98
+ else { fail reason }
99
100
101
pub pure fn map<T, U>(opt: &Option<T>, f: fn(x: &T) -> U) -> Option<U> {
0 commit comments