diff --git a/nomos-core/src/da/certificate/mod.rs b/nomos-core/src/da/certificate/mod.rs index 0885c020..cd1238af 100644 --- a/nomos-core/src/da/certificate/mod.rs +++ b/nomos-core/src/da/certificate/mod.rs @@ -20,5 +20,5 @@ pub trait BlobCertificateSelect { fn select_blob_from<'i, I: Iterator + 'i>( &self, certificates: I, - ) -> Box + 'i>; + ) -> impl Iterator + 'i; } diff --git a/nomos-core/src/da/certificate/select.rs b/nomos-core/src/da/certificate/select.rs index 07d1dae7..fe2f08f0 100644 --- a/nomos-core/src/da/certificate/select.rs +++ b/nomos-core/src/da/certificate/select.rs @@ -30,7 +30,7 @@ impl BlobCertificateSelect for FillSize + 'i>( &self, certificates: I, - ) -> Box + 'i> { + ) -> impl Iterator + 'i { utils::select::select_from_till_fill_size::( |blob| blob.as_bytes().len(), certificates, diff --git a/nomos-core/src/tx/mod.rs b/nomos-core/src/tx/mod.rs index 1b329abd..10d889bc 100644 --- a/nomos-core/src/tx/mod.rs +++ b/nomos-core/src/tx/mod.rs @@ -28,5 +28,5 @@ pub trait TxSelect { fn select_tx_from<'i, I: Iterator + 'i>( &self, txs: I, - ) -> Box + 'i>; + ) -> impl Iterator + 'i; } diff --git a/nomos-core/src/tx/select.rs b/nomos-core/src/tx/select.rs index 3ddd7ffb..7c839029 100644 --- a/nomos-core/src/tx/select.rs +++ b/nomos-core/src/tx/select.rs @@ -30,7 +30,7 @@ impl TxSelect for FillSize { fn select_tx_from<'i, I: Iterator + 'i>( &self, txs: I, - ) -> Box + 'i> { + ) -> impl Iterator + 'i { utils::select::select_from_till_fill_size::(|tx| tx.as_bytes().len(), txs) } } diff --git a/nomos-core/src/utils/select.rs b/nomos-core/src/utils/select.rs index 9a5d573c..c4235cef 100644 --- a/nomos-core/src/utils/select.rs +++ b/nomos-core/src/utils/select.rs @@ -1,10 +1,10 @@ pub fn select_from_till_fill_size<'i, const SIZE: usize, T>( mut measure: impl FnMut(&T) -> usize + 'i, items: impl Iterator + 'i, -) -> Box + 'i> { +) -> impl Iterator + 'i { let mut current_size = 0usize; - Box::new(items.take_while(move |item: &T| { + items.take_while(move |item: &T| { current_size += measure(item); current_size <= SIZE - })) + }) }