# rust-phf/rust-phf

Compile time static maps for Rust

Repository: https://github.com/rust-phf/rust-phf
Canonical: https://ross.abutalabs.com/products/rust-phf
Language: Rust
License: MIT
License Family: permissive
Topics: rust
Last push: 2026-08-24T11:02:41+00:00

## Health v2 (maintenance only)
Score: 96/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 99, release rhythm 89, longevity 100
- inputs: {"age_days": 4611, "days_push": 9, "days_rel": 74, "gap_med": 0.0, "n_releases_24m": 11}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2183, forks 138 (observed 2026-08-28T04:06:23.536173+00:00)

## What it is
Rust-PHF is a Rust library for generating efficient compile-time static maps and sets using perfect hash functions (CHD algorithm by default, with an experimental ptrhash layout). It supports construction via procedural macros (phf_macros) or build-time code generation (phf_codegen), and works in no_std environments.

## Use cases
- create static lookup tables at compile time in Rust
- map string keywords to enum values with zero runtime hashing cost
- build static maps in no_std embedded Rust projects
- generate perfect hash tables in build.rs with phf_codegen
- look up operators or tokens by multiple key aliases

## When to choose
- you need fast, allocation-free static maps or sets known at compile time
- you want zero-cost lookup tables in no_std or embedded environments
- you're writing parsers or interpreters with fixed keyword tables

## When to avoid
- you need mutable or runtime-constructed maps
- your keys are only known at runtime
- you need ordered maps or rich map APIs beyond lookup

## Facets
- artifact type: library
- maturity: stable
- function: serialization, developer-tools
- domain: programming-languages, developer-tools
- platform: rust, cross-platform
- tags: perfect-hash, compile-time, static-maps, no-std, proc-macros, lookup-tables, algorithms

## Member repositories
- rust-phf/rust-phf (main) score 96

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:23.536173+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T02:48:15.515528+00:00, confidence not recorded.
  - readme: https://github.com/rust-phf/rust-phf (fetched 2026-08-28T04:06:23.536173+00:00, sha e79b44583fa1)
- Data as of 2026-08-30T08:39:29.467469+00:00.
