From d97cbc6d27e7c38b2c59841cd3d1d3fb0bbac69d Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 20 Jan 2025 13:22:06 +1100 Subject: [PATCH 1/3] units: Correct docs on private Sealed trait Trivial fix to the rustdocs on private trait (required to keep linter quiet). --- units/src/parse.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/units/src/parse.rs b/units/src/parse.rs index 6127a8f9e..316186953 100644 --- a/units/src/parse.rs +++ b/units/src/parse.rs @@ -70,7 +70,7 @@ macro_rules! impl_integer { impl_integer!(u8, i8, u16, i16, u32, i32, u64, i64, u128, i128); mod sealed { - /// Seals the extension traits. + /// Seals the `Integer` trait. pub trait Sealed {} } From f1e2564821686f620fe1c99f0ba7e4e0ab551576 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 20 Jan 2025 13:34:09 +1100 Subject: [PATCH 2/3] Improve docs on parse::int_from_string I only just worked on this function a week ago and already I couldn't see from reading the code why it exists. Add a paragraph to the rustdocs to save the next guy the trouble of working it out. --- units/src/parse.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/units/src/parse.rs b/units/src/parse.rs index 316186953..01adc3a01 100644 --- a/units/src/parse.rs +++ b/units/src/parse.rs @@ -76,6 +76,11 @@ mod sealed { /// Parses the input string as an integer returning an error carrying rich context. /// +/// Apart from the rich error context this function exists so that we can handle builds with and +/// without an allocator. If an allocator is available (`alloc` feature enabled) then this function +/// allocates to copy the input string into the error return. If `alloc` is not enabled the input +/// string is lost. +/// /// If the caller has a `String` or `Box` which is not used later it's better to call /// [`parse::int_from_string`] or [`parse::int_from_box`] respectively. /// From 7ca5c5ccae1efe5862f21bfc670257837a202517 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 20 Jan 2025 13:44:25 +1100 Subject: [PATCH 3/3] Fix rustdoc title on hex_u128_* The `hex_u32` versions of these functions have better docs, copy them to the `hex_u128` versions. --- units/src/parse.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/units/src/parse.rs b/units/src/parse.rs index 01adc3a01..c210a6c47 100644 --- a/units/src/parse.rs +++ b/units/src/parse.rs @@ -335,7 +335,7 @@ pub fn hex_u128(s: &str) -> Result { Ok(hex_u128_unchecked(unchecked)?) } -/// Parses a `u128` from a hex string. +/// Parses a `u128` from a prefixed hex string. /// /// # Errors /// @@ -346,7 +346,7 @@ pub fn hex_u128_prefixed(s: &str) -> Result { Ok(hex_u128_unchecked(checked)?) } -/// Parses a `u128` from a hex string. +/// Parses a `u128` from an unprefixed hex string. /// /// # Errors ///