From 16cac3cd702ef43278ff21bdb564a248f258fc08 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 25 May 2022 13:31:15 +1000 Subject: [PATCH] Derive Default for Witness No need for an explicit `Default` implementation for `Witness`, it can be derived. Found by Clippy. --- src/blockdata/witness.rs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/blockdata/witness.rs b/src/blockdata/witness.rs index b37f5071..e40fe8aa 100644 --- a/src/blockdata/witness.rs +++ b/src/blockdata/witness.rs @@ -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> serialization without the initial varint indicating the /// number of elements (which is stored in `witness_elements`) @@ -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];