Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(corelib): Use +Destruct instead of +Drop
Browse files Browse the repository at this point in the history
hudem1 committed Jan 18, 2025
1 parent 2fb1865 commit eb3cf8a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions corelib/src/iter/adapters/peekable.cairo
Original file line number Diff line number Diff line change
@@ -18,16 +18,17 @@ pub fn peekable_iterator<I, R>(iter: I) -> Peekable<I, R> {
}

impl PeekableIterator<
I, impl IterI: Iterator<I>, +Drop<I>, +Drop<IterI::Item>,
I, impl IterI: Iterator<I>, +Destruct<I>, +Destruct<IterI::Item>,
> of Iterator<Peekable<I, IterI::Item>> {
type Item = IterI::Item;

fn next(ref self: Peekable<I, IterI::Item>) -> Option<Self::Item> {
// `take()` makes sure that if a value was already peeked, `peeked` will be reset to None
match self.peeked.take() {
let next_value = match self.peeked {
Option::Some(v) => v,
Option::None => self.iter.next(),
}
};
self.peeked = Option::None;
next_value
}
}

0 comments on commit eb3cf8a

Please sign in to comment.