8000 Removes extra usages of let _ = by dasmanas · Pull Request #937 · pyrsia/pyrsia · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Removes extra usages of let _ = #937

New issue

Have a question about this project? Sign up for a free GitHub a 8000 ccount 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

Merged
merged 10 commits into from
Aug 30, 2022

Conversation

dasmanas
Copy link
Contributor
@dasmanas dasmanas commented Aug 9, 2022

Description

Fixes #756

This PR reduces the extra usage of let _ =.

fn main() {
    func_with_result(); //line produces warning
}

fn func_with_result() -> Result<u32, &str> {
    Err("emergency failure")
}

The function call func_with_result produces warning like following

warning: unused `Result` that must be used

To suppress the warning, developer used let _ =. Our goal is to reduce this noise and create clean coding practice. To achieve the same we are following the below strategy, where we are chaining the result with unwrap_or_else when we don't bother about the Result returned.

func_with_result().unwrap_or_else(|e| {
    error!("some error message to the logger");
    Default::default()
});

Screenshots (optional)

PR Checklist

Code Contributions

  • I've built the code cargo build --all-targets successfully.
  • I've run the unit tests cargo test --workspace and everything passes.
  • I've made sure my rust toolchain is current rustup update.

@CLAassistant
Copy link
CLAassistant commented Aug 9, 2022

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link
codecov bot commented Aug 9, 2022

Codecov Report

Merging #937 (19c6a39) into main (9609cd1) will decrease coverage by 0.84%.
The diff coverage is 37.20%.

@@            Coverage Diff             @@
##             main     #937      +/-   ##
==========================================
- Coverage   82.09%   81.24%   -0.85%     
==========================================
  Files          37       37              
  Lines        3027     3077      +50     
==========================================
+ Hits         2485     2500      +15     
- Misses        542      577      +35     
Impacted Files Coverage Δ
src/build_service/event.rs 37.50% <16.66%> (-9.73%) ⬇️
src/network/event_loop.rs 51.10% <37.93%> (-1.04%) ⬇️
src/verification_service/service.rs 93.97% <50.00%> (-2.31%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@johanvos
Copy link
Contributor
johanvos commented Aug 9, 2022

Relates to #826 (whi 8000 ch can probably be closed in favor of this?)

@dasmanas
Copy link
Contributor Author
dasmanas commented Aug 9, 2022

Relates to #826 (which can probably be closed in favor of this?)

closing

@betarelease betarelease mentioned this pull request Aug 9, 2022
7 tasks
@dasmanas dasmanas marked this pull request as ready for review August 12, 2022 08:26
@dasmanas dasmanas requested a review from a team as a code owner August 12, 2022 08:26
@dasmanas dasmanas requested review from betarelease and johanvos and removed request for a team August 12, 2022 08:26
@dasmanas dasmanas requested a review from fishseabowl August 12, 2022 08:26
Copy link
Member
@fishseabowl fishseabowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dasmanas dasmanas merged commit 07d1bb3 into pyrsia:main Aug 30, 2022
@dasmanas dasmanas deleted the wip-code-quality-improve-let-underscore branch August 30, 2022 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extra usage of let _ = clutters the code base
4 participants
0