From 121b435a9b0ad6223a2f98c82b708cab92b84400 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 5 Aug 2024 06:22:41 +1000 Subject: [PATCH] base58: Use from to cast u8 `d58` is the iterator value from `Bytes` (iter returned by `String::bytes`). As such we can infallibly convert it using `from`. Internal change only, no external changes. --- base58/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/base58/src/lib.rs b/base58/src/lib.rs index e9f3b8ec0..7e882f4fc 100644 --- a/base58/src/lib.rs +++ b/base58/src/lib.rs @@ -73,11 +73,11 @@ pub fn decode(data: &str) -> Result, InvalidCharacterError> { // Build in base 256 for d58 in data.bytes() { // Compute "X = X * 58 + next_digit" in base 256 - if d58 as usize >= BASE58_DIGITS.len() { + if usize::from(d58) >= BASE58_DIGITS.len() { return Err(InvalidCharacterError { invalid: d58 }); } - let mut carry = match BASE58_DIGITS[d58 as usize] { - Some(d58) => d58 as u32, + let mut carry = match BASE58_DIGITS[usize::from(d58)] { + Some(d58) => u32::from(d58), None => { return Err(InvalidCharacterError { invalid: d58 }); }