Skip to content

style: prefer then_some over if else#1810

Merged
mattsse merged 3 commits intomainfrom
rkrasiuk/style-prefer-then-some
Mar 17, 2023
Merged

style: prefer then_some over if else#1810
mattsse merged 3 commits intomainfrom
rkrasiuk/style-prefer-then-some

Conversation

@rkrasiuk
Copy link
Contributor

@rkrasiuk rkrasiuk commented Mar 17, 2023

Prefer bool::then_some over if <bool> { Some(..) } else { None }

@rkrasiuk rkrasiuk added the A-meta Changes in the contributor workflow and planning label Mar 17, 2023
@rkrasiuk rkrasiuk requested a review from mattsse March 17, 2023 08:00
@codecov-commenter
Copy link

codecov-commenter commented Mar 17, 2023

Codecov Report

Merging #1810 (07b8faf) into main (8485d7b) will decrease coverage by 0.01%.
The diff coverage is 57.14%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main    #1810      +/-   ##
==========================================
- Coverage   73.47%   73.47%   -0.01%     
==========================================
  Files         405      405              
  Lines       50323    50326       +3     
==========================================
  Hits        36976    36976              
- Misses      13347    13350       +3     
Flag Coverage Δ
integration-tests 19.79% <14.28%> (-0.02%) ⬇️
unit-tests 67.79% <42.85%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
bin/reth/src/test_eth_chain/runner.rs 0.00% <0.00%> (ø)
crates/executor/src/executor.rs 90.54% <0.00%> (ø)
crates/rpc/rpc/src/eth/filter.rs 7.33% <0.00%> (-0.10%) ⬇️
crates/revm/revm-primitives/src/compat.rs 32.00% <100.00%> (+2.83%) ⬆️
crates/rpc/rpc/src/eth/api/server.rs 98.45% <100.00%> (+<0.01%) ⬆️
crates/storage/provider/src/test_utils/mock.rs 31.44% <100.00%> (-0.30%) ⬇️

... and 5 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

smol nit

pre_state.into_iter().try_for_each(|(address, account)| -> eyre::Result<()> {
let has_code = !account.code.is_empty();
let code_hash = if has_code { Some(keccak256(&account.code)) } else { None };
let code_hash = has_code.then_some(keccak256(&account.code));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think these are euqivalent beecause then_some takes the value.

I think this should be just .then with a closure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch!

@mattsse mattsse merged commit 9036f5e into main Mar 17, 2023
@mattsse mattsse deleted the rkrasiuk/style-prefer-then-some branch March 17, 2023 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-meta Changes in the contributor workflow and planning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants