Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/peeking_take_while.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,28 @@ peeking_next_by_clone! { ['a] ::std::str::Bytes<'a> }
peeking_next_by_clone! { ['a, T] ::std::option::Iter<'a, T> }
peeking_next_by_clone! { ['a, T] ::std::result::Iter<'a, T> }
peeking_next_by_clone! { [T] ::std::iter::Empty<T> }

#[cfg(feature = "use_alloc")]
peeking_next_by_clone! { ['a, T] alloc::collections::linked_list::Iter<'a, T> }
#[cfg(feature = "use_alloc")]
peeking_next_by_clone! { ['a, T] alloc::collections::vec_deque::Iter<'a, T> }
const _: () = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace then const _ with repeated gates.

If we start adopting this pattern, we should do it consistently and not arbitrarily only here.

peeking_next_by_clone! { ['a, T] alloc::collections::linked_list::Iter<'a, T> }
peeking_next_by_clone! { ['a, T] alloc::collections::vec_deque::Iter<'a, T> }

peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Iter<'a, K, V> }
peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Keys<'a, K, V> }
peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Values<'a, K, V> }

peeking_next_by_clone! { ['a, T] alloc::collections::btree_set::Iter<'a, T> }
peeking_next_by_clone! { ['a, T] alloc::collections::binary_heap::Iter<'a, T> }
};

#[cfg(feature = "use_std")]
const _: () = {
peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Iter<'a, K, V> }
peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Keys<'a, K, V> }
peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Values<'a, K, V> }

peeking_next_by_clone! { ['a, T] std::collections::hash_set::Iter<'a, T> }
};

// cloning a Rev has no extra overhead; peekable and put backs are never DEI.
peeking_next_by_clone! { [I: Clone + PeekingNext + DoubleEndedIterator]
Expand Down
Loading