-
Notifications
You must be signed in to change notification settings - Fork 13.3k
std: Second pass stabilization of Result<T, E> #19961
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
Conversation
r? @aturon |
cc @jakub- |
pub struct Item<T> { | ||
opt: Option<T> | ||
} | ||
/// An iterator over the a reference to the `Ok` value of a result. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reads weird. Is that first 'a' needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Reworded slightly with a pushed update.
4956389
to
8605ce2
Compare
@alexcrichton This is only backwards-compatible if the code has specified the |
@tbu- can you elaborate? I'm not sure I understand what you mean sadly :( |
The current signature of
If this is changed to
then the type of the parameter is less constrained. In particular one can see in the pull request you linked that additional type annotations were needed in the tests of this new |
Ah the PR actually recommended a signature like:
which with the default type parameter I believe makes it a backwards-compatible change. |
I actually do not think that it is wise to bake |
@alexcrichton Yeah, you're right, with the default type parameter this looks backwards-compatible. |
std: Second pass stabilization of Result<T, E> Reviewed-by: aturon
This commit, like the second pass of `Option`, largely just stablizes the existing functionality after renaming a few iterators. The specific actions taken were: * The `Ok` and `Err` variants were marked `#[stable]` as the stability inheritance was since removed. * The `as_mut` method is now stable. * The `map` method is now stable * The `map_err` method is now stable * The `iter`, `iter_mut`, and `into_iter` methods now returned structures named after the method of iteration. The methods are also now all stable. * The `and_then` method is now stable. * The `or_else` method is now stable. * The `unwrap` family of functions are now all stable: `unwrap_or`, `unwrap_or_else`, `unwrap`, and `unwrap_err`. There is a possible open extension to `Result::{and, and_then}` to make the return type further generic over `FromError` (as proposed in rust-lang#19078), but this is a backwards compatible change due to the usage of default type parameters, which makes the two functions safe to stabilize now regardless of the outcome of that issue.
8605ce2
to
a71686f
Compare
This commit, like the second pass of `Option`, largely just stablizes the existing functionality after renaming a few iterators. The specific actions taken were: * The `Ok` and `Err` variants were marked `#[stable]` as the stability inheritance was since removed. * The `as_mut` method is now stable. * The `map` method is now stable * The `map_err` method is now stable * The `iter`, `iter_mut`, and `into_iter` methods now returned structures named after the method of iteration. The methods are also now all stable. * The `and_then` method is now stable. * The `or_else` method is now stable. * The `unwrap` family of functions are now all stable: `unwrap_or`, `unwrap_or_else`, `unwrap`, and `unwrap_err`. There is a possible open extension to `Result::{and, and_then}` to make the return type further generic over `FromError` (as proposed in #19078), but this is a backwards compatible change due to the usage of default type parameters, which makes the two functions safe to stabilize now regardless of the outcome of that issue.
This commit, like the second pass of `Option`, largely just stablizes the existing functionality after renaming a few iterators. The specific actions taken were: * The `Ok` and `Err` variants were marked `#[stable]` as the stability inheritance was since removed. * The `as_mut` method is now stable. * The `map` method is now stable * The `map_err` method is now stable * The `iter`, `iter_mut`, and `into_iter` methods now returned structures named after the method of iteration. The methods are also now all stable. * The `and_then` method is now stable. * The `or_else` method is now stable. * The `unwrap` family of functions are now all stable: `unwrap_or`, `unwrap_or_else`, `unwrap`, and `unwrap_err`. There is a possible open extension to `Result::{and, and_then}` to make the return type further generic over `FromError` (as proposed in rust-lang#19078), but this is a backwards compatible change due to the usage of default type parameters, which makes the two functions safe to stabilize now regardless of the outcome of that issue.
This commit, like the second pass of
Option
, largely just stablizes theexisting functionality after renaming a few iterators.
The specific actions taken were:
Ok
andErr
variants were marked#[stable]
as the stabilityinheritance was since removed.
as_mut
method is now stable.map
method is now stablemap_err
method is now stableiter
,iter_mut
, andinto_iter
methods now returned structures namedafter the method of iteration. The methods are also now all stable.
and_then
method is now stable.or_else
method is now stable.unwrap
family of functions are now all stable:unwrap_or
,unwrap_or_else
,unwrap
, andunwrap_err
.There is a possible open extension to
Result::{and, and_then}
to make thereturn type further generic over
FromError
(as proposed in #19078), but thisis a backwards compatible change due to the usage of default type parameters,
which makes the two functions safe to stabilize now regardless of the outcome of
that issue.