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.
This commit is contained in:
parent
3f8cf1b335
commit
4b66a479b0
|
@ -208,7 +208,7 @@ where
|
||||||
let mut leading_zeroes = true;
|
let mut leading_zeroes = true;
|
||||||
// Build string in little endian with 0-58 in place of characters...
|
// Build string in little endian with 0-58 in place of characters...
|
||||||
for d256 in data {
|
for d256 in data {
|
||||||
let mut carry = usize::from(d256);
|
let mut carry = u32::from(d256);
|
||||||
if leading_zeroes && carry == 0 {
|
if leading_zeroes && carry == 0 {
|
||||||
leading_zero_count += 1;
|
leading_zero_count += 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -216,7 +216,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
for ch in buf.slice_mut() {
|
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
|
*ch = (new_ch % 58) as u8; // cast loses data intentionally
|
||||||
carry = new_ch / 58;
|
carry = new_ch / 58;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue