Replace use of as_str().len() with .len()
What changed, and why it matters
This is a trivial code cleanup inside a test file. It replaces a slightly longer way of getting a string's length with a shorter, equivalent way. There is no security relevance.
No action required. This is a non-security refactoring change in test code.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit changes one line in bitcoin/src/address/mod.rs within a unit test. It replaces encoded.as_str().len() with encoded.len(). Both expressions return the same byte length for the string. The change is purely stylistic/refactoring and does not alter program logic, behavior, or security posture.
Changed components
bitcoin/src/address/mod.rs test moduleInspect captured patch +1 / −1
diff --git a/bitcoin/src/address/mod.rs b/bitcoin/src/address/mod.rs
index 7b44ba7c..e8d66da2 100644
--- a/bitcoin/src/address/mod.rs
+++ b/bitcoin/src/address/mod.rs
@@ -1626,7 +1626,7 @@ mod tests {
match err {
Base58Error::InvalidBase58PayloadLength(inner) => {
assert_eq!(inner.invalid_base58_payload_length(), 22); // Payload size
- assert_ne!(inner.invalid_base58_payload_length(), encoded.as_str().len()); // Not string size
+ assert_ne!(inner.invalid_base58_payload_length(), encoded.len()); // Not string size
}
other => panic!("unexpected error: {other:?}"),
}
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.