8000 Refactor use map_err by wim-web · Pull Request #794 · rust-bitcoin/rust-bitcoin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Refactor use map_err #794

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
Jan 18, 2022
Merged

Conversation

wim-web
Copy link
Contributor
@wim-web wim-web commented Jan 17, 2022

issue: #793

change to using map_err

@wim-web wim-web marked this pull request as ready for review January 17, 2022 15:55
@dr-orlovsky dr-orlovsky linked an issue Jan 17, 2022 that may be closed by this pull request
@dr-orlovsky dr-orlovsky added the trivial Obvious, easy and quick to review (few lines or doc-only...) label Jan 17, 2022
Copy link
Collaborator
@dr-orlovsky dr-orlovsky left a comment

Choose a reason for hiding this comment

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

I believe there was a second place in that PR when the similar matching was happening?

Copy link
Collaborator
@Kixunil Kixunil left a comment

Choose a reason for hiding this comment

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

@dr-orlovsky yes, there was another place

Ok(sig) => Ok(sig),
8000 Err(schnorr::SchnorrSigError::InvalidSighashType(flag)) => {
Err(encode::Error::from(psbt::Error::NonStandardSigHashType(flag as u32)))
schnorr::SchnorrSig::from_slice(&bytes).map_err(|e| match e {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel that one of these styles would be easier to understand by readers:

schnorr::SchnorrSig::from_slice(&bytes)
    .map_err(|e| match e {
       ...
    })
schnorr::SchnorrSig::from_slice(&bytes)
    .map_err(|e|
        match e {
            ...
        }
    )
schnorr::SchnorrSig::from_slice(&bytes)
    .map_err(|e|
        match e {
           ...
        }
    )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you for review.
fixed code!

@wim-web wim-web force-pushed the refactor_to_map_err branch from ee4e405 to 9f84847 Compare January 18, 2022 04:22
@wim
8000
-web
Copy link
Contributor Author
wim-web commented Jan 18, 2022

i have refactor another place too

@Kixunil
Copy link
Collaborator
Kixunil commented Jan 18, 2022

I approved run but unless I'm too confused something it'll fail on missing commas.

@Kixunil
Copy link
Collaborator
Kixunil commented Jan 18, 2022

What the hell?! Commas are not mandatory? OMG I thought I knew Rust well. 🤣

Copy link
Collaborator
@Kixunil Kixunil left a comment

Choose a reason for hiding this comment

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

ACK 9f84847

Thank you!

@wim-web
Copy link
Contributor Author
wim-web commented Jan 18, 2022

What the hell?! Commas are not mandatory? OMG I thought I knew Rust well. 🤣

According to the reference, comma after a BlockExpression(like {}) is optional !

https://doc.rust-lang.org/reference/expressions/match-expr.html

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 9f84847

@apoelstra apoelstra merged commit 64451a2 into rust-bitcoin:master Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
748C
Labels
trivial Obvious, easy and quick to review (few lines or doc-only...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use map_err in PSBT EcdsaSigHash deserializer
4 participants
0