Introduce local variable

To make the stripping of the prefix a little clearer introduce a local
variable.

Refactor only, no logic changes.
This commit is contained in:
Tobin C. Harding 2024-04-02 09:46:21 +11:00
parent 1269722770
commit cf65bf035f
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 2 additions and 1 deletions

View File

@ -92,7 +92,8 @@ pub fn int<T: Integer, S: AsRef<str> + Into<String>>(s: S) -> Result<T, ParseInt
///
/// Input string may or may not contain a `0x` prefix.
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 {
let stripped = strip_hex_prefix(s.as_ref());
u32::from_str_radix(stripped, 16).map_err(|error| ParseIntError {
input: s.into(),
bits: 32,
is_signed: false,