diff options
| author | bors <bors@rust-lang.org> | 2013-08-07 13:23:07 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-07 13:23:07 -0700 |
| commit | 98ec79c9576052d9fededd3b72b47d387c1c455d (patch) | |
| tree | 1bb89d47e3668a024cc4bc9d252991ef78d1e4d5 /src/libstd/iterator.rs | |
| parent | cdba212e7299f6bda752abbb9f887c51d96f7586 (diff) | |
| parent | 19e17f54a02e484f1ab4fd809caa0aaf3f3d14bc (diff) | |
| download | rust-98ec79c9576052d9fededd3b72b47d387c1c455d.tar.gz rust-98ec79c9576052d9fededd3b72b47d387c1c455d.zip | |
auto merge of #8294 : erickt/rust/map-move, r=bblum
According to #7887, we've decided to use the syntax of `fn map<U>(f: &fn(&T) -> U) -> U`, which passes a reference to the closure, and to `fn map_move<U>(f: &fn(T) -> U) -> U` which moves the value into the closure. This PR adds these `.map_move()` functions to `Option` and `Result`. In addition, it has these other minor features: * Replaces a couple uses of `option.get()`, `result.get()`, and `result.get_err()` with `option.unwrap()`, `result.unwrap()`, and `result.unwrap_err()`. (See #8268 and #8288 for a more thorough adaptation of this functionality. * Removes `option.take_map()` and `option.take_map_default()`. These two functions can be easily written as `.take().map_move(...)`. * Adds a better error message to `result.unwrap()` and `result.unwrap_err()`.
Diffstat (limited to 'src/libstd/iterator.rs')
| -rw-r--r-- | src/libstd/iterator.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs index 1be398966bb..29f54bd10fb 100644 --- a/src/libstd/iterator.rs +++ b/src/libstd/iterator.rs @@ -674,7 +674,7 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T { Some((y, y_val)) } } - }).map_consume(|(x, _)| x) + }).map_move(|(x, _)| x) } #[inline] @@ -689,7 +689,7 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T { Some((y, y_val)) } } - }).map_consume(|(x, _)| x) + }).map_move(|(x, _)| x) } } @@ -1382,7 +1382,7 @@ impl<'self, A, T: Iterator<A>, B, U: Iterator<B>> Iterator<B> for return Some(x) } } - match self.iter.next().map_consume(|x| (self.f)(x)) { + match self.iter.next().map_move(|x| (self.f)(x)) { None => return self.backiter.chain_mut_ref(|it| it.next()), next => self.frontiter = next, } @@ -1414,7 +1414,7 @@ impl<'self, y => return y } } - match self.iter.next_back().map_consume(|x| (self.f)(x)) { + match self.iter.next_back().map_move(|x| (self.f)(x)) { None => return self.frontiter.chain_mut_ref(|it| it.next_back()), next => self.backiter = next, } |
