-
Notifications
You must be signed in to change notification settings - Fork 13.3k
libstd: replace all try!
with ?
in documentation examples
#38648
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
libstd: replace all try!
with ?
in documentation examples
#38648
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (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. |
/cc @rust-lang/docs , I would like more than one person to review this PR, as it's very long and tedious, which means that we're likely to miss something. |
@@ -205,16 +205,15 @@ | |||
//! | |||
//! Last, but certainly not least, is [`io::Result`]. This type is used | |||
//! as the return type of many `std::io` functions that can cause an error, and | |||
//! can be returned from your own functions as well. Many of the examples in this | |||
//! module use the [`try!`] macro: | |||
//! can be returned from your own functions as well. | |||
//! |
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.
Why not replace Many of the examples in this module use the [try!
] macro with Many of the examples in this module use the [?
operator] (and link to the Syntax Index, probably)?
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.
I don't think that information is really relevant in this module documentation, but I'd be happy to add what you suggested if others think the same. @steveklabnik?
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.
I don't think that documenting try!
or ?
is needed here, but I don't feel strongly.
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.
My inclination is to say that this PR should be about a fairly mechanical translation, so keeping it here is fine.
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.
Done!
I'd suggest manually converting many of the multi-line |
@Stebalien I started doing that but found many cases in which I'm not sure if a single line would be clearer for the reader (I personally would write most of these in a single line in my code). For example, what do you (and others as well) think about converting these 2 cases into single lines:
-> and
-> |
I tend to generally write them as two lines. That said, I think it's best to not mess too much with the formatting of the examples here, and just worry about the transformation. So let's Thank you! @bors: r+ |
As someone new to the syntax, I like the decision to keep things unchained for these examples. It seems clearer visually, given the context. Looks good @utkarshkukreti! |
@@ -250,7 +250,7 @@ | |||
//! [`println!`]: ../macro.println.html | |||
//! [`Lines`]: struct.Lines.html | |||
//! [`io::Result`]: type.Result.html | |||
//! [`try!`]: ../macro.try.html | |||
//! [`?` operator]: ../../book/syntax-index.html |
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.
its sort of a shame that one cannot link right to the ?
operator within the index, but AFAICT there is no anchor for it specifically. (You could link to https://doc.rust-lang.org/stable/book/syntax-index.html#operators-and-symbols but I'm not sure if that pays off.)
r=me, in case you still wanted a secondary reviewer @steveklabnik |
☔ The latest upstream changes (presumably #39176) made this pull request unmergeable. Please resolve the merge conflicts. |
It looks like the bors approval didn't go through for this PR for some reason (hence it not being merged yet). @utkarshkukreti If you get some time to address the merge conflicts, we can try again. Sorry about that |
17575ae
to
19724d3
Compare
@frewsxcv rebased! |
Thanks! @bors r=pnkfelix,steveklabnik,frewsxcvx |
📌 Commit 19724d3 has been approved by |
…tation-examples, r=pnkfelix,steveklabnik,frewsxcvx libstd: replace all `try!` with `?` in documentation examples See #38644. For the record, I used the following Perl one-liner and then manually fixed a couple of things it got wrong: $ perl -p -i -e 's#(///.*)try!\((.*)\)#$1$2?#' src/libstd/**/*.rs
☀️ Test successful - status-appveyor, status-travis |
See #38644.
For the record, I used the following Perl one-liner and then manually fixed a couple of things it got wrong: