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

digest: add newtype! macro #1799

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

digest: add newtype! macro #1799

wants to merge 2 commits into from

Conversation

newpavlov
Copy link
Member

@newpavlov newpavlov commented Mar 19, 2025

TODO: support generic parameters (e.g. output size) on generated newtype

Closes #1069

@baloo
Copy link
Member

baloo commented Mar 19, 2025

I'm a bit worried we have to list all the traits in the invocation of the macro and that consumers will drift inconsistent over time.

We can't centrally add/implement a trait (like we could with the CoreWrapper or my set of macros (#1775)).

@newpavlov
Copy link
Member Author

newpavlov commented Mar 19, 2025

What do you mean by "drift"? The list of traits should not change across semver-compatible releases of digest.

To make the list of traits less annoying, I plan to add several templates for the most common cases. In other words, instead of:

newtype!(
    /// SHA-256 hash
    Sha256(..);
    delegate:
        Debug AlgorithmName
        Clone Default Reset
        BlockSizeUser OutputSizeUser HashMarker
        Update FixedOutput FixedOutputReset
);

We will write:

newtype!(
    /// SHA-256 hash
    Sha256(..);
    delegate_template: FixedOutputHash
);

@baloo
Copy link
Member

baloo commented Mar 19, 2025

We've added traits in the previous cycle: #1098 (released in digest 0.10.4)

We may continue to do so in the next one. Having to list the traits means we have to each consumers and bump the list everywhere and release them.
It's less of a problem with a template though.

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.

digest: type name readability regression
2 participants