Remove unnecessary casts

Clippy emits a bunch of warnings of form:

 warning: casting to the same type is unnecessary ...

As suggested, remove the unnecessary casts.
This commit is contained in:
Tobin C. Harding 2022-11-04 11:44:23 +11:00
parent d8e94cf181
commit 624cda07b3
5 changed files with 6 additions and 6 deletions

View File

@ -284,7 +284,7 @@ impl Decodable for BlockTransactionsRequest {
// Since the number of indices ultimately represent transactions, // Since the number of indices ultimately represent transactions,
// we can limit the number of indices to the maximum number of // we can limit the number of indices to the maximum number of
// transactions that would be allowed in a vector. // transactions that would be allowed in a vector.
let byte_size = (nb_indexes as usize) let byte_size = (nb_indexes)
.checked_mul(mem::size_of::<Transaction>()) .checked_mul(mem::size_of::<Transaction>())
.ok_or(encode::Error::ParseFailed("Invalid length"))?; .ok_or(encode::Error::ParseFailed("Invalid length"))?;
if byte_size > encode::MAX_VEC_SIZE { if byte_size > encode::MAX_VEC_SIZE {

View File

@ -627,7 +627,7 @@ impl ExtendedPrivKey {
Network::Testnet | Network::Signet | Network::Regtest => [0x04, 0x35, 0x83, 0x94], Network::Testnet | Network::Signet | Network::Regtest => [0x04, 0x35, 0x83, 0x94],
}[..], }[..],
); );
ret[4] = self.depth as u8; ret[4] = self.depth;
ret[5..9].copy_from_slice(&self.parent_fingerprint[..]); ret[5..9].copy_from_slice(&self.parent_fingerprint[..]);
ret[9..13].copy_from_slice(&u32::from(self.child_number).to_be_bytes()); ret[9..13].copy_from_slice(&u32::from(self.child_number).to_be_bytes());
ret[13..45].copy_from_slice(&self.chain_code[..]); ret[13..45].copy_from_slice(&self.chain_code[..]);
@ -759,7 +759,7 @@ impl ExtendedPubKey {
Network::Testnet | Network::Signet | Network::Regtest => [0x04u8, 0x35, 0x87, 0xCF], Network::Testnet | Network::Signet | Network::Regtest => [0x04u8, 0x35, 0x87, 0xCF],
}[..], }[..],
); );
ret[4] = self.depth as u8; ret[4] = self.depth;
ret[5..9].copy_from_slice(&self.parent_fingerprint[..]); ret[5..9].copy_from_slice(&self.parent_fingerprint[..]);
ret[9..13].copy_from_slice(&u32::from(self.child_number).to_be_bytes()); ret[9..13].copy_from_slice(&u32::from(self.child_number).to_be_bytes());
ret[13..45].copy_from_slice(&self.chain_code[..]); ret[13..45].copy_from_slice(&self.chain_code[..]);

View File

@ -179,7 +179,7 @@ impl Witness {
/// Returns the number of elements this witness holds /// Returns the number of elements this witness holds
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
self.witness_elements as usize self.witness_elements
} }
/// Returns the bytes required when this Witness is consensus encoded /// Returns the bytes required when this Witness is consensus encoded

View File

@ -423,7 +423,7 @@ impl Encodable for VarInt {
}, },
_ => { _ => {
w.emit_u8(0xFF)?; w.emit_u8(0xFF)?;
(self.0 as u64).consensus_encode(w)?; self.0.consensus_encode(w)?;
Ok(9) Ok(9)
}, },
} }

View File

@ -198,7 +198,7 @@ impl Target {
size += 1; size += 1;
} }
CompactTarget(compact | (size << 24) as u32) CompactTarget(compact | (size << 24))
} }
/// Returns true if block hash is less than or equal to this [`Target`]. /// Returns true if block hash is less than or equal to this [`Target`].