diff --git a/src/libcore/option.rs b/src/libcore/option.rs index c60b7b401cc8..e970f00c5fbb 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -119,11 +119,9 @@ pub pure fn chain(opt: Option, * function that returns an option. */ - // XXX write with move match - if opt.is_some() { - f(unwrap(opt)) - } else { - None + match move opt { + Some(move t) => f(t), + None => None } } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 39fae8905f92..611d62394357 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -105,11 +105,9 @@ pub pure fn to_either(res: &Result) */ pub fn chain(res: Result, op: fn(t: T) -> Result) -> Result { - // XXX: Should be writable with move + match - if res.is_ok() { - op(unwrap(res)) - } else { - Err(unwrap_err(res)) + match move res { + Ok(move t) => op(t), + Err(move e) => Err(e) } }