Skip to content

Commit

Permalink
Merge rust-bitcoin#2577: Fix cargo cult programming
Browse files Browse the repository at this point in the history
290e441 units: Fix cargo cult programming (Tobin C. Harding)

Pull request description:

  When creating the ParseIntError in `hex_u32` I (tobin) just cargo cult programmed the generic stuff without thinking.

  - The `is_signed` field is used to denote whether we were attempting to parse a signed or unsigned integer, it should be `false`.
  - The `bits` field should be directly set to 32.

ACKs for top commit:
  apoelstra:
    ACK 290e441
  sanket1729:
    ACK 290e441

Tree-SHA512: 7dfd9f0cd98eff1c2b27a92dac5c4e2fe0fa4ae724528ef741fe43d8d923e2d31cbdcd4e540ecfba1b953860dc2b728a958e756e2d2012d9a9e715c0ca3c5068
  • Loading branch information
apoelstra committed Mar 19, 2024
2 parents 002590b + 290e441 commit 6389d3f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Empty file removed bitcoin/src/parse.rs
Empty file.
4 changes: 2 additions & 2 deletions units/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ pub(crate) fn strip_hex_prefix(s: &str) -> &str {
pub fn hex_u32<S: AsRef<str> + Into<String>>(s: S) -> Result<u32, ParseIntError> {
u32::from_str_radix(strip_hex_prefix(s.as_ref()), 16).map_err(|error| ParseIntError {
input: s.into(),
bits: u8::try_from(core::mem::size_of::<u32>() * 8).expect("max is 32 bits for u32"),
is_signed: u32::try_from(-1i8).is_ok(),
bits: 32,
is_signed: false,
source: error,
})
}
Expand Down

0 comments on commit 6389d3f

Please sign in to comment.