@@ -74,7 +74,7 @@ pure fn map_consume<T, U>(+opt: Option<T>, f: fn(+T) -> U) -> Option<U> {
74
74
* As `map`, but consumes the option and gives `f` ownership to avoid
75
75
* copying.
76
76
*/
77
- if opt. is_some ( ) { Some ( f ( option:: unwrap ( move opt) ) ) } else { None }
77
+ if opt. is_some ( ) { Some ( f ( option:: unwrap ( opt) ) ) } else { None }
78
78
}
79
79
80
80
pure fn chain < T , U > ( opt : Option < T > , f : fn ( T ) -> Option < U > ) -> Option < U > {
@@ -112,7 +112,7 @@ pure fn while_some<T>(+x: Option<T>, blk: fn(+T) -> Option<T>) {
112
112
113
113
let mut opt <- x;
114
114
while opt. is_some ( ) {
115
- opt = blk ( unwrap ( move opt) ) ;
115
+ opt = blk ( unwrap ( opt) ) ;
116
116
}
117
117
}
118
118
@@ -160,8 +160,10 @@ pure fn iter_ref<T>(opt: &Option<T>, f: fn(x: &T)) {
160
160
match * opt { None => ( ) , Some ( ref t) => f ( t) }
161
161
}
162
162
163
+ // tjc: shouldn't this be - instead of +?
164
+ // then could get rid of some superfluous moves
163
165
#[ inline( always) ]
164
- pure fn unwrap < T > ( + opt : Option < T > ) -> T {
166
+ pure fn unwrap<T >( - opt: Option <T >) -> T {
165
167
/*!
166
168
* Moves a value out of an option type and returns it.
167
169
*
@@ -184,7 +186,7 @@ fn swap_unwrap<T>(opt: &mut Option<T>) -> T {
184
186
pure fn unwrap_expect<T >( +opt: Option <T >, reason: & str) -> T {
185
187
//! As unwrap, but with a specified failure message.
186
188
if opt. is_none ( ) { fail reason. to_unique ( ) ; }
187
- unwrap ( move opt)
189
+ unwrap ( opt)
188
190
}
189
191
190
192
// Some of these should change to be &Option<T>, some should not. See below.
0 commit comments