Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking Issue for Result<Option> and Option<Result> Conversion #47338
Comments
Mark-Simulacrum
added
the
C-tracking-issue
label
Jan 10, 2018
alexcrichton
added
T-libs
B-unstable
labels
Jan 11, 2018
This comment has been minimized.
This comment has been minimized.
epage
commented
Jan 25, 2018
|
A nice-to-have but not required would be someway for us to make this general so it can be used with other types, for example with I saw |
This comment has been minimized.
This comment has been minimized.
|
Does it make sense to implement |
This comment has been minimized.
This comment has been minimized.
|
Then perhaps |
This comment has been minimized.
This comment has been minimized.
|
Nice addition |
This comment has been minimized.
This comment has been minimized.
|
Conversions for |
This comment has been minimized.
This comment has been minimized.
I don't think so. The code below doesn't compile. #![feature(catch_expr)]
fn transpose<T, E1, E2>(x: Result<Result<T, E1>, E2>) -> Result<Result<T, E2>, E1> {
do catch {
Ok(x??)
}
} |
This comment has been minimized.
This comment has been minimized.
|
@qnighy that's because you're missing |
This comment has been minimized.
This comment has been minimized.
|
@clarcharr perhaps are we talking about different functions? My understanding is that |
This comment has been minimized.
This comment has been minimized.
goose121
commented
Oct 19, 2018
Also, is it just me, or does |
This comment has been minimized.
This comment has been minimized.
mexus
commented
Dec 24, 2018
|
Hi everyone, is there anything which prevents this useful feature from being stabilized? I've come here from a link from the docs about the Thanks :) |
This comment has been minimized.
This comment has been minimized.
|
Ping @rust-lang/libs this has been sitting around for a year now and I don't expect we'll see much more experimentation with it if folks have to rely on a nightly feature. What would y'all think about stabilizing? |
This comment has been minimized.
This comment has been minimized.
|
Sounds ok to me. @rfcbot fcp merge This issue tracks these methods: impl<T, E> Option<Result<T, E>> {
pub fn transpose(self) -> Result<Option<T>, E> {…}
}
impl<T, E> Result<Option<T>, E> {
pub fn transpose(self) -> Option<Result<T, E>> {…}
} |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Dec 26, 2018
•
|
Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
rfcbot
added
proposed-final-comment-period
disposition-merge
labels
Dec 26, 2018
This comment has been minimized.
This comment has been minimized.
traviscross
commented
Dec 30, 2018
|
This will be an improvement under any name, but here's an argument for stabilizing this as
The first point feels particularly compelling. This method will be used in all kinds of code. People reviewing code dealing with matrices will strongly expect |
This comment has been minimized.
This comment has been minimized.
|
The term |
This comment has been minimized.
This comment has been minimized.
|
Perhaps going with |
This comment has been minimized.
This comment has been minimized.
traviscross
commented
Dec 30, 2018
|
Agreed those would be better than The semantic argument for Perhaps we should consider the merits of |
rfcbot
added
the
final-comment-period
label
Jan 2, 2019
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jan 2, 2019
|
|
rfcbot
removed
the
proposed-final-comment-period
label
Jan 2, 2019
This comment has been minimized.
This comment has been minimized.
troiganto
commented
Jan 10, 2019
|
As someone who's already well aware of these two functions, I would not mind the name However, it has one disadvantage that should be considered: people will likely have a hard time searching for functions named Maybe it might be better to pick a slightly ambiguous name like |
This comment has been minimized.
This comment has been minimized.
epage
commented
Jan 10, 2019
|
RE My main concern is discoverability. Once you get past the "how will people think to see if this exists" (maybe a help in a compiler error?), there is the "how will it stand out". Personally, I gloss over weird names in libraries (e.g. |
This comment has been minimized.
This comment has been minimized.
8573
commented
Jan 10, 2019
|
For discoverability, could the documentation for the |
This comment has been minimized.
This comment has been minimized.
traviscross
commented
Jan 11, 2019
|
Regarding discoverability, it seems unlikely that anyone will first find these methods by name regardless of what we call them. There's just not a common name for this operation. People will find these 1) by searching the web for "convert Rust Result Option to Option Result" or "chain Rust Result methods with Option" or other variations, 2) by scanning the Option or Result documentation for a method of the correct signature, or 3) by being introduced to the concept through the book, through blogs, or through seeing discussions such as this one. Regarding matrices, as soon as you have a function that returns |
rfcbot
added
the
finished-final-comment-period
label
Jan 12, 2019
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jan 12, 2019
|
The final comment period, with a disposition to merge, as per the review above, is now complete. |
rfcbot
removed
the
final-comment-period
label
Jan 12, 2019
Centril
self-assigned this
Jan 13, 2019
bors
added a commit
that referenced
this issue
Jan 13, 2019
bors
closed this
in
#57567
Jan 13, 2019
This comment has been minimized.
This comment has been minimized.
Stargateur
commented
Feb 1, 2019
|
Someone proposed to have something close to Hoogle for search this kind of feature. |
cramertj commentedJan 10, 2018
Initial implementation in #47193.