Skip to content

Commit

Permalink
Derive Default for Witness
Browse files Browse the repository at this point in the history
No need for an explicit `Default` implementation for `Witness`, it can
be derived. Found by Clippy.
  • Loading branch information
tcharding committed May 25, 2022
1 parent c751898 commit 16cac3c
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/blockdata/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use serde;
/// For serialization and deserialization performance it is stored internally as a single `Vec`,
/// saving some allocations.
///
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
#[derive(Clone, Default, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
pub struct Witness {
/// contains the witness Vec<Vec<u8>> serialization without the initial varint indicating the
/// number of elements (which is stored in `witness_elements`)
Expand Down Expand Up @@ -249,19 +249,6 @@ impl Witness {
}
}

impl Default for Witness {
fn default() -> Self {
// from https://doc.rust-lang.org/std/vec/struct.Vec.html#method.new
// The vector will not allocate until elements are pushed onto it.
Witness {
content: Vec::new(),
witness_elements: 0,
last: 0,
second_to_last: 0,
}
}
}

impl<'a> Iterator for Iter<'a> {
type Item = &'a [u8];

Expand Down

0 comments on commit 16cac3c

Please sign in to comment.