Skip to content

Commit 4b66a47

Browse files
committed
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.
1 parent 3f8cf1b commit 4b66a47

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

base58/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,15 @@ where
208208
let mut leading_zeroes = true;
209209
// Build string in little endian with 0-58 in place of characters...
210210
for d256 in data {
211-
let mut carry = usize::from(d256);
211+
let mut carry = u32::from(d256);
212212
if leading_zeroes && carry == 0 {
213213
leading_zero_count += 1;
214214
} else {
215215
leading_zeroes = false;
216216
}
217217

218218
for ch in buf.slice_mut() {
219-
let new_ch = usize::from(*ch) * 256 + carry;
219+
let new_ch = u32::from(*ch) * 256 + carry;
220220
*ch = (new_ch % 58) as u8; // cast loses data intentionally
221221
carry = new_ch / 58;
222222
}

0 commit comments

Comments
 (0)