Skip to content

Commit 255b02c

Browse files
author
Daniel Patterson
committed
---
yaml --- r: 23338 b: refs/heads/master c: 62ea688 h: refs/heads/master v: v3
1 parent 88f08f3 commit 255b02c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
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: c321cdbac6c4ddd9fedb89e1cc8bce1569347c5a
2+
refs/heads/master: 62ea688e508fdd265eff5207acf2191cc2a715e8
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/option.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ pure fn chain_ref<T, U>(opt: &option<T>,
9393
match *opt { some(ref x) => f(x), none => none }
9494
}
9595

96+
pure fn or<T>(+opta: option<T>, +optb: option<T>) -> option<T> {
97+
/*!
98+
* Returns the leftmost some() value, or none if both are none.
99+
*/
100+
match opta {
101+
some(_) => opta,
102+
_ => optb
103+
}
104+
}
105+
96106
#[inline(always)]
97107
pure fn while_some<T>(+x: option<T>, blk: fn(+T) -> option<T>) {
98108
//! Applies a function zero or more times until the result is none.

0 commit comments

Comments
 (0)