diff --git a/commit_verify/src/merkle.rs b/commit_verify/src/merkle.rs index 3e03fe52..bede75b9 100644 --- a/commit_verify/src/merkle.rs +++ b/commit_verify/src/merkle.rs @@ -19,8 +19,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use core::{iter, slice}; -use std::collections::{btree_set, BTreeSet}; +use std::collections::BTreeSet; use std::ops::SubAssign; use amplify::confinement::Confined; @@ -202,77 +201,49 @@ impl MerkleHash { pub trait MerkleLeaves { type Leaf: CommitId; - // TODO: Remove associated type - type LeafIter<'tmp>: ExactSizeIterator - where Self: 'tmp; - - fn merkle_leaves(&self) -> Self::LeafIter<'_>; + fn merkle_leaves(&self) -> impl ExactSizeIterator; } impl MerkleLeaves for Confined, MIN, { u8::MAX as usize }> -where T: CommitId + Copy +where T: CommitId { type Leaf = T; - type LeafIter<'tmp> - = iter::Copied> - where Self: 'tmp; - - fn merkle_leaves(&self) -> Self::LeafIter<'_> { self.iter().copied() } + fn merkle_leaves(&self) -> impl ExactSizeIterator { self.iter() } } impl MerkleLeaves for Confined, MIN, { u8::MAX as usize }> -where T: CommitId + Copy +where T: CommitId { type Leaf = T; - type LeafIter<'tmp> - = iter::Copied> - where Self: 'tmp; - - fn merkle_leaves(&self) -> Self::LeafIter<'_> { self.iter().copied() } + fn merkle_leaves(&self) -> impl ExactSizeIterator { self.iter() } } impl MerkleLeaves for Confined, MIN, { u16::MAX as usize }> -where T: CommitId + Copy +where T: CommitId { type Leaf = T; - type LeafIter<'tmp> - = iter::Copied> - where Self: 'tmp; - - fn merkle_leaves(&self) -> Self::LeafIter<'_> { self.iter().copied() } + fn merkle_leaves(&self) -> impl ExactSizeIterator { self.iter() } } impl MerkleLeaves for Confined, MIN, { u16::MAX as usize }> -where T: CommitId + Copy +where T: CommitId { type Leaf = T; - type LeafIter<'tmp> - = iter::Copied> - where Self: 'tmp; - - fn merkle_leaves(&self) -> Self::LeafIter<'_> { self.iter().copied() } + fn merkle_leaves(&self) -> impl ExactSizeIterator { self.iter() } } impl MerkleLeaves for Confined, MIN, { u32::MAX as usize }> -where T: CommitId + Copy +where T: CommitId { type Leaf = T; - type LeafIter<'tmp> - = iter::Copied> - where Self: 'tmp; - - fn merkle_leaves(&self) -> Self::LeafIter<'_> { self.iter().copied() } + fn merkle_leaves(&self) -> impl ExactSizeIterator { self.iter() } } impl MerkleLeaves for Confined, MIN, { u32::MAX as usize }> -where T: CommitId + Copy +where T: CommitId { type Leaf = T; - type LeafIter<'tmp> - = iter::Copied> - where Self: 'tmp; - - fn merkle_leaves(&self) -> Self::LeafIter<'_> { self.iter().copied() } + fn merkle_leaves(&self) -> impl ExactSizeIterator { self.iter() } } /// Helper struct to track depth when working with Merkle blocks.