Extend from_hex and from_unprefixed_hex docs
What changed, and why it matters
This commit only updates documentation comments for two existing Rust functions, adding details about what errors they can return. No code logic was changed, so it cannot introduce or fix a security vulnerability on its own.
No security action needed. Treat as a normal documentation improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies docstrings for from_hex and from_unprefixed_hex in bitcoin/src/pow.rs to document error conditions. The function bodies and behavior remain identical; only #[doc = ...] attributes were added or extended. There are no code changes affecting parsing, validation, or error handling.
Changed components
bitcoin/src/pow.rs documentationInspect captured patch +14 / −4
diff --git a/bitcoin/src/pow.rs b/bitcoin/src/pow.rs
index 0abb2098..d7fb2ef1 100644
--- a/bitcoin/src/pow.rs
+++ b/bitcoin/src/pow.rs
@@ -25,16 +25,26 @@ pub use primitives::CompactTarget;
macro_rules! do_impl {
($ty:ident) => {
impl $ty {
- #[doc = "Constructs `"]
+ #[doc = "Constructs a new `"]
+ #[doc = stringify!($ty)]
+ #[doc = "` from a prefixed hex string.\n"]
+ #[doc = "\n# Errors\n"]
+ #[doc = "\n - If the input string does not contain a `0x` (or `0X`) prefix."]
+ #[doc = "\n - If the input string is not a valid hex encoding of a `"]
#[doc = stringify!($ty)]
- #[doc = "` from a prefixed hex string."]
+ #[doc = "`."]
pub fn from_hex(s: &str) -> Result<Self, PrefixedHexError> {
Ok($ty(U256::from_hex(s)?))
}
- #[doc = "Constructs `"]
+ #[doc = "Constructs a new `"]
+ #[doc = stringify!($ty)]
+ #[doc = "` from an unprefixed hex string.\n"]
+ #[doc = "\n# Errors\n"]
+ #[doc = "\n - If the input string contains a `0x` (or `0X`) prefix."]
+ #[doc = "\n - If the input string is not a valid hex encoding of a `"]
#[doc = stringify!($ty)]
- #[doc = "` from an unprefixed hex string."]
+ #[doc = "`."]
pub fn from_unprefixed_hex(s: &str) -> Result<Self, UnprefixedHexError> {
Ok($ty(U256::from_unprefixed_hex(s)?))
}
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.