Skip to content

Commit 9928eb4

Browse files
committed
---
yaml --- r: 35852 b: refs/heads/try2 c: 1ab914d h: refs/heads/master v: v3
1 parent 81c7494 commit 9928eb4

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 5a8ba073bcd6ee6fd34ff545845a746cddc4904f
8+
refs/heads/try2: 1ab914df1d24f6c198bb7b1e01a4cf0050d179c8
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

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