refactor: prefer conversion methods to infallable casts

This commit is contained in:
Lucille L. Blumire 2025-04-17 15:53:55 +01:00
parent 2dea589c0e
commit 0768b0ad67
No known key found for this signature in database
GPG key ID: D168492023622329
2 changed files with 4 additions and 4 deletions

View file

@ -129,7 +129,7 @@ fn main() -> Result<()> {
let _ = device.seek(SeekFrom::Start(pstart))?;
assert_eq!(header.part_size, 128);
assert!(header.num_parts < u8::MAX as _);
assert!(header.num_parts < u32::from(u8::MAX));
let empty_bytes = [0u8; 128];
@ -177,8 +177,8 @@ fn main() -> Result<()> {
.find(|s| s.name().unwrap().eq(sect))
.ok_or(anyhow!("Failed to find section `{sect}`"))?;
let mut start = s.pointer_to_raw_data as u64;
let end = start + s.virtual_size as u64;
let mut start = u64::from(s.pointer_to_raw_data);
let end = start + u64::from(s.virtual_size);
debug!(sect, start, end, len = (s.virtual_size));

View file

@ -15,7 +15,7 @@ use sha3::{Digest, Keccak256};
pub fn recover_signer(sig: &[u8; 65], root_hash: &Message) -> Result<[u8; 20]> {
let sig = RecoverableSignature::from_compact(
&sig[0..64],
RecoveryId::try_from(sig[64] as i32 - 27)?,
RecoveryId::try_from(i32::from(sig[64]) - 27)?,
)?;
let public = SECP256K1.recover_ecdsa(root_hash, &sig)?;
Ok(public_key_to_ethereum_address(&public))