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 invalid trait implementations #96

Merged
merged 2 commits into from
Oct 3, 2024
Merged

Conversation

Dzejkop
Copy link
Contributor

@Dzejkop Dzejkop commented Oct 3, 2024

Fixes invalid trait implementations like

#[derive(Clone)]
pub struct Proof<H>(pub Vec<Branch<H::Hash>>)
where
    H: Hasher;

where Clone would only be implemented if the Hasher was Clone. Not if the hash type was clone

@0xForerunner
Copy link
Contributor

It sorta sucks having to manually implement things like Debug. I had a think about a better way to accomplish this though and couldn't come up with anything. No way to tell derive to ignore the generic type.

You could probably remove the Hasher generic and implement the methods that require that through a trait, but that solution brings up a bunch of other problems. This will have to do :p

@0xForerunner
Copy link
Contributor

This crate seems to solve the problem. Do you think it's worth the dependency?

Copy link
Contributor

@0xForerunner 0xForerunner left a comment

Choose a reason for hiding this comment

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

Nice! This looks pretty sweet!

@Dzejkop Dzejkop merged commit 6532dd0 into main Oct 3, 2024
7 checks passed
@Dzejkop Dzejkop deleted the dzejkop/fix-invalid-trait-derives branch October 3, 2024 23:42
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