From f62885890d0025d0117ca85947b982fcc5980fcb Mon Sep 17 00:00:00 2001 From: Harshil Jani Date: Sat, 25 Feb 2023 17:20:40 +0530 Subject: [PATCH] Accept borrowed values in InputWeightPrediction::new() Signed-off-by: Harshil Jani --- bitcoin/src/blockdata/transaction.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs index e6097564..e56f9209 100644 --- a/bitcoin/src/blockdata/transaction.rs +++ b/bitcoin/src/blockdata/transaction.rs @@ -1278,11 +1278,12 @@ pub struct InputWeightPrediction { impl InputWeightPrediction { /// Computes the prediction for a single input. - pub fn new(input_script_len: usize, witness_element_lengths: I) -> Self - where I: IntoIterator, + pub fn new(input_script_len: usize, witness_element_lengths: T) -> Self + where T :IntoIterator, T::Item:Borrow, { let (count, total_size) = witness_element_lengths.into_iter() .fold((0, 0), |(count, total_size), elem_len| { + let elem_len = *elem_len.borrow(); let elem_size = elem_len + VarInt(elem_len as u64).len(); (count + 1, total_size + elem_size) });