refactor: partially refactor iter types into submodules#1531
refactor: partially refactor iter types into submodules#1531demosdemon wants to merge 1 commit intomainfrom
Conversation
| /// An iterator over key-value pairs that stops after a specified final key. | ||
| #[derive(Debug)] | ||
| #[must_use = "iterators are lazy and do nothing unless consumed"] | ||
| pub enum FilteredKeyRangeIter<I, K> { |
There was a problem hiding this comment.
nit: naming
FilteredKeyRangeIter::Unfiltered seems odd. Perhaps MaybeFilteredKeyRangeIter is better?
| } | ||
| } | ||
|
|
||
| impl<I: Iterator<Item = T>, T: KeyValuePair, K: KeyType> Iterator for FilteredKeyRangeIter<I, K> { |
There was a problem hiding this comment.
Should also impl FusedIterator since this code will also fuse the underlying iterator.
Probably should document that it will fuse it as well.
|
|
||
| impl<I: Iterator> ReturnableIteratorExt for I {} | ||
|
|
||
| /// Similar to a peekable iterator. In addition to being able to peek at the |
There was a problem hiding this comment.
I'm not sure I'm following what this does that Peekable's blanket implementation does not do., except it's a little less flexible. Peekable keeps a peeked: Option<Option<I::Item>> inside it, but also supports stuff like peek_mut which can be used to implement return_item.
There was a problem hiding this comment.
also supports stuff like
peek_mutwhich can be used to implementreturn_item.
peek_mut does not do what I need. If it returned &mut Option<I::Item>, that would be sufficient. However, it returns Option<&mut I::Item> which is not the same thing.
Peekable provides no way for us to push the item back to the front of the iterator.
This is similar to using VecDeque to push_front but with a slot for only one element.
This partially refactors some of the iterator types into submodules.
The
peekmethod was added toReturnableIteratorbecause it will be necessary in a future PR for #1441.