Skip to content

Commit cb4f6fb

Browse files
committed
---
yaml --- r: 64497 b: refs/heads/snap-stage3 c: 5a9b33a h: refs/heads/master i: 64495: 36a5c89 v: v3
1 parent 95f0de2 commit cb4f6fb

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 96c1082f0fdbbe5258cfc1dc37f83052feff8421
4+
refs/heads/snap-stage3: 5a9b33a76d76a77d2ced1c2430a25faa0f284071
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libstd/option.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,20 @@ impl<T> Option<T> {
200200
match self { None => def, Some(v) => f(v) }
201201
}
202202

203+
/// As `map_consume`, but swaps a None into the original option rather
204+
/// than consuming it by-value.
205+
#[inline]
206+
pub fn take_map<U>(&mut self, blk: &fn(T) -> U) -> Option<U> {
207+
util::replace(self, None).map_consume(blk)
208+
}
209+
210+
/// As `map_consume_default`, but swaps a None into the original option
211+
/// rather than consuming it by-value.
212+
#[inline]
213+
pub fn take_map_default<U> (&mut self, def: U, blk: &fn(T) -> U) -> U {
214+
util::replace(self, None).map_consume_default(def, blk)
215+
}
216+
203217
/// Apply a function to the contained value or do nothing
204218
pub fn mutate(&mut self, f: &fn(T) -> T) {
205219
if self.is_some() {

0 commit comments

Comments
 (0)