Skip to content

Add option.map_move and result.map_move#8294

Closed
erickt wants to merge 4 commits into
rust-lang:masterfrom
erickt:map-move
Closed

Add option.map_move and result.map_move#8294
erickt wants to merge 4 commits into
rust-lang:masterfrom
erickt:map-move

Conversation

@erickt

@erickt erickt commented Aug 5, 2013

Copy link
Copy Markdown
Contributor

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:

@erickt

erickt commented Aug 5, 2013

Copy link
Copy Markdown
Contributor Author

Feel free to wait until #8288 builds before reviewing, as this PR will probably have a merge conflict with that PR.

@bblum

bblum commented Aug 5, 2013

Copy link
Copy Markdown
Contributor

Looks good.

@erickt

erickt commented Aug 7, 2013

Copy link
Copy Markdown
Contributor Author

@bblum: updated to be rebased onto HEAD! Can you re-review?

bors added a commit that referenced this pull request Aug 7, 2013
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()`.
@bors bors closed this Aug 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants