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

cleanup(rust): Simplify code using closure capture in Rust 2021 edition #6737

Merged
merged 3 commits into from
May 22, 2023

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented May 21, 2023

Motivation

Rust's new closure capture rules in the 2021 edition allow us to simplify some code.

There are some new clippy errors in Rust nightly.

Reference

In Rust 2021 edition, closures only capture the fields they need to, not the entire self or argument:
https://doc.rust-lang.org/edition-guide/rust-2021/disjoint-capture-in-closures.html

Solution

Remove a temporary variable

Fix clippy lints

Review

This is a low priority cleanup.

Reviewer Checklist

  • Will the PR name make sense to users?
    • Does it need extra CHANGELOG info? (new features, breaking changes, large changes)
  • Are the PR labels correct?
  • Does the code do what the ticket and PR says?
    • Does it change concurrent code, unsafe code, or consensus rules?
  • How do you know it works? Does it have tests?

@teor2345 teor2345 added A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup P-Low ❄️ A-network Area: Network protocol updates or fixes C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG labels May 21, 2023
@teor2345 teor2345 self-assigned this May 21, 2023
@teor2345 teor2345 requested a review from a team as a code owner May 21, 2023 21:01
@teor2345 teor2345 requested review from upbqdn and removed request for a team May 21, 2023 21:01
@codecov
Copy link

codecov bot commented May 21, 2023

Codecov Report

Merging #6737 (c7464b1) into main (a972144) will increase coverage by 0.14%.
The diff coverage is 60.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6737      +/-   ##
==========================================
+ Coverage   77.92%   78.07%   +0.14%     
==========================================
  Files         308      308              
  Lines       40874    40869       -5     
==========================================
+ Hits        31851    31908      +57     
+ Misses       9023     8961      -62     

@teor2345 teor2345 requested a review from a team as a code owner May 22, 2023 02:14
mergify bot added a commit that referenced this pull request May 22, 2023
@mergify mergify bot merged commit 3f13072 into main May 22, 2023
@mergify mergify bot deleted the disconnect-peers-rust-2021 branch May 22, 2023 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-network Area: Network protocol updates or fixes A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants