Skip to content

Commit 007e7ba

Browse files
committed
---
yaml --- r: 38517 b: refs/heads/incoming c: 1ab914d h: refs/heads/master i: 38515: b261f11 v: v3
1 parent d3c35cf commit 007e7ba

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
@@ -6,7 +6,7 @@ refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
9-
refs/heads/incoming: 5a8ba073bcd6ee6fd34ff545845a746cddc4904f
9+
refs/heads/incoming: 1ab914df1d24f6c198bb7b1e01a4cf0050d179c8
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/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

branches/incoming/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)