-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Use pattern matching instead of checking lengths explicitly #85900
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rustbot
added
C-cleanup
Category: PRs that clean code up or issues documenting cleanup.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Jun 1, 2021
(rust-highfive has picked a reviewer for you, use r? to override) |
rust-highfive
added
the
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
label
Jun 1, 2021
petrochenkov
reviewed
Jun 1, 2021
r=me with nit addressed. |
petrochenkov
added
S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Jun 1, 2021
This piece of code checks that there are exaclty two variants, one having exactly one field, the other having exactly zero fields. If any of these conditions is violated, it returns `None`. Otherwise it assigns that one field's ty to `field_ty`. Instead of fiddling with indices and length checks explicitly, use pattern matching to simplify this.
@bors r+ rollup |
📌 Commit e2b22b5 has been approved by |
bors
added
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed
S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.
labels
Jun 1, 2021
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jun 3, 2021
Rollup of 13 pull requests Successful merges: - rust-lang#83362 (Stabilize `vecdeque_binary_search`) - rust-lang#85706 (Turn off frame pointer elimination on all Apple platforms. ) - rust-lang#85724 (Fix issue 85435 by restricting Fake Read precision) - rust-lang#85852 (Clarify meaning of MachineApplicable suggestions.) - rust-lang#85877 (Intra doc link-ify a reference to a function) - rust-lang#85880 (convert assertion on rvalue::threadlocalref to delay bug) - rust-lang#85896 (Add test for forward declared const param defaults) - rust-lang#85897 (Update I-unsound label for triagebot) - rust-lang#85900 (Use pattern matching instead of checking lengths explicitly) - rust-lang#85911 (Avoid a clone of output_filenames.) - rust-lang#85926 (Update cargo) - rust-lang#85934 (Add `Ty::is_union` predicate) - rust-lang#85935 (Validate type of locals used as indices) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-cleanup
Category: PRs that clean code up or issues documenting cleanup.
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This piece of code checks that there are exaclty two variants, one having
exactly one field, the other having exactly zero fields. If any of these
conditions is violated, it returns
None
. Otherwise it assigns that onefield's ty to
field_ty
.Instead of fiddling with indices and length checks explicitly, use pattern
matching to simplify this.
@rustbot modify labels +C-cleanup +T-compiler