units: Add #[inline] to fmt functions in macro
What changed, and why it matters
This commit adds compiler hints (#[inline]) to formatting functions for some numeric wrapper types. It is a routine performance/cleanup change and does not alter program behavior or fix any security issue.
No security action needed. Treat as a normal optimization/cleanup commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds #[inline] attributes to fmt method implementations inside the impl_fmt_traits_for_u32_wrapper macro in units/src/internal_macros.rs. These implementations delegate directly to the underlying u32’s formatting traits. Adding #[inline] only affects compiler inlining decisions; it does not change semantics, input validation, memory safety, or cryptographic behavior.
Changed components
units/src/internal_macros.rsInspect captured patch +8 / −0
diff --git a/units/src/internal_macros.rs b/units/src/internal_macros.rs
index a9b049df..06fa4bfe 100644
--- a/units/src/internal_macros.rs
+++ b/units/src/internal_macros.rs
@@ -186,24 +186,28 @@ pub(crate) use impl_div_assign;
macro_rules! impl_fmt_traits_for_u32_wrapper {
($ty:ident) => {
impl core::fmt::LowerHex for $ty {
+ #[inline]
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
core::fmt::LowerHex::fmt(&self.0, f)
}
}
impl core::fmt::UpperHex for $ty {
+ #[inline]
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
core::fmt::UpperHex::fmt(&self.0, f)
}
}
impl core::fmt::Octal for $ty {
+ #[inline]
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
core::fmt::Octal::fmt(&self.0, f)
}
}
impl core::fmt::Binary for $ty {
+ #[inline]
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
core::fmt::Binary::fmt(&self.0, f)
}
@@ -211,24 +215,28 @@ macro_rules! impl_fmt_traits_for_u32_wrapper {
};
($ty:ident, $fn:ident) => {
impl core::fmt::LowerHex for $ty {
+ #[inline]
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
core::fmt::LowerHex::fmt(&self.$fn(), f)
}
}
impl core::fmt::UpperHex for $ty {
+ #[inline]
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
core::fmt::UpperHex::fmt(&self.$fn(), f)
}
}
impl core::fmt::Octal for $ty {
+ #[inline]
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
core::fmt::Octal::fmt(&self.$fn(), f)
}
}
impl core::fmt::Binary for $ty {
+ #[inline]
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
core::fmt::Binary::fmt(&self.$fn(), f)
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.