From fb3ae53845401b20a5e4372bb65a406808020568 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 26 Oct 2023 12:35:08 +1100 Subject: [PATCH 1/3] Improve crate docs Implement a pattern we have recently been playing with. Currently public re-exports are listed in a separate section in the HTML docs. This is kinda clunky, instead use `doc(inline)`. Separately but related, put the pub re-export statements below other use statements and use `rustfmt::skip` to stop `rustfmt` from squashing them together. --- src/buf_encoder.rs | 6 ++++-- src/lib.rs | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/buf_encoder.rs b/src/buf_encoder.rs index aa9b8a3..ccedaf5 100644 --- a/src/buf_encoder.rs +++ b/src/buf_encoder.rs @@ -10,10 +10,12 @@ use core::borrow::Borrow; -pub use out_bytes::OutBytes; - use super::Case; +#[rustfmt::skip] // Keep public re-exports separate. +#[doc(inline)] +pub use self::out_bytes::OutBytes; + /// Trait for types that can be soundly converted to `OutBytes`. /// /// To protect the API from future breakage this sealed trait guards which types can be used with diff --git a/src/lib.rs b/src/lib.rs index 7e87273..5e716ff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -49,16 +49,20 @@ mod error; mod iter; pub mod parse; -pub use display::DisplayHex; -pub use iter::{BytesToHexIter, HexToBytesIter}; -pub use parse::{FromHex, HexToArrayError, HexToBytesError}; - /// Reexports of extension traits. pub mod exts { pub use super::display::DisplayHex; pub use super::parse::FromHex; } +#[rustfmt::skip] // Keep public re-exports separate. +#[doc(inline)] +pub use self::{ + display::DisplayHex, + iter::{BytesToHexIter, HexToBytesIter}, + parse::{FromHex, HexToArrayError, HexToBytesError}, +}; + /// Mainly reexports based on features. pub(crate) mod prelude { #[cfg(feature = "alloc")] From 97c41b2eac05046bcecf6d6da878b5d44ca29b54 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 26 Oct 2023 12:55:30 +1100 Subject: [PATCH 2/3] Do minor grammar improvement to rustdoc No content change, just slight re-wording. --- src/buf_encoder.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/buf_encoder.rs b/src/buf_encoder.rs index ccedaf5..1cf80aa 100644 --- a/src/buf_encoder.rs +++ b/src/buf_encoder.rs @@ -4,9 +4,9 @@ //! //! This is a low-level module, most uses should be satisfied by the `display` module instead. //! -//! The main type of this module is [`BufEncoder`] which provides buffered hex encoding. Such is -//! faster than the usual `write!(f, "{02x}", b)?` in a for loop because it reduces dynamic -//! dispatch and decreases the number of allocations if a `String` is being created. +//! The main type in this module is [`BufEncoder`] which provides buffered hex encoding. +//! `BufEncoder` is faster than the usual `write!(f, "{02x}", b)?` in a for loop because it reduces +//! dynamic dispatch and decreases the number of allocations if a `String` is being created. use core::borrow::Borrow; From 0bc4043eea3f3c1bd40ec45b6d50dd3abeb8ddb7 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 26 Oct 2023 12:50:37 +1100 Subject: [PATCH 3/3] Improve rustdoc about package trick Slightly improve the documentation about using the `package` trick in the manifest when depending on this crate. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 5e716ff..069c28a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ //! ## Basic Usage //! ``` //! # #[cfg(feature = "alloc")] { -//! // Use the `package` key to improve import ergonomics (`hex` instead of `hex-conservative`). +//! // In your manifest use the `package` key to improve import ergonomics. //! // hex = { package = "hex-conservative", version = "*" } //! # use hex_conservative as hex; // No need for this if using `package` as above. //! use hex::{DisplayHex, FromHex};