Skip to content

Please document use_phf #439

@tgrushka

Description

@tgrushka

What does #[strum(use_phf)] do on a #[derive(strum::EnumString)] enum? The only documentation is:

/// If you have a large enum, you may want to consider using the `use_phf` attribute here. It leverages
/// perfect hash functions to parse much quicker than a standard `match`. (MSRV 1.46)

That's it. What does this do? What does it mean, for those of us without a PhD in computer science? It generates a hash per variant for the string representation or something? Which string does it use, the #[strum(to_string = "...")] one? I'm just guessing here, no idea, and #220 refers to #218 which refers to the phf crate. At this point, I have given up, there are too many rabbit holes to figure out what this does, how it works, what code it generates, how it impacts my performance / memory usage, etc.

Someone took hours to implement this feature. Would be worth 10 minutes to write up a paragraph describing what it does, and when and how to use it.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions