Skip to content

Commit

Permalink
Cleanup docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Jun 17, 2021
1 parent ff77659 commit ddecc3a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 36 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -14,11 +14,11 @@ a 100,000 entry map in roughly .4 seconds. By default statistics are not
produced, but if you set the environment variable `PHF_STATS` it will issue
a compiler note about how long it took.

MSRV (minimum supported rust version) is Rust 1.46.

Usage
=====

##### Release 0.8.0 requires Rust 1.32.0

PHF data structures can be constucted via either the procedural
macros in the `phf_macros` crate or code generation supported by the
`phf_codegen` crate.
Expand Down
44 changes: 25 additions & 19 deletions phf/src/lib.rs
Expand Up @@ -8,11 +8,11 @@
//! 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 method can be used with a stable compiler
//! (`rustc` version 1.30+)
//! (minimum supported rust version is 1.46).
//!
//! ```toml
//! [dependencies]
//! phf = { version = "0.7.24", features = ["macros"] }
//! phf = { version = "0.9", features = ["macros"] }
//! ```
//!
//! ```
Expand All @@ -34,9 +34,17 @@
//! }
//! ```
//!
//! (Alternatively, you can use the phf_codegen crate to generate PHF datatypes
//! in a build script)
#![doc(html_root_url="https://docs.rs/phf/0.7")]
//! 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.
//!
//! [#183]: https://github.com/rust-phf/rust-phf/issues/183
//! [#196]: https://github.com/rust-phf/rust-phf/issues/196
#![doc(html_root_url="https://docs.rs/phf/0.9")]
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]

Expand All @@ -46,12 +54,12 @@ extern crate std as core;
#[cfg(feature = "macros")]
/// Macro to create a `static` (compile-time) [`Map`].
///
/// Requires the `"macros"` feature.
/// Requires the `macros` feature.
///
/// # Example
///
/// ```rust,edition2018
/// use ::phf::{phf_map, Map};
/// ```
/// use phf::{phf_map, Map};
///
/// static MY_MAP: Map<&'static str, u32> = phf_map! {
/// "hello" => 1,
Expand All @@ -68,41 +76,39 @@ pub use phf_macros:: phf_map;
#[cfg(feature = "macros")]
/// Macro to create a `static` (compile-time) [`OrderedMap`].
///
/// Requires the `"macros"` feature. Same usage as [`phf_map`]`!`.
/// Requires the `macros` feature. Same usage as [`phf_map`].
#[::proc_macro_hack::proc_macro_hack]
pub use phf_macros::phf_ordered_map;

#[cfg(feature = "macros")]
/// Macro to create a `static` (compile-time) [`Set`].
///
/// Requires the `"macros"` feature.
/// Requires the `macros` feature.
///
/// # Example
///
/// ```rust,edition2018
/// use ::phf::{phf_set, Set};
/// ```
/// use phf::{phf_set, Set};
///
/// static MY_SET: Set<&'static str> = phf_set! {
/// "hello world",
/// "hola mundo",
/// };
///
/// fn main ()
/// {
/// fn main () {
/// assert!(MY_SET.contains("hello world"));
/// }
/// ```
#[::proc_macro_hack::proc_macro_hack]
#[proc_macro_hack::proc_macro_hack]
pub use phf_macros::phf_set;

#[cfg(feature = "macros")]
/// Macro to create a `static` (compile-time) [`OrderedSet`].
///
/// Requires the `"macros"` feature. Same usage as [`phf_set`]`!`.
#[::proc_macro_hack::proc_macro_hack]
/// Requires the `macros` feature. Same usage as [`phf_set`].
#[proc_macro_hack::proc_macro_hack]
pub use phf_macros::phf_ordered_set;


use core::ops::Deref;

pub use phf_shared::PhfHash;
Expand All @@ -123,7 +129,7 @@ pub mod ordered_set;
// WARNING: this is not considered part of phf's public API and is subject to
// change at any time.
//
// Basically Cow, but with the Owned version conditionally compiled
// Basically Cow, but with the Owned version conditionally compiled.
#[doc(hidden)]
pub enum Slice<T: 'static> {
Static(&'static [T]),
Expand Down
18 changes: 5 additions & 13 deletions phf_codegen/src/lib.rs
Expand Up @@ -7,11 +7,9 @@
//!
//! # Examples
//!
//! build.rs
//! build.rs:
//!
//! ```rust,no_run
//! extern crate phf_codegen;
//!
//! use std::env;
//! use std::fs::File;
//! use std::io::{BufWriter, Write};
Expand All @@ -35,11 +33,9 @@
//! }
//! ```
//!
//! lib.rs
//! lib.rs:
//!
//! ```ignore
//! extern crate phf;
//!
//! #[derive(Clone)]
//! enum Keyword {
//! Loop,
Expand All @@ -60,11 +56,9 @@
//! Byte strings by default produce references to fixed-size arrays; the compiler needs a hint
//! to coerce them to slices:
//!
//! build.rs
//! build.rs:
//!
//! ```rust,no_run
//! extern crate phf_codegen;
//!
//! use std::env;
//! use std::fs::File;
//! use std::io::{BufWriter, Write};
Expand All @@ -88,11 +82,9 @@
//! }
//! ```
//!
//! lib.rs
//! lib.rs:
//!
//! ```rust,ignore
//! extern crate phf;
//!
//! #[derive(Clone)]
//! enum Keyword {
//! Loop,
Expand Down Expand Up @@ -131,7 +123,7 @@
//! builder.entry("world", "2");
//! // ...
//! ```
#![doc(html_root_url = "https://docs.rs/phf_codegen/0.7")]
#![doc(html_root_url = "https://docs.rs/phf_codegen/0.9")]

use phf_shared::{PhfHash, FmtConst};
use std::collections::HashSet;
Expand Down
2 changes: 1 addition & 1 deletion phf_generator/src/lib.rs
@@ -1,4 +1,4 @@
#![doc(html_root_url="https://docs.rs/phf_generator/0.7")]
#![doc(html_root_url="https://docs.rs/phf_generator/0.9")]
use phf_shared::{PhfHash, HashKey};
use rand::{SeedableRng, Rng};
use rand::distributions::Standard;
Expand Down
2 changes: 1 addition & 1 deletion phf_shared/src/lib.rs
@@ -1,4 +1,4 @@
#![doc(html_root_url = "https://docs.rs/phf_shared/0.7")]
#![doc(html_root_url = "https://docs.rs/phf_shared/0.9")]
#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(feature = "std")]
Expand Down

0 comments on commit ddecc3a

Please sign in to comment.