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:
parent
8c0de95749
commit
121b435a9b
|
@ -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 });
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue