units: Fix cargo cult programming

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.
This commit is contained in:
Tobin C. Harding 2024-03-13 09:34:58 +11:00
parent 7b7461c5d9
commit 290e4418e6
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
2 changed files with 2 additions and 2 deletions

View File

View File

@ -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,
})
}