7001e93ad5 Fix clippy warnings (Tobin C. Harding)

Pull request description:

  We have a bunch of clippy warnings on master, at least one of them is from a patch dated from March, before we ran clippy on CI.

  Fix clippy warnings

  - warning: accessing first element with `self.0.get(0)`
  - warning: deref on an immutable reference
  - warning: you are deriving `PartialEq` and can implement `Eq`

  All one patch because clippy has to run cleanly for each patch on CI now.

  Please note the `Eq` change, adding this derive is an API change.

ACKs for top commit:
  apoelstra:
    ACK 7001e93ad5
  sanket1729:
    ACK 7001e93ad5

Tree-SHA512: b59bf92a8222d236538fe38951a92d0daaf86fc19e4ec4752c0eaf3e5b59025953560d089c72141d90f72ea137ec70425b4fa438ebfae65160fbd8799b95af7d
This commit is contained in:
sanket1729 2022-08-11 14:30:45 -07:00
commit 0eff9eb94a
No known key found for this signature in database
GPG Key ID: 648FFB183E0870A2
5 changed files with 5 additions and 5 deletions

View File

@ -473,7 +473,7 @@ impl Script {
/// Returns witness version of the script, if any, assuming the script is a `scriptPubkey`.
#[inline]
pub fn witness_version(&self) -> Option<WitnessVersion> {
self.0.get(0).and_then(|opcode| WitnessVersion::try_from(opcodes::All::from(*opcode)).ok())
self.0.first().and_then(|opcode| WitnessVersion::try_from(opcodes::All::from(*opcode)).ok())
}
/// Checks whether a script pubkey is a P2SH output.

View File

@ -847,7 +847,7 @@ impl Transaction {
S: FnMut(&OutPoint) -> Option<TxOut>,
F: Into<u32>
{
let tx = encode::serialize(&*self);
let tx = encode::serialize(self);
let flags: u32 = flags.into();
for (idx, input) in self.input.iter().enumerate() {
if let Some(output) = spent(&input.previous_output) {

View File

@ -179,7 +179,7 @@ impl HeaderAndShortIds {
let mut last_prefill = 0;
for (idx, tx) in block.txdata.iter().enumerate() {
// Check if we should prefill this tx.
let prefill_tx = if prefill.get(0) == Some(&idx) {
let prefill_tx = if prefill.first() == Some(&idx) {
prefill = &prefill[1..];
true
} else {

View File

@ -29,7 +29,7 @@ pub struct Key {
}
/// A PSBT key-value pair in its raw byte form.
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
pub struct Pair {

View File

@ -905,7 +905,7 @@ impl<'a> Annex<'a> {
/// Returns the Annex bytes data (including first byte `0x50`).
pub fn as_bytes(&self) -> &[u8] {
&*self.0
self.0
}
}