talira

Rust-PHF

Compile-time perfect-hash lookup tables for Rust

open sourceMITfree

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.

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

Alternatives

The same job

These do what Rust-PHF does.

  1. hashbrown SwissTable-based HashMap and HashSet for Rust, the implementation behind the standard library's
  2. indexmap Rust hash map and set that keep insertion order and index entries

Compare Rust-PHF with the top 3