Skip to content
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

Closed
wants to merge 3 commits into from
Closed

doc: discuss try! in std::io #12817

wants to merge 3 commits into from

Conversation

tari
Copy link
Contributor

@tari tari commented Mar 10, 2014

std::macros::try says to refer to std::io for more information. This patch adds an example of try! when doing I/O.

edwardw and others added 2 commits March 9, 2014 23:23
- 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.
Copy link
Member

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 IoResults often gets quite verbose, especially when many I/O operations are being performed. Some examples (like those above) are alleviated with extra methods implemented on IoResult, but others have more complex interdependencies among each I/O operation.

The try! macro from std::macros is provided as a method of early-return inside Result-returning functions. It expands to an early-return on Err and otherwise unwraps the wrapped Ok value.

@tari tari closed this Mar 10, 2014
@tari tari deleted the io-docs-try branch March 10, 2014 23:02
@tari tari restored the io-docs-try branch March 10, 2014 23:03
@tari tari deleted the io-docs-try branch March 10, 2014 23:04
@huonw
Copy link
Member

huonw commented Mar 10, 2014

Hey @tari, thanks for the PR, but did you mean to close it? (Looks like you may've deleted the branch accidentally?)

@tari
Copy link
Contributor Author

tari commented Mar 10, 2014

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.

@tari tari reopened this Mar 10, 2014
@tari tari closed this Mar 10, 2014
bors added a commit that referenced this pull request Mar 11, 2014
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.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 25, 2022
…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)
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jul 11, 2024
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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants