From 4b66a479b0ddf71d2bcde61e2d8f34a197b479ad Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 7 Aug 2024 05:33:31 +1000 Subject: [PATCH] base58: Use u32 instead of usize The `carry` variable is used as a value not as an array index so we should use a `u32` - this is inline with other usage in the crate. --- base58/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base58/src/lib.rs b/base58/src/lib.rs index 5705a2d7f..7e0f15239 100644 --- a/base58/src/lib.rs +++ b/base58/src/lib.rs @@ -208,7 +208,7 @@ where let mut leading_zeroes = true; // Build string in little endian with 0-58 in place of characters... for d256 in data { - let mut carry = usize::from(d256); + let mut carry = u32::from(d256); if leading_zeroes && carry == 0 { leading_zero_count += 1; } else { @@ -216,7 +216,7 @@ where } for ch in buf.slice_mut() { - let new_ch = usize::from(*ch) * 256 + carry; + let new_ch = u32::from(*ch) * 256 + carry; *ch = (new_ch % 58) as u8; // cast loses data intentionally carry = new_ch / 58; }