Skip to content

Improve std::hash::Hasher to finish with an associated type #65744

@afranchuk

Description

@afranchuk

std::hash::Hasher currently defines a finish() method that returns a fixed type (u64). This trait could be improved by changing the return type to some associated Output type. I don't see a particular reason this wouldn't work, since, for instance, std::collections::HashMap can simply provide a Hasher which produces the type it expects. This would be nice as then types implementing std::hash::Hash could be used with, for example, cryptographic hash functions. I am aware of the digest crate intended for that use case, but I don't see a reason not to improve the existing trait.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.rust-2-breakage-wishlistIn the wishlist of breaking changes that requires rust 2.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions