Uh oh!
There was an error while loading. Please reload this page.
Add Result::cloned{,_err} and Result::copied{,_err} - #63166
Conversation
rust-highfive
commented
Jul 31, 2019
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @sfackler (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| /// assert_eq!(copied, Ok(12)); | ||
| /// ``` | ||
| #[unstable(feature = "result_copied", reason = "newly added", issue = "63168")] | ||
| pub fn copied(self) -> Result<T, E> { |
There was a problem hiding this comment.
My gut tells me that this should be called copied_ok so that there can be a copied that will copy both sides in one go.
There was a problem hiding this comment.
I'm not entirely sure about the usefulness. From my experience, I usually only need copied_ok and cloned_ok. But indeed having copied, copied_ok, and copied_err is more consistent. I've added them in the update.
… to copy/clone both Ok and Err
rust-highfive
commented
Jul 31, 2019
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
sfackler
commented
Aug 1, 2019
Is there any context in which cloned_err would be used? |
This reverts commit 6c13081.
ksqsf
commented
Aug 1, 2019
@sfackler Actually I didn't think of a single use case. I'd be more than happy if we could remove Introducing |
rust-highfive
commented
Aug 1, 2019
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
rust-highfive
commented
Aug 1, 2019
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
sfackler
commented
Aug 2, 2019
Yeah, let's remove the error variants. Come to think of it, I'm having a hard time thinking of a context where I had a |
ksqsf
commented
Aug 2, 2019
My use case for |
wirelessringo
commented
Aug 9, 2019
Ping from triage @sfackler any updates on this? Thanks. |
ksqsf
commented
Aug 13, 2019
ping @sfackler |
totsteps
commented
Aug 20, 2019
Second ping from triage, @sfackler can you please review this. Thanks |
Alexendoo
commented
Aug 28, 2019
Ping from triage, requesting a review @rust-lang/libs |
@ksqsf can you resolve the |
ksqsf
commented
Sep 1, 2019
@Dylan-DPC Hi, I just ran the tests locally ( |
alexcrichton
commented
Sep 3, 2019
@bors: r+ This looks good to me to add as unstable. I added some explicit questions to the tracking issue to make sure we get back to them by stabilization. |
bors
commented
Sep 3, 2019
📌 Commit 61e5286 has been approved by |
Add Result::cloned{,_err} and Result::copied{,_err}
This is a little nice addition to `Result`.
1. I'm not sure how useful are `cloned_err` and `copied_err`, but for the sake of completeness they are here.
2. Naming is similar to `map`/`map_err`. I thought about naming `cloned` as `cloned_ok` and add another method called `cloned` that clones both Ok and Err, but `cloned_ok` should be more prevalent than `cloned_both`.Rollup of 10 pull requests Successful merges: - #63166 (Add Result::cloned{,_err} and Result::copied{,_err}) - #63930 (Account for doc comments coming from proc macros without spans) - #63985 (Stabilize pin_into_inner in 1.39.0) - #64023 (libstd fuchsia fixes) - #64030 (Fix unlock ordering in SGX synchronization primitives) - #64041 (use TokenStream rather than &[TokenTree] for built-in macros) - #64043 (Add some more tests for underscore imports) - #64092 (Update xLTO compatibility table in rustc book.) - #64120 (Move path parsing earlier) - #64123 (Added warning around code with reference to uninit bytes) Failed merges: r? @ghost
bors
commented
Sep 4, 2019
Add Result::cloned{,_err} and Result::copied{,_err}
This is a little nice addition to `Result`.
1. I'm not sure how useful are `cloned_err` and `copied_err`, but for the sake of completeness they are here.
2. Naming is similar to `map`/`map_err`. I thought about naming `cloned` as `cloned_ok` and add another method called `cloned` that clones both Ok and Err, but `cloned_ok` should be more prevalent than `cloned_both`.bors
commented
Sep 4, 2019
☀️ Test successful - checks-azure |
This is a little nice addition to
Result.cloned_errandcopied_err, but for the sake of completeness they are here.map/map_err. I thought about namingclonedascloned_okand add another method calledclonedthat clones both Ok and Err, butcloned_okshould be more prevalent thancloned_both.