base58: Add explicit None return impl for std::error::Error
What changed, and why it matters
This commit is a minor code-clarity change. It rewrites three standard Rust error trait implementations to explicitly state that these errors have no underlying cause, instead of relying on the trait's automatic default. The behavior is identical before and after; no security issue is introduced or fixed.
No security action required. Treat as a normal readability/refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In base58/src/error.rs, the blanket impl std::error::Error for IncorrectChecksumError {}, TooShortError {}, and InvalidCharacterError {} are replaced with explicit fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None } implementations. This is semantically equivalent to the default provided by std::error::Error and has no functional effect on error chaining, reporting, or program behavior.
Changed components
base58/src/error.rsInspect captured patch +9 / −3
diff --git a/base58/src/error.rs b/base58/src/error.rs
index 8838fb73..c223ba7c 100644
--- a/base58/src/error.rs
+++ b/base58/src/error.rs
@@ -116,7 +116,9 @@ impl fmt::Display for IncorrectChecksumError {
}
#[cfg(feature = "std")]
-impl std::error::Error for IncorrectChecksumError {}
+impl std::error::Error for IncorrectChecksumError {
+ fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
+}
/// The decoded base58 data was too short (require at least 4 bytes for checksum).
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -140,7 +142,9 @@ impl fmt::Display for TooShortError {
}
#[cfg(feature = "std")]
-impl std::error::Error for TooShortError {}
+impl std::error::Error for TooShortError {
+ fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
+}
/// Found an invalid ASCII byte while decoding base58 string.
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -173,4 +177,6 @@ impl fmt::Display for InvalidCharacterError {
}
#[cfg(feature = "std")]
-impl std::error::Error for InvalidCharacterError {}
+impl std::error::Error for InvalidCharacterError {
+ fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
+}
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.