Skip to content

Fix Result::chain, Result::chain_err to not require Copy bounds. #3954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ pub pure fn to_either<T: Copy, U: Copy>(res: &Result<U, T>)
* ok(parse_bytes(buf))
* }
*/
pub fn chain<T, U: Copy, V: Copy>(res: Result<T, V>, op: fn(t: T)
pub fn chain<T, U, V>(res: Result<T, V>, op: fn(t: T)
-> Result<U, V>) -> Result<U, V> {
match move res {
Ok(move t) => op(move t),
Err(move e) => Err(e)
Err(move e) => Err(move e)
}
}

Expand All @@ -119,13 +119,13 @@ pub fn chain<T, U: Copy, V: Copy>(res: Result<T, V>, op: fn(t: T)
* immediately returned. This function can be used to pass through a
* successful result while handling an error.
*/
pub fn chain_err<T: Copy, U: Copy, V: Copy>(
pub fn chain_err<T, U, V>(
res: Result<T, V>,
op: fn(t: V) -> Result<T, U>)
-> Result<T, U> {
match move res {
Ok(move t) => Ok(t),
Err(move v) => op(v)
Ok(move t) => Ok(move t),
Err(move v) => op(move v)
}
}

Expand Down