avoid unwrap in Option::map_consume implementation

This commit is contained in:
Daniel Micay 2013-01-13 01:38:20 -05:00
parent 65a0125f7f
commit 3c6da7761b

View File

@ -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>,