# Rust-PHF

> Compile-time perfect-hash lookup tables for Rust

Source: https://talira.ai/catalog/rust-phf-45g8awr0
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [libraries / data structures / hashes](https://talira.ai/categories/libraries/data-structures/hashes), [languages / rust](https://talira.ai/categories/languages/rust)
- Licence: MIT[^1][^2]
- Pricing: Free and open source[^1]
- Free tier: yes[^1]
- Backed by: [rust-phf](https://talira.ai/orgs/rust-phf.md)

Rust-PHF generates efficient static maps and sets for Rust at compile time with perfect hash functions, using the CHD algorithm by default with an experimental `ptrhash` layout. Tables are built with procedural macros (`phf_macros`) or build-script code generation (`phf_codegen`), and the `phf` crate works in `no_std` environments with default features off.

## Links

- GitHub: https://github.com/rust-phf/rust-phf
- Docs: https://docs.rs/phf

## Problems it solves

- build a static lookup table at compile time in Rust
- a constant HashMap of keywords in Rust
- fast keyword lookup without runtime hashing setup in Rust

## Features

- compile-time static maps and sets
- perfect hashing with CHD, experimental ptrhash
- macros or build-script code generation
- no_std support

## Trust

Overall: 0.59 out of 1.
Signals: maintenance 0.85, adoption 0.67, momentum 0.36, community 0.75, backing 0.30, extensibility 0.00.

- last commit 2 days ago
- 38 commits in the last 90 days
- latest release v0.14.0 5 months ago
- 2.2k GitHub stars
- 74 contributors
- accepts sponsorship (Github)
- has a company behind it

## Alternatives

- [hashbrown](https://talira.ai/catalog/hashbrown-ewttdp0d.md): SwissTable-based HashMap and HashSet for Rust, the implementation behind the standard library's
- [indexmap](https://talira.ai/catalog/indexmap-jmq3c2ec.md): Rust hash map and set that keep insertion order and index entries

## Sources

[^1]: https://github.com/rust-phf/rust-phf/blob/main/LICENSE (checked 29 Nov 2026)
[^2]: https://github.com/rust-phf/rust-phf/blob/main/phf/Cargo.toml (checked 29 Nov 2026)
