Skip to content

Commit c371f13

Browse files
committed
---
yaml --- r: 34659 b: refs/heads/master c: 1ab914d h: refs/heads/master i: 34657: 93ff8eb 34655: 57e2c10 v: v3
1 parent 71880ab commit c371f13

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 5a8ba073bcd6ee6fd34ff545845a746cddc4904f
2+
refs/heads/master: 1ab914df1d24f6c198bb7b1e01a4cf0050d179c8
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024

trunk/src/libcore/option.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,9 @@ pub pure fn chain<T, U>(opt: Option<T>,
119119
* function that returns an option.
120120
*/
121121

122-
// XXX write with move match
123-
if opt.is_some() {
124-
f(unwrap(opt))
125-
} else {
126-
None
122+
match move opt {
123+
Some(move t) => f(t),
124+
None => None
127125
}
128126
}
129127

trunk/src/libcore/result.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,9 @@ pub pure fn to_either<T: Copy, U: Copy>(res: &Result<U, T>)
105105
*/
106106
pub fn chain<T, U: Copy, V: Copy>(res: Result<T, V>, op: fn(t: T)
107107
-> Result<U, V>) -> Result<U, V> {
108-
// XXX: Should be writable with move + match
109-
if res.is_ok() {
110-
op(unwrap(res))
111-
} else {
112-
Err(unwrap_err(res))
108+
match move res {
109+
Ok(move t) => op(t),
110+
Err(move e) => Err(e)
113111
}
114112
}
115113

0 commit comments

Comments
 (0)