Skip to content

Commit

Permalink
std: removed option.take_map{,_default}
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed Aug 7, 2013
1 parent 1e49081 commit 19e17f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
14 changes: 0 additions & 14 deletions src/libstd/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,6 @@ impl<T> Option<T> {
util::replace(self, None)
}

/// As `map_move`, but swaps a None into the original option rather
/// than consuming it by-value.
#[inline]
pub fn take_map<U>(&mut self, blk: &fn(T) -> U) -> Option<U> {
self.take().map_move(blk)
}

/// As `map_move_default`, but swaps a None into the original option
/// rather than consuming it by-value.
#[inline]
pub fn take_map_default<U> (&mut self, def: U, blk: &fn(T) -> U) -> U {
self.take().map_move_default(def, blk)
}

/// Apply a function to the contained value or do nothing.
/// Returns true if the contained value was mutated.
pub fn mutate(&mut self, f: &fn(T) -> T) -> bool {
Expand Down
10 changes: 5 additions & 5 deletions src/libstd/rt/kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ impl KillHandle {
others.take().map_move_default(true, |f| f()) && {
let mut inner = this.take().unwrap();
(!inner.any_child_failed) &&
inner.child_tombstones.take_map_default(true, |f| f())
inner.child_tombstones.take().map_move_default(true, |f| f())
}
}
}
Expand Down Expand Up @@ -493,15 +493,15 @@ impl Death {
{ use util; util::ignore(group); }

// Step 1. Decide if we need to collect child failures synchronously.
do self.on_exit.take_map |on_exit| {
do self.on_exit.take().map_move |on_exit| {
if success {
// We succeeded, but our children might not. Need to wait for them.
let mut inner = self.kill_handle.take_unwrap().unwrap();
if inner.any_child_failed {
success = false;
} else {
// Lockless access to tombstones protected by unwrap barrier.
success = inner.child_tombstones.take_map_default(true, |f| f());
success = inner.child_tombstones.take().map_move_default(true, |f| f());
}
}
on_exit(success);
Expand All @@ -510,12 +510,12 @@ impl Death {
// Step 2. Possibly alert possibly-watching parent to failure status.
// Note that as soon as parent_handle goes out of scope, the parent
// can successfully unwrap its handle and collect our reported status.
do self.watching_parent.take_map |mut parent_handle| {
do self.watching_parent.take().map_move |mut parent_handle| {
if success {
// Our handle might be None if we had an exit callback, and
// already unwrapped it. But 'success' being true means no
// child failed, so there's nothing to do (see below case).
do self.kill_handle.take_map |own_handle| {
do self.kill_handle.take().map_move |own_handle| {
own_handle.reparent_children_to(&mut parent_handle);
};
} else {
Expand Down

5 comments on commit 19e17f5

@bors
Copy link
Contributor

@bors bors commented on 19e17f5 Aug 7, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from bblum
at erickt@19e17f5

@bors
Copy link
Contributor

@bors bors commented on 19e17f5 Aug 7, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging erickt/rust/map-move = 19e17f5 into auto

@bors
Copy link
Contributor

@bors bors commented on 19e17f5 Aug 7, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erickt/rust/map-move = 19e17f5 merged ok, testing candidate = 98ec79c

@bors
Copy link
Contributor

@bors bors commented on 19e17f5 Aug 7, 2013

@bors
Copy link
Contributor

@bors bors commented on 19e17f5 Aug 7, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 98ec79c

Please sign in to comment.