From ddecc3aa97aec6d9e9d6e59c57bc598d476335c1 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 17 Jun 2021 16:56:51 +0900 Subject: [PATCH] Cleanup docs --- README.md | 4 ++-- phf/src/lib.rs | 44 +++++++++++++++++++++++----------------- phf_codegen/src/lib.rs | 18 +++++----------- phf_generator/src/lib.rs | 2 +- phf_shared/src/lib.rs | 2 +- 5 files changed, 34 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 3b175b18..792c6d3e 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/phf/src/lib.rs b/phf/src/lib.rs index 44f0bfb0..ec39325b 100644 --- a/phf/src/lib.rs +++ b/phf/src/lib.rs @@ -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"] } //! ``` //! //! ``` @@ -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)] @@ -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, @@ -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; @@ -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 { Static(&'static [T]), diff --git a/phf_codegen/src/lib.rs b/phf_codegen/src/lib.rs index 9152387d..2555a9fa 100644 --- a/phf_codegen/src/lib.rs +++ b/phf_codegen/src/lib.rs @@ -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}; @@ -35,11 +33,9 @@ //! } //! ``` //! -//! lib.rs +//! lib.rs: //! //! ```ignore -//! extern crate phf; -//! //! #[derive(Clone)] //! enum Keyword { //! Loop, @@ -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}; @@ -88,11 +82,9 @@ //! } //! ``` //! -//! lib.rs +//! lib.rs: //! //! ```rust,ignore -//! extern crate phf; -//! //! #[derive(Clone)] //! enum Keyword { //! Loop, @@ -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; diff --git a/phf_generator/src/lib.rs b/phf_generator/src/lib.rs index 6d0950e1..b1625e7b 100644 --- a/phf_generator/src/lib.rs +++ b/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; diff --git a/phf_shared/src/lib.rs b/phf_shared/src/lib.rs index 02dca59d..dc778ca0 100644 --- a/phf_shared/src/lib.rs +++ b/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")]