Phf - Rust
- phf-0.13.1
- phf 0.13.1
- Permalink
- Docs.rs crate page
- MIT
- Links
- Repository
- crates.io
- Source
- Owners
- sfackler
- abonander
- JohnTitor
- Dependencies
-
- phf_macros ^0.13.1 normal optional
- phf_shared ^0.13.1 normal
- serde ^1.0 normal optional
- Versions
- 100% of the crate is documented
- Platform
- i686-pc-windows-msvc
- i686-unknown-linux-gnu
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
- x86_64-unknown-linux-gnu
- Feature flags
- docs.rs
- About docs.rs
- Badges
- Builds
- Metadata
- Shorthand URLs
- Download
- Rustdoc JSON
- Build queue
- Privacy policy
- Rust
- Rust website
- The Book
- Standard Library API Reference
- Rust by Example
- The Cargo Guide
- Clippy Documentation
Crate phf
phf0.13.1
- All Items
Sections
- Usage
- Example (with the macros feature enabled)
- Note
Crate Items
- Modules
- Macros
- Structs
- Traits
Rust-PHF is a library to generate efficient lookup tables at compile time using perfect hash functions.
It currently uses the CHD algorithm and can generate a 100,000 entry map in roughly .4 seconds.
MSRV (minimum supported rust version) is Rust 1.66.
§Usage
PHF data structures can be constructed via either the procedural macros in the phf_macros crate or code generation supported by the phf_codegen crate. If you prefer macros, you can easily use them by enabling the macros feature of the phf crate, like:
[dependencies] phf = { version = "0.13.1", features = ["macros"] }To compile the phf crate with a dependency on libcore instead of libstd, enabling use in environments where libstd will not work, set default-features = false for the dependency:
[dependencies] # to use `phf` in `no_std` environments phf = { version = "0.13.1", default-features = false }§Example (with the macros feature enabled)
use phf::phf_map; #[derive(Clone)] pub enum Keyword { Loop, Continue, Break, Fn, Extern, } static KEYWORDS: phf::Map<&'static str, Keyword> = phf_map! { "loop" => Keyword::Loop, "continue" => Keyword::Continue, "break" => Keyword::Break, "fn" => Keyword::Fn, "extern" => Keyword::Extern, }; pub fn parse_keyword(keyword: &str) -> Option<Keyword> { KEYWORDS.get(keyword).cloned() }Alternatively, you can use the phf_codegen crate to generate PHF datatypes in a build script.
§Note
Currently, the macro syntax has some limitations and may not work as you want. See #183 or #196 for example.
Modules§
mapAn immutable map constructed at compile time.ordered_mapAn order-preserving immutable map constructed at compile time.ordered_setAn order-preserving immutable set constructed at compile time.setAn immutable set constructed at compile time.Macros§
phf_mapMacro to create a static (compile-time) Map.phf_ordered_mapMacro to create a static (compile-time) OrderedMap.phf_ordered_setMacro to create a static (compile-time) OrderedSet.phf_setMacro to create a static (compile-time) Set.Structs§
MapAn immutable map constructed at compile time.OrderedMapAn order-preserving immutable map constructed at compile time.OrderedSetAn order-preserving immutable set constructed at compile time.SetAn immutable set constructed at compile time.Traits§
PhfHashA trait implemented by types which can be used in PHF data structures.Từ khóa » Phf
-
Home - PREMIER HOCKEY FEDERATION
-
The Toronto Six Strengthened Their Defense With The Return Of Emma Greco & Signing Of Kati Tabin! 🍁 #PresentedByDiscover 9 Giờ Trước
-
The Minnesota Whitecaps Made Two Forward Signings In Brittyn Fleming & Ronja Mogren! 🌊 #PresentedByDiscover 9 Giờ Trước
-
The Riveters Announced The Signings Of Defenders Emilie Harley & Sarah Forster! 💪 #PresentedByDiscover 10 Giờ Trước
-
The Buffalo Beauts Announced The Signing Of Forward Summer-Rae Dobson! 🦬 #PresentedByDiscover 10 Giờ Trước
-
2021–22 PHF Season - Wikipedia
-
PHF - YouTube
-
PUREST HELL Out NOW (@p.h.f) • Instagram Photos And Videos
-
Public Health Foundation - Home
-
P.H.F. | Spotify
-
Paul Hamlyn Foundation: Home
-
PHF | Your Partner In Practice
-
Phf - : Rust Package Registry
-
PHF: The New Parathyroid Hypertensive Factor - PubMed
-
PHF FX190-68X115 - Bushings - SKF