-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
doc: discuss try! in std::io #12817
doc: discuss try! in std::io #12817
Conversation
- Repurposes `MoveData.assignee_ids` to mean only `=` but not `+=`, so that borrowck effectively classifies all expressions into assignees, uses or both. - Removes two `span_err` in liveness analysis, which are now borrowck's responsibilities. Closes rust-lang#12527.
- Repurposes `MoveData.assignee_ids` to mean only `=` but not `+=`, so that borrowck effectively classifies all expressions into assignees, uses or both. - Removes two `span_err` in liveness analysis, which are now borrowck's responsibilities. Closes rust-lang#12527.
Because explicit pattern matching on `IoResult`s is clumsy when performing | ||
many I/O operations that may not be dependent as in the above example, the | ||
`try!` macro is provided in `std::macros`. This macro yields a value if `Ok` | ||
and immediately returns the error otherwise. |
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.
The title of this section should be enclosed in backticks (to show that the try macro is code). How about wording like this for this paragraph:
Explicit pattern matching on
IoResult
s often gets quite verbose, especially when many I/O operations are being performed. Some examples (like those above) are alleviated with extra methods implemented onIoResult
, but others have more complex interdependencies among each I/O operation.The
try!
macro fromstd::macros
is provided as a method of early-return insideResult
-returning functions. It expands to an early-return onErr
and otherwise unwraps the wrappedOk
value.
Hey @tari, thanks for the PR, but did you mean to close it? (Looks like you may've deleted the branch accidentally?) |
Correct; fumbling with git a bit trying to squash edits (I'm usually a mercurial user). Will open a new PR when I get things sorted out. |
std::macros::try says to refer to std::io for more information. This patch adds an example of try! when doing I/O. Redo of #12817 following some fumbling with git.
…nicola Upgrade to [email protected], add CARGO_WORKSPACE_DIR env var This should make ra's test suite runnable from within `rust-analyzer/rust`. `@cuviper` ran into that when trying to run RA tests from rust CI: rust-lang#99444 (comment)
Don't lint `assertions_on_constants` on any const assertions close rust-lang#12816 close rust-lang#12847 cc rust-lang#12817 ---- changelog: Fix false positives in consts for `assertions_on_constants` and `unnecessary_operation`.
std::macros::try says to refer to std::io for more information. This patch adds an example of try! when doing I/O.