Accept borrowed values in InputWeightPrediction::new()
Signed-off-by: Harshil Jani <harshiljani2002@gmail.com>
This commit is contained in:
parent
fbb3b82b93
commit
f62885890d
|
@ -1278,11 +1278,12 @@ pub struct InputWeightPrediction {
|
||||||
|
|
||||||
impl InputWeightPrediction {
|
impl InputWeightPrediction {
|
||||||
/// Computes the prediction for a single input.
|
/// Computes the prediction for a single input.
|
||||||
pub fn new<I>(input_script_len: usize, witness_element_lengths: I) -> Self
|
pub fn new<T>(input_script_len: usize, witness_element_lengths: T) -> Self
|
||||||
where I: IntoIterator<Item = usize>,
|
where T :IntoIterator, T::Item:Borrow<usize>,
|
||||||
{
|
{
|
||||||
let (count, total_size) = witness_element_lengths.into_iter()
|
let (count, total_size) = witness_element_lengths.into_iter()
|
||||||
.fold((0, 0), |(count, total_size), elem_len| {
|
.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();
|
let elem_size = elem_len + VarInt(elem_len as u64).len();
|
||||||
(count + 1, total_size + elem_size)
|
(count + 1, total_size + elem_size)
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue