Skip to content

Commit 22fadf4

Browse files
committed
Removed IntoIterator for TapTree implementation
In the future, TapTree may iterate over different node types, and that's why it does not have `iter()` function; using instead `script_leafs`. Thus, we should not have IntoIterator implementation as well
1 parent 173cc53 commit 22fadf4

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

src/util/psbt/map/output.rs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,15 @@ impl TapTree {
158158
/// Returns [`TapTreeIter`] iterator for a taproot script tree, operating in DFS order over
159159
/// tree [`ScriptLeaf`]s.
160160
pub fn script_leaves(&self) -> TapTreeIter {
161-
self.into_iter()
161+
match (self.0.branch().len(), self.0.branch().last()) {
162+
(1, Some(Some(root))) => {
163+
TapTreeIter {
164+
leaf_iter: root.leaves.iter()
165+
}
166+
}
167+
// This should be unreachable as we Taptree is already finalized
168+
_ => unreachable!("non-finalized tree builder inside TapTree"),
169+
}
162170
}
163171
}
164172

@@ -177,23 +185,6 @@ impl<'tree> Iterator for TapTreeIter<'tree> {
177185
}
178186
}
179187

180-
impl<'tree> IntoIterator for &'tree TapTree {
181-
type Item = &'tree ScriptLeaf;
182-
type IntoIter = TapTreeIter<'tree>;
183-
184-
fn into_iter(self) -> Self::IntoIter {
185-
match (self.0.branch().len(), self.0.branch().last()) {
186-
(1, Some(Some(root))) => {
187-
TapTreeIter {
188-
leaf_iter: root.leaves.iter()
189-
}
190-
}
191-
// This should be unreachable as we Taptree is already finalized
192-
_ => unreachable!("non-finalized tree builder inside TapTree"),
193-
}
194-
}
195-
}
196-
197188
impl Output {
198189
pub(super) fn insert_pair(&mut self, pair: raw::Pair) -> Result<(), encode::Error> {
199190
let raw::Pair {

0 commit comments

Comments
 (0)