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.
This commit is contained in:
Tobin C. Harding 2024-08-05 06:22:41 +10:00
parent 8c0de95749
commit 121b435a9b
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 3 additions and 3 deletions

View File

@ -73,11 +73,11 @@ pub fn decode(data: &str) -> Result<Vec<u8>, 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 });
}