From d242125ae4ae2f33575236166e137ce3b5d657e7 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 8 May 2024 11:43:29 +1000 Subject: [PATCH 1/2] units: Fix error re-exports Currently we re-export two error types at the crate root, this is surprising because: - Why not none or all the rest? - Why these two? Observe that the `ParseIntError` is special in that it is used by other modules so its good to have at the crate root (other errors are expected to be used with a module prefix eg, `amount::ParseError`). There is no obvious reason why `ParseAmountError` is re-exported. Comment and doc inline the `ParesIntError`, remove the re-export of the `ParseAmountError`. --- units/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/units/src/lib.rs b/units/src/lib.rs index 393b5ced1..3273eeef6 100644 --- a/units/src/lib.rs +++ b/units/src/lib.rs @@ -45,10 +45,11 @@ pub mod parse; #[cfg(feature = "alloc")] pub mod weight; -pub use self::amount::ParseAmountError; #[doc(inline)] pub use self::amount::{Amount, SignedAmount}; +// ParseIntError is used by other modules, so we re-export it. #[cfg(feature = "alloc")] +#[doc(inline)] pub use self::parse::ParseIntError; #[cfg(feature = "alloc")] #[doc(inline)] From d2a597c90ddb8eec06d660640e332460884a87e1 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 8 May 2024 11:52:54 +1000 Subject: [PATCH 2/2] unit: Group re-exports As is customary group the public re-exports differently to other use statements and tell rustfmt to skip them. Refactor only, no logic changes. --- units/src/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/units/src/lib.rs b/units/src/lib.rs index 3273eeef6..f123034ce 100644 --- a/units/src/lib.rs +++ b/units/src/lib.rs @@ -47,13 +47,15 @@ pub mod weight; #[doc(inline)] pub use self::amount::{Amount, SignedAmount}; -// ParseIntError is used by other modules, so we re-export it. #[cfg(feature = "alloc")] #[doc(inline)] -pub use self::parse::ParseIntError; -#[cfg(feature = "alloc")] -#[doc(inline)] -pub use self::{fee_rate::FeeRate, weight::Weight}; +#[rustfmt::skip] +pub use self::{ + fee_rate::FeeRate, + // ParseIntError is used by other modules, so we re-export it. + parse::ParseIntError, + weight::Weight +}; #[rustfmt::skip] #[allow(unused_imports)]