Drop wrap_debug module from internals
What changed, and why it matters
This commit is a simple internal code cleanup. It moves a small helper type used only for formatting debug output from a shared internal utility module directly into the only place it is used, then removes the now-unused utility module. There is no change to how the code behaves or to any security-sensitive logic.
No security action needed. This is a routine refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch removes internals::wrap_debug::WrapDebug from internals/src/wrap_debug.rs and internals/src/lib.rs, and pastes the same WrapDebug<F> struct and its fmt::Debug implementation as a private type inside primitives/src/witness.rs. The type signature, trait bounds, and behavior are identical; only visibility changes from pub to private and the module location changes. No functional or API change is introduced.
Changed components
internals/src/wrap_debug.rsinternals/src/lib.rsprimitives/src/witness.rsInspect captured patch +7 / −11
diff --git a/internals/src/lib.rs b/internals/src/lib.rs
index b1d24040..e0fcc659 100644
--- a/internals/src/lib.rs
+++ b/internals/src/lib.rs
@@ -44,7 +44,6 @@ pub mod macros;
mod parse;
pub mod script;
pub mod slice;
-pub mod wrap_debug;
#[cfg(feature = "serde")]
#[macro_use]
pub mod serde;
diff --git a/internals/src/wrap_debug.rs b/internals/src/wrap_debug.rs
deleted file mode 100644
index 9a3f63d9..00000000
--- a/internals/src/wrap_debug.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-//! Contains a wrapper for a function that implements `Debug`.
-use core::fmt;
-
-/// A wrapper for a function that implements `Debug`.
-pub struct WrapDebug<F: Fn(&mut fmt::Formatter) -> fmt::Result>(pub F);
-
-impl<F: Fn(&mut fmt::Formatter) -> fmt::Result> fmt::Debug for WrapDebug<F> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (self.0)(f) }
-}
diff --git a/primitives/src/witness.rs b/primitives/src/witness.rs
index c74fa692..4653860c 100644
--- a/primitives/src/witness.rs
+++ b/primitives/src/witness.rs
@@ -18,7 +18,6 @@ use encoding::{
#[cfg(feature = "hex")]
use hex::DecodeVariableLengthBytesError;
use internals::slice::SliceExt;
-use internals::wrap_debug::WrapDebug;
#[cfg(feature = "hex")]
use crate::hex_codec::HexPrimitive;
@@ -949,6 +948,13 @@ fn decode_unchecked(slice: &mut &[u8]) -> u64 {
}
}
+/// A wrapper for a function that implements `Debug`.
+struct WrapDebug<F: Fn(&mut fmt::Formatter) -> fmt::Result>(pub F);
+
+impl<F: Fn(&mut fmt::Formatter) -> fmt::Result> fmt::Debug for WrapDebug<F> {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (self.0)(f) }
+}
+
/// Error types for witness data.
pub mod error {
use core::convert::Infallible;
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.