Skip to content

Commit

Permalink
Docs for new macro setup
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Jan 3, 2019
1 parent e3a7442 commit 364ed47
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Expand Up @@ -47,6 +47,7 @@ jobs:
- run: rustc --version > ~/rust-version
- run: cargo test -p phf_macros
- run: cargo test -p phf_codegen_test
- run: cargo test -p phf --features macros

workflows:
version: 2
Expand Down
42 changes: 38 additions & 4 deletions phf/src/lib.rs
@@ -1,8 +1,42 @@
//! Compile time optimized maps and sets.
//! Compile-time generated maps and sets.
//!
//! PHF data structures can be generated via the syntax extensions in the
//! `phf_macros` crate or via code generation in the `phf_codegen` crate. See
//! the documentation of those crates for more details.
//! The `phf::Map` and `phf::Set` types have roughly comparable performance to
//! a standard hash table, but can be generated as compile-time static values.
//!
//! # Usage
//!
//! If the `macros` Cargo feature is enabled, the `phf_map`, `phf_set`,
//! `phf_ordered_map`, and `phf_ordered_set` macros can be used to construct
//! the PHF type. This currently requires a nightly compiler.
//!
//! ```toml
//! [dependencies]
//! phf = { version = "0.7.24", features = ["macros"] }
//! ```
//!
//! ```
//! #![feature(proc_macro_hygiene)]
//!
//! use phf::{phf_map, phf_set};
//!
//! static MY_MAP: phf::Map<&'static str, u32> = phf_map! {
//! "hello" => 1,
//! "world" => 2,
//! };
//!
//! static MY_SET: phf::Set<&'static str> = phf_set! {
//! "hello world",
//! "hola mundo",
//! };
//!
//! fn main() {
//! assert_eq!(MY_MAP["hello"], 1);
//! assert!(MY_SET.contains("hello world"));
//! }
//! ```
//!
//! Alternatively, you can use the phf_codegen crate to generate PHF datatypes
//! in a build script. This method can be used with a stable compiler.
#![doc(html_root_url="https://docs.rs/phf/0.7.20")]
#![warn(missing_docs)]
#![cfg_attr(feature = "core", no_std)]
Expand Down

0 comments on commit 364ed47

Please sign in to comment.