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

fix: no default values when unexpected errors occurred #1303

Merged
merged 1 commit into from
Aug 9, 2023

Conversation

yangby-cryptape
Copy link
Collaborator

@yangby-cryptape yangby-cryptape commented Aug 3, 2023

What this PR does / why we need it:

This PR:

  • Remove unwrap_or_default for unexpected errors.

  • Set default value directly instead of unwrap_or_default.

    • const fn for traits is not released (today, latest toolchain is 1.71.0), set a const value with unwrap_or(const_value) is better than unwrap_or_default, since unwrap_or_default will call the Default::default(..) function.
      p.s. -O3, even -O2, may ignore the call, set const value directly.

    • More readability, a literal value is more clearly than Default::default(..).

Which issue(s) this PR fixes:

Fixes #1287

Which docs this PR relation:

Ref #

Which toolchain this PR adaption:

No Breaking Change

Special notes for your reviewer:

NIL

CI Description

CI Name Description
Chaos CI Test the liveness and robustness of Axon under terrible network condition
Cargo Clippy Run cargo clippy --all --all-targets --all-features
Coverage Test Get the unit test coverage report
E2E Test Run end-to-end test to check interfaces
Code Format Run cargo +nightly fmt --all -- --check and cargo sort -gwc
Web3 Compatible Test Test the Web3 compatibility of Axon
v3 Core Test Run the compatibility tests provided by Uniswap V3
OCT 1-5 | 6-10 | 11 | 12-15 | 16-19 Run the compatibility tests provided by OpenZeppelin

CI Usage

Check the CI you want to run below, and then comment /run-ci.

CI Switch

  • Chaos CI
  • Cargo Clippy
  • Coverage Test
  • E2E Tests
  • Code Format
  • Unit Tests
  • Web3 Compatible Tests
  • OCT 1-5 And 12-15
  • OCT 6-10
  • OCT 11
  • OCT 16-19
  • v3 Core Tests

@github-actions github-actions bot added the bugfix label Aug 3, 2023
@yangby-cryptape

This comment was marked as off-topic.

@yangby-cryptape yangby-cryptape marked this pull request as ready for review August 4, 2023 00:25
@yangby-cryptape yangby-cryptape requested a review from a team as a code owner August 4, 2023 00:25
@axon-bot

This comment was marked as outdated.

@yangby-cryptape yangby-cryptape force-pushed the yangby/bugfix/remove_unwrap_or_default_fo_result branch from d4bf768 to 53077bb Compare August 4, 2023 06:57
@yangby-cryptape

This comment was marked as off-topic.

@axon-bot

This comment was marked as outdated.

@yangby-cryptape yangby-cryptape requested review from driftluo and KaoImin and removed request for jjyr August 4, 2023 07:41
@yangby-cryptape yangby-cryptape force-pushed the yangby/bugfix/remove_unwrap_or_default_fo_result branch from 53077bb to 5d99d3e Compare August 7, 2023 02:26
@yangby-cryptape

This comment was marked as off-topic.

@axon-bot

This comment was marked as outdated.

@KaoImin

This comment was marked as off-topic.

@axon-bot

This comment was marked as outdated.

@KaoImin KaoImin added this pull request to the merge queue Aug 9, 2023
Merged via the queue into main with commit 2b75f11 Aug 9, 2023
27 checks passed
@yangby-cryptape yangby-cryptape deleted the yangby/bugfix/remove_unwrap_or_default_fo_result branch August 9, 2023 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid to use unwrap_or_default(..), specifically on Result
3 participants