Skip to content

Use KeySource instead of tuple #399

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

Merged
merged 1 commit into from
May 10, 2022

Conversation

tcharding
Copy link
Member

@tcharding tcharding commented May 10, 2022

Clippy emits:

warning: very complex type used. Consider factoring parts into type definitions

The type we return is more complex than needed because we do not use the bip32::KeySource alias but instead write the full tuple (byp32::Fingerprint, bip32::DerivationPath).

To fix the clippy warning we have at least 3 options

  1. Add an alias for the complex return type
  2. Add a compiler directive to quieten clippy
  3. Use bip32::KeySource instead of tuple

(1) seems like an overkill
(2) means we loose lint coverage for the whole function

Elect to do (3), the best of 3 imperfect solutions.

@tcharding tcharding changed the title Clippy emits: Use KeySource instead of tuple May 10, 2022
Clippy emits:

 warning: very complex type used. Consider factoring parts into `type` definitions

The type we return is more complex than needed because we do not use the
`bip32::KeySource` alias but instead write the full tuple
`(byp32::Fingerprint, bip32::DerivationPath)`.

To fix the clippy warning we have at least 3 options

1. Add an alias for the complex return type
2. Add a compiler directive to quieten clippy
3. Use `bip32::KeySource` instead of tuple

(1) seems like an overkill
(2) means we loose lint coverage for the whole function

Elect to do (3), the best of 3 imperfect solutions.
@tcharding tcharding force-pushed the 05-10-use-key-source branch from ae1eff5 to f8945d0 Compare May 10, 2022 05:26
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK f8945d0

I actually think this is a great improvement.

Copy link
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

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

ACK f8945d0

@sanket1729 sanket1729 merged commit abcec45 into rust-bitcoin:master May 10, 2022
@tcharding
Copy link
Member Author

I actually think this is a great improvement.

Oh yeah? Why is that? At some other place in some other time I favoured the tuple also because I thought it was clearer than KeySource, I'm interested to hear your thoughts. Cheers

@tcharding tcharding deleted the 05-10-use-key-source branch May 10, 2022 21:22
@apoelstra
Copy link
Member

"keysource" is a standard term (I believe) for this tuple, so by using the shorter name it aids readability.

@tcharding
Copy link
Member Author

cool, cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants