avoid unwrap in Option::map_consume implementation
This commit is contained in:
parent
65a0125f7f
commit
3c6da7761b
@ -114,7 +114,7 @@ pub enum Option<T> {
|
||||
* As `map`, but consumes the option and gives `f` ownership to avoid
|
||||
* copying.
|
||||
*/
|
||||
if opt.is_some() { Some(f(option::unwrap(move opt))) } else { None }
|
||||
match opt { None => None, Some(v) => Some(f(v)) }
|
||||
}
|
||||
|
||||
pub pure fn chain<T, U>(opt: Option<T>,
|
||||
|
Loading…
Reference in New Issue
Block a user