Skip to content

Commit 3c6da77

Browse files
committed
avoid unwrap in Option::map_consume implementation
1 parent 65a0125 commit 3c6da77

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libcore/option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub pure fn map_consume<T, U>(opt: Option<T>,
114114
* As `map`, but consumes the option and gives `f` ownership to avoid
115115
* copying.
116116
*/
117-
if opt.is_some() { Some(f(option::unwrap(move opt))) } else { None }
117+
match opt { None => None, Some(v) => Some(f(v)) }
118118
}
119119

120120
pub pure fn chain<T, U>(opt: Option<T>,

0 commit comments

Comments
 (0)