-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Made std::option
and std::result
more similar
#10119
Conversation
I think that we shouldn't take renaming of option methods very lightly any more. Has the transition from Also in the future, I know it's tough and I always forget to do this as well, but it's always nice for reviewing if reorganization of code is separated (by commits) from refactoring/renaming and additions to code. It's tough to see here that the only method on option that changed is Other than that though, I like how this pretty much makes the apis of option and result the same. I'm in favor of all the changes to Result, I think that I'd r+ a pull request which didn't modify |
We previously came to the consensus that using |
I updated the PR to not include the |
I talked with @Kimundi on IRC, and I like where this is going, but I'm personally a little uneasy about all of the |
Cleaned up the source in a few places Renamed `map_move` to `map`, removed other `map` methods Added `as_ref` and `as_mut` adapters to `Result` Added `fmt::Default` impl
Made both types implement more standard traits in a nicer way Derived more traits
@alexcrichton: A buildbot failed with a runtime abort, so I used the additional time to update this PR with as much cleanup as possible without touching the |
This takes the last reforms on the `Option` type and applies them to `Result` too. For that, I reordered and grouped the functions in both modules, and also did some refactorings: - Added `as_ref` and `as_mut` adapters to `Result`. - Renamed `Result::map_move` to `Result::map` (same for `_err` variant), deleted other map functions. - Made the `.expect()` methods be generic over anything you can fail with. - Updated some doc comments to the line doc comment style - Cleaned up and extended standard trait implementations on `Option` and `Result` - Removed legacy implementations in the `option` and `result` module
…Frednet fix codeblocks in the document While I've looked into rust-lang/rust-clippy#9990, I found broken code blocks in the document. This patch not only improves visibility, but also fixes a potential bug. When a lint description ends with code block, the string will have three backquotes at the end. Since the current implementation prints the default value immediately after that, the markdown renderer is unable to properly close the code block. e.g. `arithmetic_side_effects`, we can see code block is not rendered properly, and (I think) it's bit hard to understand what ``"defaults to `[]`"`` is meant.  In this PR, it will be rendered as:  changelog: none r? `@xFrednet`
This takes the last reforms on the
Option
type and applies them toResult
too. For that, I reordered and grouped the functions in both modules, and also did some refactorings:as_ref
andas_mut
adapters toResult
.Result::map_move
toResult::map
(same for_err
variant), deleted other map functions..expect()
methods be generic over anything you canfail with.
Option
andResult
option
andresult
module