parent
5a8ba073bc
commit
1ab914df1d
@ -119,11 +119,9 @@ pub enum Option<T> {
|
||||
* 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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,11 +105,9 @@ pub enum Result<T, U> {
|
||||
*/
|
||||
pub fn chain<T, U: Copy, V: Copy>(res: Result<T, V>, op: fn(t: T)
|
||||
-> Result<U, V>) -> Result<U, V> {
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user