Skip to content

remove decode_error macro only used once #478

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

Conversation

arik-so
Copy link
Contributor

@arik-so arik-so commented Feb 6, 2020

No description provided.

@jkczyz jkczyz self-requested a review February 7, 2020 22:03
Copy link
Contributor

@jkczyz jkczyz left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning this up!

Comment on lines +585 to +586
let message_result = wire::read(&mut reader);
let message = match message_result {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can simplify these two lines as:

let message = match wire::read(&mut reader) {

Or use the name message in both assignments to shadow the first variable, as that is idiomatic in Rust.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. Although I would argue it might be easier for readers and debuggers to have the match input be a variable as opposed to a method call. What do you think?

Copy link
Contributor

@jkczyz jkczyz Feb 8, 2020

Choose a reason for hiding this comment

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

I don't have a strong opinion on that. For the readability standpoint, the let x = match <exp> { Ok(x) => x, Err(e) => { ... } } pattern is common enough to know that the expression evaluates to a Result. And given that, one variable removes redundancy. Regarding debugging, knowing which arm is hit should be enough.

Anyhow, feel free to leave as is if you feel strongly.

@TheBlueMatt
Copy link
Collaborator

Gonna merge this as its obviously better than it was and upcoming refactors in this area should give ample opportunity to get it Just Right (tm).

@TheBlueMatt TheBlueMatt merged commit 2ecec2e into lightningdevkit:master Feb 8, 2020
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