hashes: Add commented out dyn compatible test
What changed, and why it matters
This commit only adds a test file containing fully commented-out code. It documents that certain hashing traits in the library are not 'dyn compatible' (a Rust technical term meaning they cannot be used as trait objects). No actual code behavior changes, no bug is fixed, and no security issue is introduced.
No action required. This is a non-functional documentation/test-only commit with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff appends a new test function dyn_compatible() to hashes/tests/api.rs. The entire body is commented out, including the trait imports and a struct with boxed trait objects. The commit message explains this is documentation of object safety (C-OBJECT API guideline) for the hashes traits. There are no functional changes to library code, no unsafe blocks, no cryptographic changes, and no test that actually executes.
Changed components
hashes/tests/api.rsInspect captured patch +14 / −0
diff --git a/hashes/tests/api.rs b/hashes/tests/api.rs
index 9c1937c2..e607b85c 100644
--- a/hashes/tests/api.rs
+++ b/hashes/tests/api.rs
@@ -257,3 +257,17 @@ fn all_error_types_implement_error() {
assert_error::<hkdf::MaxLengthError>();
assert_error::<sha256::MidstateError>();
}
+
+// This is for documentation and so anyone can play with these if they want.
+#[test]
+fn dyn_compatible() {
+ // use bitcoin_hashes::{sha256t, HashEngine, Hash, IsByteArray};
+
+ // struct Traits {
+ // // These traits are explicitly not dyn compatible.
+ // a: Box<dyn HashEngine>,
+ // b: Box<dyn Hash>,
+ // c: Box<dyn IsByteArray>,
+ // d: Box<dyn sha256t::Tag>,
+ // }
+}
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.